From b88ebf915130a856b98911f86878d9a2ef627dc9 Mon Sep 17 00:00:00 2001 From: Saman Sartipi Date: Tue, 17 Mar 2026 14:06:40 -0400 Subject: [PATCH] fix: linter errors --- aws/canonical_policy.go | 2 +- aws/service.go | 2 +- aws/table_aws_cloudwatch_log_metric_filter.go | 7 ++++--- aws/table_aws_ec2_launch_template_version.go | 2 +- aws/table_aws_iam_credential_report.go | 7 ++++--- aws/table_aws_organizations_account.go | 2 +- ...e_aws_organizations_organizational_unit.go | 2 +- aws/table_aws_resource_explorer_search.go | 4 ++-- ..._aws_servicecatalog_provisioned_product.go | 2 +- aws/table_aws_ssm_inventory.go | 19 +++++++++++-------- aws/vpcflowlogs/flow_log_events_s3.go | 16 ++++++++-------- 11 files changed, 35 insertions(+), 30 deletions(-) diff --git a/aws/canonical_policy.go b/aws/canonical_policy.go index 6cdb0e158..ebcf0134c 100644 --- a/aws/canonical_policy.go +++ b/aws/canonical_policy.go @@ -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 diff --git a/aws/service.go b/aws/service.go index ec55169b5..96799be3d 100644 --- a/aws/service.go +++ b/aws/service.go @@ -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 { diff --git a/aws/table_aws_cloudwatch_log_metric_filter.go b/aws/table_aws_cloudwatch_log_metric_filter.go index 7222afb41..4c4421df4 100644 --- a/aws/table_aws_cloudwatch_log_metric_filter.go +++ b/aws/table_aws_cloudwatch_log_metric_filter.go @@ -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 } } diff --git a/aws/table_aws_ec2_launch_template_version.go b/aws/table_aws_ec2_launch_template_version.go index 87b572ba4..4ddc59fb4 100644 --- a/aws/table_aws_ec2_launch_template_version.go +++ b/aws/table_aws_ec2_launch_template_version.go @@ -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. diff --git a/aws/table_aws_iam_credential_report.go b/aws/table_aws_iam_credential_report.go index 24cb703e1..2c87515d6 100644 --- a/aws/table_aws_iam_credential_report.go +++ b/aws/table_aws_iam_credential_report.go @@ -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) @@ -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 diff --git a/aws/table_aws_organizations_account.go b/aws/table_aws_organizations_account.go index dcc9ddaf9..928338d6f 100644 --- a/aws/table_aws_organizations_account.go +++ b/aws/table_aws_organizations_account.go @@ -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 diff --git a/aws/table_aws_organizations_organizational_unit.go b/aws/table_aws_organizations_organizational_unit.go index 95f9170a4..f6daf0e90 100644 --- a/aws/table_aws_organizations_organizational_unit.go +++ b/aws/table_aws_organizations_organizational_unit.go @@ -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 diff --git a/aws/table_aws_resource_explorer_search.go b/aws/table_aws_resource_explorer_search.go index c0ddceb99..6d0822a39 100644 --- a/aws/table_aws_resource_explorer_search.go +++ b/aws/table_aws_resource_explorer_search.go @@ -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 @@ -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) } } diff --git a/aws/table_aws_servicecatalog_provisioned_product.go b/aws/table_aws_servicecatalog_provisioned_product.go index 92b9fc627..397ad83d0 100644 --- a/aws/table_aws_servicecatalog_provisioned_product.go +++ b/aws/table_aws_servicecatalog_provisioned_product.go @@ -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 diff --git a/aws/table_aws_ssm_inventory.go b/aws/table_aws_ssm_inventory.go index 5080229cd..9e3fd4e2d 100644 --- a/aws/table_aws_ssm_inventory.go +++ b/aws/table_aws_ssm_inventory.go @@ -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 } } @@ -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) @@ -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) diff --git a/aws/vpcflowlogs/flow_log_events_s3.go b/aws/vpcflowlogs/flow_log_events_s3.go index 018e0cb4d..2e5601e81 100644 --- a/aws/vpcflowlogs/flow_log_events_s3.go +++ b/aws/vpcflowlogs/flow_log_events_s3.go @@ -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 } @@ -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 } @@ -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 } } @@ -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++ @@ -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 {