Skip to content

Commit e03ad3a

Browse files
authored
feat: [IAC-3149]: Use log keys from executable response when possible (#79)
* IAC-3149: use new log keys object when possible * IAC-3149: revert tail to blob
1 parent 94423fe commit e03ad3a

File tree

3 files changed

+30
-11
lines changed

3 files changed

+30
-11
lines changed

client/iacm-client.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,22 @@ type ExecutionNodeAdjacencyList struct {
236236
}
237237

238238
type ExecutionNode struct {
239-
Uuid string `json:"uuid,omitempty"`
240-
SetupId string `json:"setupId,omitempty"`
241-
Name string `json:"name,omitempty"`
242-
Identifier string `json:"identifier,omitempty"`
243-
StepType string `json:"stepType,omitempty"`
244-
Status string `json:"status,omitempty"`
245-
LogBaseKey string `json:"logBaseKey,omitempty"`
239+
Uuid string `json:"uuid,omitempty"`
240+
SetupId string `json:"setupId,omitempty"`
241+
Name string `json:"name,omitempty"`
242+
Identifier string `json:"identifier,omitempty"`
243+
StepType string `json:"stepType,omitempty"`
244+
Status string `json:"status,omitempty"`
245+
LogBaseKey string `json:"logBaseKey,omitempty"`
246+
ExecutableResponses []ExecutableResponse `json:"executableResponses"`
247+
}
248+
249+
type ExecutableResponse struct {
250+
Async Async `json:"async"`
251+
}
252+
253+
type Async struct {
254+
LogKeys []string `json:"logKeys"`
246255
}
247256

248257
type ResponseMessage struct {

client/log-client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ func (c *LogClient) Tail(ctx context.Context, key string) error {
7878
line, err := formatLogs(event.Data)
7979
if err != nil {
8080
fmt.Println(err)
81+
} else {
82+
fmt.Println(line)
8183
}
82-
fmt.Println(line)
8384
})
8485
err = conn.Connect()
8586
if err != nil {

iacm-plan.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ func (c *IacmCommand) walkStage(ctx context.Context, executionID string, stageNo
306306
if lastStepNodeID != "" && !ok {
307307
go func() {
308308
fmt.Printf(startingStepMsg, stepNode.Name)
309-
err := c.logClient.Tail(ctx, stepNode.LogBaseKey)
309+
err := c.logClient.Tail(ctx, getLogKeyFromStepNode(stepNode))
310310
if err != nil {
311311
fmt.Println(err)
312312
}
@@ -323,7 +323,7 @@ func (c *IacmCommand) walkStage(ctx context.Context, executionID string, stageNo
323323
if lastStepNodeID != "" && !ok {
324324
go func() {
325325
fmt.Printf(startingStepMsg, stepNode.Name)
326-
err := c.logClient.Blob(ctx, stepNode.LogBaseKey)
326+
err := c.logClient.Blob(ctx, getLogKeyFromStepNode(stepNode))
327327
if err != nil {
328328
fmt.Println(err)
329329
}
@@ -399,8 +399,17 @@ func isInactiveStageNode(status string) bool {
399399
}
400400

401401
func shouldIgnoreStepType(stepType string) bool {
402-
if stepType == "IntegrationStageStepPMS" || stepType == "NG_EXECUTION" || stepType == "IACMPrepareExecution" {
402+
if stepType == "IACMIntegrationStageStepPMS" || stepType == "IntegrationStageStepPMS" || stepType == "NG_EXECUTION" || stepType == "IACMPrepareExecution" {
403403
return true
404404
}
405405
return false
406406
}
407+
408+
func getLogKeyFromStepNode(stepNode client.ExecutionNode) string {
409+
if len(stepNode.ExecutableResponses) >= 1 {
410+
if len(stepNode.ExecutableResponses[0].Async.LogKeys) >= 1 {
411+
return stepNode.ExecutableResponses[0].Async.LogKeys[0]
412+
}
413+
}
414+
return stepNode.LogBaseKey
415+
}

0 commit comments

Comments
 (0)