Skip to content
Closed
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
2 changes: 1 addition & 1 deletion aws/canonical_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func canonicalPolicy(src string) (interface{}, error) {
var policy Policy

if err := json.Unmarshal([]byte(src), &policy); err != nil {
return nil, fmt.Errorf("Convert policy failed unmarshalling source data: %+v. src: %s", err, url.QueryEscape(src))
return nil, fmt.Errorf("convert policy failed unmarshalling source data: %+v. src: %s", err, url.QueryEscape(src))
}

return policy, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -1862,7 +1862,7 @@ func getClientUncached(ctx context.Context, d *plugin.QueryData, h *plugin.Hydra
// number of retries as 9 (our default). The default maximum delay will not be more than approximately 3 minutes to avoid Steampipe
// waiting too long to return results
maxRetries := 9
var minRetryDelay time.Duration = 25 * time.Millisecond // Default minimum delay
var minRetryDelay = 25 * time.Millisecond // Default minimum delay

// Set max retry count from config file or env variable (config file has precedence)
if awsSpcConfig.MaxErrorRetryAttempts != nil {
Expand Down
7 changes: 4 additions & 3 deletions aws/table_aws_cloudwatch_log_metric_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,12 @@ func logMetricTransformationsData(ctx context.Context, d *transform.TransformDat
metricFilterData := d.HydrateItem.(types.MetricFilter)

if len(metricFilterData.MetricTransformations) > 0 {
if d.Param.(string) == "MetricName" {
switch d.Param.(string) {
case "MetricName":
return metricFilterData.MetricTransformations[0].MetricName, nil
} else if d.Param.(string) == "MetricNamespace" {
case "MetricNamespace":
return metricFilterData.MetricTransformations[0].MetricNamespace, nil
} else {
default:
return metricFilterData.MetricTransformations[0].MetricValue, nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_ec2_launch_template_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func listEc2LaunchTemplateVersions(ctx context.Context, d *plugin.QueryData, h *
}

if launchTemplateName != "" && launchTemplateId != "" {
return nil, fmt.Errorf("Both LaunchtemplateName and LaunchTemplateId cannot be passed in the where clause")
return nil, fmt.Errorf("both LaunchtemplateName and LaunchTemplateId cannot be passed in the where clause")
}

// The aws_ec2_launch_template table is used as the parent hydrate because the LaunchTemplateId is not specified in the input parameter, and it will return only the latest and default version launch templates.
Expand Down
7 changes: 4 additions & 3 deletions aws/table_aws_iam_credential_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func listCredentialReports(ctx context.Context, d *plugin.QueryData, _ *plugin.H
var ae smithy.APIError
if errors.As(err, &ae) {
if ae.ErrorCode() == "ReportNotPresent" {
return nil, errors.New("Credential report not available. Please run 'aws iam generate-credential-report' to generate it and try again.")
return nil, errors.New("credential report not available; please run 'aws iam generate-credential-report' to generate it and try again")
}
}
plugin.Logger(ctx).Error("aws_iam_credential_report.listCredentialReports", "api_error", err)
Expand Down Expand Up @@ -267,9 +267,10 @@ func passwordEnabledToBool(_ context.Context, d *transform.TransformData) (inter
func passwordStatus(_ context.Context, d *transform.TransformData) (interface{}, error) {
used := types.SafeString(d.Value)
pwdStatus := "used"
if used == "no_information" {
switch used {
case "no_information":
pwdStatus = "never_used"
} else if used == "N/A" {
case "N/A":
pwdStatus = "not_set"
}
return pwdStatus, nil
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_organizations_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func listAllOusByParent(ctx context.Context, d *plugin.QueryData, svc *organizat
}

for _, unit := range output.OrganizationalUnits {
ouPath := strings.Replace(currentPath, "-", "_", -1) + "." + strings.Replace(*unit.Id, "-", "_", -1)
ouPath := strings.ReplaceAll(currentPath, "-", "_") + "." + strings.ReplaceAll(*unit.Id, "-", "_")
units = append(units, unit)

// Recursively list units for this child
Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_organizations_organizational_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func listAllNestedOUs(ctx context.Context, d *plugin.QueryData, svc *organizatio
}

for _, unit := range output.OrganizationalUnits {
ouPath := strings.Replace(currentPath, "-", "_", -1) + "." + strings.Replace(*unit.Id, "-", "_", -1)
ouPath := strings.ReplaceAll(currentPath, "-", "_") + "." + strings.ReplaceAll(*unit.Id, "-", "_")
d.StreamListItem(ctx, OrganizationalUnit{unit, ouPath, parentId})

// Recursively list units for this child
Expand Down
4 changes: 2 additions & 2 deletions aws/table_aws_resource_explorer_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func awsResourceExplorerSearch(ctx context.Context, d *plugin.QueryData, h *plug
}

if len(indexesOutput.Indexes) == 0 {
return nil, fmt.Errorf("Aggregator index not found in account %s. Please create an aggregator index or specify \"view_arn\".", accountID)
return nil, fmt.Errorf("aggregator index not found in account %s; please create an aggregator index or specify \"view_arn\"", accountID)
}

// Each account can only have 1 aggregator index
Expand All @@ -170,7 +170,7 @@ func awsResourceExplorerSearch(ctx context.Context, d *plugin.QueryData, h *plug
}

if defaultViewOutput.ViewArn == nil {
return nil, fmt.Errorf("Default view not found in %s region in account %s. Please create a default view or specify \"view_arn\".", region, accountID)
return nil, fmt.Errorf("default view not found in %s region in account %s; please create a default view or specify \"view_arn\"", region, accountID)
}
}

Expand Down
2 changes: 1 addition & 1 deletion aws/table_aws_servicecatalog_provisioned_product.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func getServiceCatalogProvisionedProduct(ctx context.Context, d *plugin.QueryDat
}

if id != "" && name != "" {
return nil, fmt.Errorf("Both ProvisionedProductName and ProvisionedProductId cannot be passed in the where clause simultaneously")
return nil, fmt.Errorf("both ProvisionedProductName and ProvisionedProductId cannot be passed in the where clause simultaneously")
}

// Create client
Expand Down
19 changes: 11 additions & 8 deletions aws/table_aws_ssm_inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,10 @@ func buildSSMInventoryFilter(ctx context.Context, quals *plugin.QueryData) ssm.G
Values: []string{quals.EqualsQualString("instance_id")},
},
}
if q.Operator == "=" {
switch q.Operator {
case "=":
input.Filters[0].Type = types.InventoryQueryOperatorTypeEqual
} else if q.Operator == "<>" {
case "<>":
input.Filters[0].Type = types.InventoryQueryOperatorTypeNotEqual
}
}
Expand Down Expand Up @@ -492,9 +493,10 @@ func buildSSMInventoryFilter(ctx context.Context, quals *plugin.QueryData) ssm.G
Values: []string{value.(string)},
},
}
if q.Operator == "=" {
switch q.Operator {
case "=":
input.Filters[0].Type = types.InventoryQueryOperatorTypeEqual
} else if q.Operator == "<>" {
case "<>":
input.Filters[0].Type = types.InventoryQueryOperatorTypeNotEqual
}
input.Filters = append(input.Filters, inventoryFilter)
Expand All @@ -504,13 +506,14 @@ func buildSSMInventoryFilter(ctx context.Context, quals *plugin.QueryData) ssm.G
if shouldFilterKeyValueApplied {
inventoryFilter.Key = aws.String(value.(string))
inventoryFilter.Values = []string{filterValue}
if filterOperator == "=" {
switch filterOperator {
case "=":
inventoryFilter.Type = types.InventoryQueryOperatorTypeEqual
} else if filterOperator == "<>" {
case "<>":
inventoryFilter.Type = types.InventoryQueryOperatorTypeNotEqual
} else if filterOperator == "<" || filterOperator == "<=" {
case "<", "<=":
inventoryFilter.Type = types.InventoryQueryOperatorTypeLessThan
} else if filterOperator == ">" || filterOperator == ">=" {
case ">", ">=":
inventoryFilter.Type = types.InventoryQueryOperatorTypeGreaterThan
}
input.Filters = append(input.Filters, inventoryFilter)
Expand Down
16 changes: 8 additions & 8 deletions aws/vpcflowlogs/flow_log_events_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (r *S3FlowLogEventsRetriever) processObjectsWorker(
if ctx.Err() != nil {
r.logger.Trace("listS3FlowLogEvents", "worker_id", workerID,
"message", "Context done after object download", "key", key, "reason", ctx.Err())
objOut.Body.Close()
_ = objOut.Body.Close()
return
}

Expand All @@ -326,7 +326,7 @@ func (r *S3FlowLogEventsRetriever) processObjectsWorker(
r.logger.Error("listS3FlowLogEvents", "worker_id", workerID,
"message", "Failed to create gzip reader",
"key", key, "error", err)
objOut.Body.Close()
_ = objOut.Body.Close()
if !sendWithContext(ctx, errorChan, err) {
return
}
Expand All @@ -353,8 +353,8 @@ func (r *S3FlowLogEventsRetriever) processObjectsWorker(
r.logger.Debug("listS3FlowLogEvents", "worker_id", workerID,
"message", "Context done during scanning", "key", key,
"lines_processed", lineNum, "reason", ctx.Err())
gr.Close()
objOut.Body.Close()
_ = gr.Close()
_ = objOut.Body.Close()
return
}
}
Expand Down Expand Up @@ -414,8 +414,8 @@ func (r *S3FlowLogEventsRetriever) processObjectsWorker(
r.logger.Debug("listS3FlowLogEvents", "worker_id", workerID,
"message", "Failed to send event to channel, context done",
"key", key, "lines_processed", lineNum)
gr.Close()
objOut.Body.Close()
_ = gr.Close()
_ = objOut.Body.Close()
return
}
lineNum++
Expand All @@ -434,8 +434,8 @@ func (r *S3FlowLogEventsRetriever) processObjectsWorker(
r.logger.Trace("listS3FlowLogEvents", "worker_id", workerID,
"message", "Completed processing object",
"key", key, "lines_processed", lineNum)
gr.Close()
objOut.Body.Close()
_ = gr.Close()
_ = objOut.Body.Close()

// Check context after finishing an object
if ctx.Err() != nil {
Expand Down