Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions providers/aws/services/elasticache/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,7 @@ func (c *Client) paginateElastiCacheOfferings(ctx context.Context, rec common.Re
if err != nil {
return "", err
}
tag := execID
if tag == "" {
tag = "no-exec"
}
tag := resolveTag(execID)
t0 := time.Now()
log.Printf("purchase[%s]: ElastiCache findOfferingID starting (nodeType=%s engine=%s duration=%s payment=%s)",
tag, rec.ResourceType, details.Engine, duration, offeringType)
Expand Down Expand Up @@ -359,6 +356,17 @@ func scanElastiCacheOfferingPage(offerings []types.ReservedCacheNodesOffering, r
return "", nil
}

// resolveTag returns execID when non-empty, or a sentinel "no-exec" string for
// log correlation when called outside of a purchase flow (e.g. ValidateOffering,
// GetOfferingDetails). Extracted from paginateElastiCacheOfferings to keep
// cyclomatic complexity within the pre-commit gocyclo limit (issue #1388).
func resolveTag(execID string) string {
if execID == "" {
return "no-exec"
}
return execID
}

// ValidateOffering checks if an offering exists without purchasing
func (c *Client) ValidateOffering(ctx context.Context, rec common.Recommendation) error {
_, err := c.findOfferingID(ctx, rec, "")
Expand Down
16 changes: 12 additions & 4 deletions providers/aws/services/memorydb/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,7 @@ func (c *Client) findOfferingID(ctx context.Context, rec common.Recommendation,
if err != nil {
return "", err
}
tag := execID
if tag == "" {
tag = "no-exec"
}
tag := resolveTag(execID)
t0 := time.Now()
log.Printf("purchase[%s]: MemoryDB findOfferingID starting (nodeType=%s term=%s payment=%s)",
tag, rec.ResourceType, rec.Term, rec.PaymentOption)
Expand Down Expand Up @@ -380,6 +377,17 @@ func isLastMemoryDBPage(nextToken *string) bool {
return nextToken == nil || aws.ToString(nextToken) == ""
}

// resolveTag returns execID when non-empty, or a sentinel "no-exec" string for
// log correlation when called outside of a purchase flow (e.g. ValidateOffering,
// GetOfferingDetails). Extracted from findOfferingID to keep cyclomatic complexity
// within the pre-commit gocyclo limit (issue #1388).
func resolveTag(execID string) string {
if execID == "" {
return "no-exec"
}
return execID
}

// getDurationStringForAPI converts the term string to a duration value accepted
// by DescribeReservedNodesOfferings (seconds as a string or "1yr"/"3yr").
// The MemoryDB API accepts both numeric-seconds strings and year strings.
Expand Down
16 changes: 12 additions & 4 deletions providers/aws/services/opensearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,7 @@ func (c *Client) findOfferingID(ctx context.Context, rec common.Recommendation,
if err != nil {
return "", err
}
tag := execID
if tag == "" {
tag = "no-exec"
}
tag := resolveTag(execID)
t0 := time.Now()
log.Printf("purchase[%s]: OpenSearch findOfferingID starting (instanceType=%s term=%s payment=%s)",
tag, rec.ResourceType, rec.Term, rec.PaymentOption)
Expand Down Expand Up @@ -608,3 +605,14 @@ func getTermMonthsFromDuration(duration int32) int {
}
return 12
}

// resolveTag returns execID when non-empty, or a sentinel "no-exec" string for
// log correlation when called outside of a purchase flow (e.g. ValidateOffering,
// GetOfferingDetails). Extracted from findOfferingID to keep cyclomatic complexity
// within the pre-commit gocyclo limit (issue #1388).
func resolveTag(execID string) string {
if execID == "" {
return "no-exec"
}
return execID
}
16 changes: 12 additions & 4 deletions providers/aws/services/redshift/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,7 @@ func (c *Client) findOfferingID(ctx context.Context, rec common.Recommendation,
if err != nil {
return "", err
}
tag := execID
if tag == "" {
tag = "no-exec"
}
tag := resolveTag(execID)
t0 := time.Now()
log.Printf("purchase[%s]: Redshift findOfferingID starting (nodeType=%s term=%s payment=%s)",
tag, rec.ResourceType, rec.Term, rec.PaymentOption)
Expand Down Expand Up @@ -691,3 +688,14 @@ func getTermMonthsFromDuration(duration int32) int {
}
return 12
}

// resolveTag returns execID when non-empty, or a sentinel "no-exec" string for
// log correlation when called outside of a purchase flow (e.g. ValidateOffering,
// GetOfferingDetails). Extracted from findOfferingID to keep cyclomatic complexity
// within the pre-commit gocyclo limit (issue #1388).
func resolveTag(execID string) string {
if execID == "" {
return "no-exec"
}
return execID
}
Loading