diff --git a/.changelog/3862dfedda7e4cf9b8593de8ac95a77e.json b/.changelog/3862dfedda7e4cf9b8593de8ac95a77e.json new file mode 100644 index 00000000000..c29b0e6a377 --- /dev/null +++ b/.changelog/3862dfedda7e4cf9b8593de8ac95a77e.json @@ -0,0 +1,8 @@ +{ + "id": "3862dfed-da7e-4cf9-b859-3de8ac95a77e", + "type": "feature", + "description": "Switch to new waiter matching implementation, which conveys a slight performance boost and removes the need for the go-jmespath runtime dependency.", + "modules": [ + "service/ec2" + ] +} \ No newline at end of file diff --git a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AwsWaiters.java b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AwsWaiters.java index 7ec04211057..5d011ec6342 100644 --- a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AwsWaiters.java +++ b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AwsWaiters.java @@ -20,12 +20,11 @@ import software.amazon.smithy.aws.go.codegen.AwsGoDependency; import software.amazon.smithy.codegen.core.Symbol; -import software.amazon.smithy.codegen.core.SymbolProvider; -import software.amazon.smithy.go.codegen.GoDelegator; -import software.amazon.smithy.go.codegen.GoSettings; +import software.amazon.smithy.go.codegen.GoCodegenContext; import software.amazon.smithy.go.codegen.SmithyGoDependency; import software.amazon.smithy.go.codegen.integration.Waiters; import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.ShapeId; import static software.amazon.smithy.go.codegen.GoWriter.goTemplate; import static software.amazon.smithy.go.codegen.SymbolUtils.buildPackageSymbol; @@ -40,10 +39,16 @@ public Set getAdditionalClientOptions() { } @Override - public void writeAdditionalFiles(GoSettings settings, Model model, SymbolProvider symbolProvider, GoDelegator goDelegator) { - super.writeAdditionalFiles(settings, model, symbolProvider, goDelegator); + public boolean enabledForService(Model model, ShapeId service) { + return !AwsWaiters2.PHASED_ROLLOUT_SERVICES.contains(service); + } + + @Override + public void writeAdditionalFiles(GoCodegenContext ctx) { + super.writeAdditionalFiles(ctx); - goDelegator.useFileWriter("api_client.go", settings.getModuleName(), goTemplate(""" + // happens regardless of enabledForService() == true - so AwsWaiters2 can use it + ctx.writerDelegator().useFileWriter("api_client.go", ctx.settings().getModuleName(), goTemplate(""" func addIsWaiterUserAgent(o *Options) { o.APIOptions = append(o.APIOptions, func(stack $stack:P) error { ua, err := getOrAddRequestUserAgent(stack) diff --git a/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AwsWaiters2.java b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AwsWaiters2.java new file mode 100644 index 00000000000..2ac74322436 --- /dev/null +++ b/codegen/smithy-aws-go-codegen/src/main/java/software/amazon/smithy/aws/go/codegen/customization/AwsWaiters2.java @@ -0,0 +1,27 @@ +package software.amazon.smithy.aws.go.codegen.customization; + +import software.amazon.smithy.codegen.core.Symbol; +import software.amazon.smithy.go.codegen.integration.Waiters2; +import software.amazon.smithy.model.Model; +import software.amazon.smithy.model.shapes.ShapeId; + +import java.util.List; +import java.util.Set; + +import static software.amazon.smithy.go.codegen.SymbolUtils.buildPackageSymbol; + +public class AwsWaiters2 extends Waiters2 { + public static final List PHASED_ROLLOUT_SERVICES = List.of( + ShapeId.from("com.amazonaws.ec2#AmazonEC2") + ); + + @Override + public Set getAdditionalClientOptions() { + return Set.of(buildPackageSymbol("addIsWaiterUserAgent")); + } + + @Override + public boolean enabledForService(Model model, ShapeId service) { + return PHASED_ROLLOUT_SERVICES.contains(service); + } +} diff --git a/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration b/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration index 25a74f25eea..cafa1e2a3f3 100644 --- a/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration +++ b/codegen/smithy-aws-go-codegen/src/main/resources/META-INF/services/software.amazon.smithy.go.codegen.integration.GoIntegration @@ -1,4 +1,5 @@ software.amazon.smithy.aws.go.codegen.customization.AwsWaiters +software.amazon.smithy.aws.go.codegen.customization.AwsWaiters2 software.amazon.smithy.aws.go.codegen.customization.AwsPaginators software.amazon.smithy.aws.go.codegen.customization.auth.BackfillSigV4ATrait software.amazon.smithy.aws.go.codegen.AddProtocols diff --git a/service/ec2/api_op_DescribeBundleTasks.go b/service/ec2/api_op_DescribeBundleTasks.go index add19eb359e..386f8e1b378 100644 --- a/service/ec2/api_op_DescribeBundleTasks.go +++ b/service/ec2/api_op_DescribeBundleTasks.go @@ -11,7 +11,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -334,29 +333,18 @@ func (w *BundleTaskCompleteWaiter) WaitForOutput(ctx context.Context, params *De func bundleTaskCompleteStateRetryable(ctx context.Context, input *DescribeBundleTasksInput, output *DescribeBundleTasksOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("BundleTasks[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.BundleTasks + var v2 []types.BundleTaskState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "complete" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.BundleTaskState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.BundleTaskState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -366,26 +354,23 @@ func bundleTaskCompleteStateRetryable(ctx context.Context, input *DescribeBundle } if err == nil { - pathValue, err := jmespath.Search("BundleTasks[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.BundleTasks + var v2 []types.BundleTaskState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "failed" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.BundleTaskState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.BundleTaskState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } diff --git a/service/ec2/api_op_DescribeConversionTasks.go b/service/ec2/api_op_DescribeConversionTasks.go index 999edbf9b82..41a934c492b 100644 --- a/service/ec2/api_op_DescribeConversionTasks.go +++ b/service/ec2/api_op_DescribeConversionTasks.go @@ -11,7 +11,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -306,29 +305,18 @@ func (w *ConversionTaskCancelledWaiter) WaitForOutput(ctx context.Context, param func conversionTaskCancelledStateRetryable(ctx context.Context, input *DescribeConversionTasksInput, output *DescribeConversionTasksOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("ConversionTasks[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.ConversionTasks + var v2 []types.ConversionTaskState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "cancelled" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.ConversionTaskState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.ConversionTaskState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -502,29 +490,18 @@ func (w *ConversionTaskCompletedWaiter) WaitForOutput(ctx context.Context, param func conversionTaskCompletedStateRetryable(ctx context.Context, input *DescribeConversionTasksInput, output *DescribeConversionTasksOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("ConversionTasks[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.ConversionTasks + var v2 []types.ConversionTaskState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "completed" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.ConversionTaskState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.ConversionTaskState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -534,50 +511,44 @@ func conversionTaskCompletedStateRetryable(ctx context.Context, input *DescribeC } if err == nil { - pathValue, err := jmespath.Search("ConversionTasks[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.ConversionTasks + var v2 []types.ConversionTaskState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "cancelled" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.ConversionTaskState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.ConversionTaskState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("ConversionTasks[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.ConversionTasks + var v2 []types.ConversionTaskState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "cancelling" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.ConversionTaskState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.ConversionTaskState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } @@ -746,29 +717,18 @@ func (w *ConversionTaskDeletedWaiter) WaitForOutput(ctx context.Context, params func conversionTaskDeletedStateRetryable(ctx context.Context, input *DescribeConversionTasksInput, output *DescribeConversionTasksOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("ConversionTasks[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.ConversionTasks + var v2 []types.ConversionTaskState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleted" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.ConversionTaskState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.ConversionTaskState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } diff --git a/service/ec2/api_op_DescribeCustomerGateways.go b/service/ec2/api_op_DescribeCustomerGateways.go index 01832f8b033..3ddf0d26275 100644 --- a/service/ec2/api_op_DescribeCustomerGateways.go +++ b/service/ec2/api_op_DescribeCustomerGateways.go @@ -11,7 +11,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -334,29 +333,20 @@ func (w *CustomerGatewayAvailableWaiter) WaitForOutput(ctx context.Context, para func customerGatewayAvailableStateRetryable(ctx context.Context, input *DescribeCustomerGatewaysInput, output *DescribeCustomerGatewaysOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("CustomerGateways[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.CustomerGateways + var v2 []string + for _, v := range v1 { + v3 := v.State + if v3 != nil { + v2 = append(v2, *v3) + } } - expectedValue := "available" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) - } - - if string(*value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -366,50 +356,48 @@ func customerGatewayAvailableStateRetryable(ctx context.Context, input *Describe } if err == nil { - pathValue, err := jmespath.Search("CustomerGateways[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.CustomerGateways + var v2 []string + for _, v := range v1 { + v3 := v.State + if v3 != nil { + v2 = append(v2, *v3) + } } - expectedValue := "deleted" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(*value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("CustomerGateways[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.CustomerGateways + var v2 []string + for _, v := range v1 { + v3 := v.State + if v3 != nil { + v2 = append(v2, *v3) + } } - expectedValue := "deleting" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(*value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } diff --git a/service/ec2/api_op_DescribeExportTasks.go b/service/ec2/api_op_DescribeExportTasks.go index 877fd6d4fc7..ec387d156c3 100644 --- a/service/ec2/api_op_DescribeExportTasks.go +++ b/service/ec2/api_op_DescribeExportTasks.go @@ -11,7 +11,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -298,29 +297,18 @@ func (w *ExportTaskCancelledWaiter) WaitForOutput(ctx context.Context, params *D func exportTaskCancelledStateRetryable(ctx context.Context, input *DescribeExportTasksInput, output *DescribeExportTasksOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("ExportTasks[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.ExportTasks + var v2 []types.ExportTaskState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "cancelled" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.ExportTaskState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.ExportTaskState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -494,29 +482,18 @@ func (w *ExportTaskCompletedWaiter) WaitForOutput(ctx context.Context, params *D func exportTaskCompletedStateRetryable(ctx context.Context, input *DescribeExportTasksInput, output *DescribeExportTasksOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("ExportTasks[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.ExportTasks + var v2 []types.ExportTaskState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "completed" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.ExportTaskState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.ExportTaskState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } diff --git a/service/ec2/api_op_DescribeImages.go b/service/ec2/api_op_DescribeImages.go index 8cf41e5544e..4124f644851 100644 --- a/service/ec2/api_op_DescribeImages.go +++ b/service/ec2/api_op_DescribeImages.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "strconv" "time" ) @@ -464,29 +463,18 @@ func (w *ImageAvailableWaiter) WaitForOutput(ctx context.Context, params *Descri func imageAvailableStateRetryable(ctx context.Context, input *DescribeImagesInput, output *DescribeImagesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Images[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Images + var v2 []types.ImageState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "available" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.ImageState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.ImageState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -496,26 +484,23 @@ func imageAvailableStateRetryable(ctx context.Context, input *DescribeImagesInpu } if err == nil { - pathValue, err := jmespath.Search("Images[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Images + var v2 []types.ImageState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "failed" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.ImageState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.ImageState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } @@ -681,22 +666,16 @@ func (w *ImageExistsWaiter) WaitForOutput(ctx context.Context, params *DescribeI func imageExistsStateRetryable(ctx context.Context, input *DescribeImagesInput, output *DescribeImagesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("length(Images[]) > `0`", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) - } - + v1 := output.Images + v2 := len(v1) + v3 := 0 + v4 := int64(v2) > int64(v3) expectedValue := "true" bv, err := strconv.ParseBool(expectedValue) if err != nil { return false, fmt.Errorf("error parsing boolean from string %w", err) } - value, ok := pathValue.(bool) - if !ok { - return false, fmt.Errorf("waiter comparator expected bool value got %T", pathValue) - } - - if value == bv { + if v4 == bv { return false, nil } } diff --git a/service/ec2/api_op_DescribeImportSnapshotTasks.go b/service/ec2/api_op_DescribeImportSnapshotTasks.go index 725d6e5b8ea..d6bd344911c 100644 --- a/service/ec2/api_op_DescribeImportSnapshotTasks.go +++ b/service/ec2/api_op_DescribeImportSnapshotTasks.go @@ -11,7 +11,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -313,29 +312,21 @@ func (w *SnapshotImportedWaiter) WaitForOutput(ctx context.Context, params *Desc func snapshotImportedStateRetryable(ctx context.Context, input *DescribeImportSnapshotTasksInput, output *DescribeImportSnapshotTasksOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("ImportSnapshotTasks[].SnapshotTaskDetail.Status", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.ImportSnapshotTasks + var v2 []string + for _, v := range v1 { + v3 := v.SnapshotTaskDetail + v4 := v3.Status + if v4 != nil { + v2 = append(v2, *v4) + } } - expectedValue := "completed" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) - } - - if string(*value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -345,26 +336,26 @@ func snapshotImportedStateRetryable(ctx context.Context, input *DescribeImportSn } if err == nil { - pathValue, err := jmespath.Search("ImportSnapshotTasks[].SnapshotTaskDetail.Status", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.ImportSnapshotTasks + var v2 []string + for _, v := range v1 { + v3 := v.SnapshotTaskDetail + v4 := v3.Status + if v4 != nil { + v2 = append(v2, *v4) + } } - expectedValue := "error" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(*value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } diff --git a/service/ec2/api_op_DescribeInstanceStatus.go b/service/ec2/api_op_DescribeInstanceStatus.go index 5a8b702ec39..51259254246 100644 --- a/service/ec2/api_op_DescribeInstanceStatus.go +++ b/service/ec2/api_op_DescribeInstanceStatus.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -396,29 +395,19 @@ func (w *InstanceStatusOkWaiter) WaitForOutput(ctx context.Context, params *Desc func instanceStatusOkStateRetryable(ctx context.Context, input *DescribeInstanceStatusInput, output *DescribeInstanceStatusOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("InstanceStatuses[].InstanceStatus.Status", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.InstanceStatuses + var v2 []types.SummaryStatus + for _, v := range v1 { + v3 := v.InstanceStatus + v4 := v3.Status + v2 = append(v2, v4) } - expectedValue := "ok" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.SummaryStatus) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.SummaryStatus value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -602,29 +591,19 @@ func (w *SystemStatusOkWaiter) WaitForOutput(ctx context.Context, params *Descri func systemStatusOkStateRetryable(ctx context.Context, input *DescribeInstanceStatusInput, output *DescribeInstanceStatusOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("InstanceStatuses[].SystemStatus.Status", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.InstanceStatuses + var v2 []types.SummaryStatus + for _, v := range v1 { + v3 := v.SystemStatus + v4 := v3.Status + v2 = append(v2, v4) } - expectedValue := "ok" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.SummaryStatus) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.SummaryStatus value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } diff --git a/service/ec2/api_op_DescribeInstances.go b/service/ec2/api_op_DescribeInstances.go index 7558f676efd..684aed47dbd 100644 --- a/service/ec2/api_op_DescribeInstances.go +++ b/service/ec2/api_op_DescribeInstances.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "strconv" "time" ) @@ -737,22 +736,16 @@ func (w *InstanceExistsWaiter) WaitForOutput(ctx context.Context, params *Descri func instanceExistsStateRetryable(ctx context.Context, input *DescribeInstancesInput, output *DescribeInstancesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("length(Reservations[]) > `0`", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) - } - + v1 := output.Reservations + v2 := len(v1) + v3 := 0 + v4 := int64(v2) > int64(v3) expectedValue := "true" bv, err := strconv.ParseBool(expectedValue) if err != nil { return false, fmt.Errorf("error parsing boolean from string %w", err) } - value, ok := pathValue.(bool) - if !ok { - return false, fmt.Errorf("waiter comparator expected bool value got %T", pathValue) - } - - if value == bv { + if v4 == bv { return false, nil } } @@ -932,29 +925,28 @@ func (w *InstanceRunningWaiter) WaitForOutput(ctx context.Context, params *Descr func instanceRunningStateRetryable(ctx context.Context, input *DescribeInstancesInput, output *DescribeInstancesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "running" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v5) > 0 + for _, v := range v5 { + if string(v) != expectedValue { match = false + break } } @@ -964,74 +956,95 @@ func instanceRunningStateRetryable(ctx context.Context, input *DescribeInstances } if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "shutting-down" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) + var match bool + for _, v := range v5 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "terminated" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) + var match bool + for _, v := range v5 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "stopping" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) + var match bool + for _, v := range v5 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } @@ -1210,29 +1223,28 @@ func (w *InstanceStoppedWaiter) WaitForOutput(ctx context.Context, params *Descr func instanceStoppedStateRetryable(ctx context.Context, input *DescribeInstancesInput, output *DescribeInstancesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "stopped" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v5) > 0 + for _, v := range v5 { + if string(v) != expectedValue { match = false + break } } @@ -1242,50 +1254,64 @@ func instanceStoppedStateRetryable(ctx context.Context, input *DescribeInstances } if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "pending" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) + var match bool + for _, v := range v5 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "terminated" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) + var match bool + for _, v := range v5 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } @@ -1452,29 +1478,28 @@ func (w *InstanceTerminatedWaiter) WaitForOutput(ctx context.Context, params *De func instanceTerminatedStateRetryable(ctx context.Context, input *DescribeInstancesInput, output *DescribeInstancesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "terminated" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v5) > 0 + for _, v := range v5 { + if string(v) != expectedValue { match = false + break } } @@ -1484,50 +1509,64 @@ func instanceTerminatedStateRetryable(ctx context.Context, input *DescribeInstan } if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "pending" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) + var match bool + for _, v := range v5 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("Reservations[].Instances[].State.Name", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Reservations + var v2 [][]types.Instance + for _, v := range v1 { + v3 := v.Instances + v2 = append(v2, v3) + } + var v4 []types.Instance + for _, v := range v2 { + v4 = append(v4, v...) + } + var v5 []types.InstanceStateName + for _, v := range v4 { + v6 := v.State + v7 := v6.Name + v5 = append(v5, v7) } - expectedValue := "stopping" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.InstanceStateName) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.InstanceStateName value, got %T", pathValue) + var match bool + for _, v := range v5 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } diff --git a/service/ec2/api_op_DescribeInternetGateways.go b/service/ec2/api_op_DescribeInternetGateways.go index e18a82f276d..c0bc59a1ae8 100644 --- a/service/ec2/api_op_DescribeInternetGateways.go +++ b/service/ec2/api_op_DescribeInternetGateways.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "strconv" "time" ) @@ -343,22 +342,23 @@ func (w *InternetGatewayExistsWaiter) WaitForOutput(ctx context.Context, params func internetGatewayExistsStateRetryable(ctx context.Context, input *DescribeInternetGatewaysInput, output *DescribeInternetGatewaysOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("length(InternetGateways[].InternetGatewayId) > `0`", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.InternetGateways + var v2 []string + for _, v := range v1 { + v3 := v.InternetGatewayId + if v3 != nil { + v2 = append(v2, *v3) + } } - + v4 := len(v2) + v5 := 0 + v6 := int64(v4) > int64(v5) expectedValue := "true" bv, err := strconv.ParseBool(expectedValue) if err != nil { return false, fmt.Errorf("error parsing boolean from string %w", err) } - value, ok := pathValue.(bool) - if !ok { - return false, fmt.Errorf("waiter comparator expected bool value got %T", pathValue) - } - - if value == bv { + if v6 == bv { return false, nil } } diff --git a/service/ec2/api_op_DescribeKeyPairs.go b/service/ec2/api_op_DescribeKeyPairs.go index bc44cc7ffb0..bde816f809c 100644 --- a/service/ec2/api_op_DescribeKeyPairs.go +++ b/service/ec2/api_op_DescribeKeyPairs.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "strconv" "time" ) @@ -333,22 +332,23 @@ func (w *KeyPairExistsWaiter) WaitForOutput(ctx context.Context, params *Describ func keyPairExistsStateRetryable(ctx context.Context, input *DescribeKeyPairsInput, output *DescribeKeyPairsOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("length(KeyPairs[].KeyName) > `0`", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.KeyPairs + var v2 []string + for _, v := range v1 { + v3 := v.KeyName + if v3 != nil { + v2 = append(v2, *v3) + } } - + v4 := len(v2) + v5 := 0 + v6 := int64(v4) > int64(v5) expectedValue := "true" bv, err := strconv.ParseBool(expectedValue) if err != nil { return false, fmt.Errorf("error parsing boolean from string %w", err) } - value, ok := pathValue.(bool) - if !ok { - return false, fmt.Errorf("waiter comparator expected bool value got %T", pathValue) - } - - if value == bv { + if v6 == bv { return false, nil } } diff --git a/service/ec2/api_op_DescribeNatGateways.go b/service/ec2/api_op_DescribeNatGateways.go index d641696f485..f242b129ed5 100644 --- a/service/ec2/api_op_DescribeNatGateways.go +++ b/service/ec2/api_op_DescribeNatGateways.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -339,29 +338,18 @@ func (w *NatGatewayAvailableWaiter) WaitForOutput(ctx context.Context, params *D func natGatewayAvailableStateRetryable(ctx context.Context, input *DescribeNatGatewaysInput, output *DescribeNatGatewaysOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("NatGateways[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.NatGateways + var v2 []types.NatGatewayState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "available" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.NatGatewayState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.NatGatewayState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -371,74 +359,65 @@ func natGatewayAvailableStateRetryable(ctx context.Context, input *DescribeNatGa } if err == nil { - pathValue, err := jmespath.Search("NatGateways[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.NatGateways + var v2 []types.NatGatewayState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "failed" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.NatGatewayState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.NatGatewayState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("NatGateways[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.NatGateways + var v2 []types.NatGatewayState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleting" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.NatGatewayState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.NatGatewayState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("NatGateways[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.NatGateways + var v2 []types.NatGatewayState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleted" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.NatGatewayState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.NatGatewayState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } @@ -617,29 +596,18 @@ func (w *NatGatewayDeletedWaiter) WaitForOutput(ctx context.Context, params *Des func natGatewayDeletedStateRetryable(ctx context.Context, input *DescribeNatGatewaysInput, output *DescribeNatGatewaysOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("NatGateways[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.NatGateways + var v2 []types.NatGatewayState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleted" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.NatGatewayState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.NatGatewayState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } diff --git a/service/ec2/api_op_DescribeNetworkInterfaces.go b/service/ec2/api_op_DescribeNetworkInterfaces.go index e1fe76cfb7e..c2f57e928a9 100644 --- a/service/ec2/api_op_DescribeNetworkInterfaces.go +++ b/service/ec2/api_op_DescribeNetworkInterfaces.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -435,29 +434,18 @@ func (w *NetworkInterfaceAvailableWaiter) WaitForOutput(ctx context.Context, par func networkInterfaceAvailableStateRetryable(ctx context.Context, input *DescribeNetworkInterfacesInput, output *DescribeNetworkInterfacesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("NetworkInterfaces[].Status", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.NetworkInterfaces + var v2 []types.NetworkInterfaceStatus + for _, v := range v1 { + v3 := v.Status + v2 = append(v2, v3) } - expectedValue := "available" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.NetworkInterfaceStatus) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.NetworkInterfaceStatus value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } diff --git a/service/ec2/api_op_DescribeSecurityGroups.go b/service/ec2/api_op_DescribeSecurityGroups.go index 38e78e1464b..eb1d92a4a1a 100644 --- a/service/ec2/api_op_DescribeSecurityGroups.go +++ b/service/ec2/api_op_DescribeSecurityGroups.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "strconv" "time" ) @@ -405,22 +404,23 @@ func (w *SecurityGroupExistsWaiter) WaitForOutput(ctx context.Context, params *D func securityGroupExistsStateRetryable(ctx context.Context, input *DescribeSecurityGroupsInput, output *DescribeSecurityGroupsOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("length(SecurityGroups[].GroupId) > `0`", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.SecurityGroups + var v2 []string + for _, v := range v1 { + v3 := v.GroupId + if v3 != nil { + v2 = append(v2, *v3) + } } - + v4 := len(v2) + v5 := 0 + v6 := int64(v4) > int64(v5) expectedValue := "true" bv, err := strconv.ParseBool(expectedValue) if err != nil { return false, fmt.Errorf("error parsing boolean from string %w", err) } - value, ok := pathValue.(bool) - if !ok { - return false, fmt.Errorf("waiter comparator expected bool value got %T", pathValue) - } - - if value == bv { + if v6 == bv { return false, nil } } diff --git a/service/ec2/api_op_DescribeSnapshots.go b/service/ec2/api_op_DescribeSnapshots.go index 890ed6cee74..afd7dd64cc9 100644 --- a/service/ec2/api_op_DescribeSnapshots.go +++ b/service/ec2/api_op_DescribeSnapshots.go @@ -11,7 +11,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -411,29 +410,18 @@ func (w *SnapshotCompletedWaiter) WaitForOutput(ctx context.Context, params *Des func snapshotCompletedStateRetryable(ctx context.Context, input *DescribeSnapshotsInput, output *DescribeSnapshotsOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Snapshots[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Snapshots + var v2 []types.SnapshotState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "completed" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.SnapshotState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.SnapshotState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -443,26 +431,23 @@ func snapshotCompletedStateRetryable(ctx context.Context, input *DescribeSnapsho } if err == nil { - pathValue, err := jmespath.Search("Snapshots[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Snapshots + var v2 []types.SnapshotState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "error" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.SnapshotState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.SnapshotState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } diff --git a/service/ec2/api_op_DescribeSpotInstanceRequests.go b/service/ec2/api_op_DescribeSpotInstanceRequests.go index 69b672acdde..8d28e0e300b 100644 --- a/service/ec2/api_op_DescribeSpotInstanceRequests.go +++ b/service/ec2/api_op_DescribeSpotInstanceRequests.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -445,29 +444,21 @@ func (w *SpotInstanceRequestFulfilledWaiter) WaitForOutput(ctx context.Context, func spotInstanceRequestFulfilledStateRetryable(ctx context.Context, input *DescribeSpotInstanceRequestsInput, output *DescribeSpotInstanceRequestsOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("SpotInstanceRequests[].Status.Code", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.SpotInstanceRequests + var v2 []string + for _, v := range v1 { + v3 := v.Status + v4 := v3.Code + if v4 != nil { + v2 = append(v2, *v4) + } } - expectedValue := "fulfilled" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) - } - - if string(*value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -477,29 +468,21 @@ func spotInstanceRequestFulfilledStateRetryable(ctx context.Context, input *Desc } if err == nil { - pathValue, err := jmespath.Search("SpotInstanceRequests[].Status.Code", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.SpotInstanceRequests + var v2 []string + for _, v := range v1 { + v3 := v.Status + v4 := v3.Code + if v4 != nil { + v2 = append(v2, *v4) + } } - expectedValue := "request-canceled-and-instance-running" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) - } - - if string(*value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -509,98 +492,98 @@ func spotInstanceRequestFulfilledStateRetryable(ctx context.Context, input *Desc } if err == nil { - pathValue, err := jmespath.Search("SpotInstanceRequests[].Status.Code", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.SpotInstanceRequests + var v2 []string + for _, v := range v1 { + v3 := v.Status + v4 := v3.Code + if v4 != nil { + v2 = append(v2, *v4) + } } - expectedValue := "schedule-expired" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(*value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("SpotInstanceRequests[].Status.Code", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.SpotInstanceRequests + var v2 []string + for _, v := range v1 { + v3 := v.Status + v4 := v3.Code + if v4 != nil { + v2 = append(v2, *v4) + } } - expectedValue := "canceled-before-fulfillment" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(*value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("SpotInstanceRequests[].Status.Code", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.SpotInstanceRequests + var v2 []string + for _, v := range v1 { + v3 := v.Status + v4 := v3.Code + if v4 != nil { + v2 = append(v2, *v4) + } } - expectedValue := "bad-parameters" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(*value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("SpotInstanceRequests[].Status.Code", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.SpotInstanceRequests + var v2 []string + for _, v := range v1 { + v3 := v.Status + v4 := v3.Code + if v4 != nil { + v2 = append(v2, *v4) + } } - expectedValue := "system-error" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(*value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } diff --git a/service/ec2/api_op_DescribeStoreImageTasks.go b/service/ec2/api_op_DescribeStoreImageTasks.go index e7c2547b224..48ee9b80364 100644 --- a/service/ec2/api_op_DescribeStoreImageTasks.go +++ b/service/ec2/api_op_DescribeStoreImageTasks.go @@ -11,7 +11,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -347,29 +346,20 @@ func (w *StoreImageTaskCompleteWaiter) WaitForOutput(ctx context.Context, params func storeImageTaskCompleteStateRetryable(ctx context.Context, input *DescribeStoreImageTasksInput, output *DescribeStoreImageTasksOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("StoreImageTaskResults[].StoreTaskState", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.StoreImageTaskResults + var v2 []string + for _, v := range v1 { + v3 := v.StoreTaskState + if v3 != nil { + v2 = append(v2, *v3) + } } - expectedValue := "Completed" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) - } - - if string(*value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -379,50 +369,48 @@ func storeImageTaskCompleteStateRetryable(ctx context.Context, input *DescribeSt } if err == nil { - pathValue, err := jmespath.Search("StoreImageTaskResults[].StoreTaskState", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.StoreImageTaskResults + var v2 []string + for _, v := range v1 { + v3 := v.StoreTaskState + if v3 != nil { + v2 = append(v2, *v3) + } } - expectedValue := "Failed" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(*value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("StoreImageTaskResults[].StoreTaskState", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.StoreImageTaskResults + var v2 []string + for _, v := range v1 { + v3 := v.StoreTaskState + if v3 != nil { + v2 = append(v2, *v3) + } } - expectedValue := "InProgress" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(*string) - if !ok { - return false, fmt.Errorf("waiter comparator expected *string value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(*value) == expectedValue { - return true, nil - } + if match { + return true, nil } } diff --git a/service/ec2/api_op_DescribeSubnets.go b/service/ec2/api_op_DescribeSubnets.go index 978ecb97799..c263e34a1b8 100644 --- a/service/ec2/api_op_DescribeSubnets.go +++ b/service/ec2/api_op_DescribeSubnets.go @@ -11,7 +11,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -404,29 +403,18 @@ func (w *SubnetAvailableWaiter) WaitForOutput(ctx context.Context, params *Descr func subnetAvailableStateRetryable(ctx context.Context, input *DescribeSubnetsInput, output *DescribeSubnetsOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Subnets[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Subnets + var v2 []types.SubnetState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "available" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.SubnetState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.SubnetState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } diff --git a/service/ec2/api_op_DescribeVolumes.go b/service/ec2/api_op_DescribeVolumes.go index 5d2a8de6069..0105b915e56 100644 --- a/service/ec2/api_op_DescribeVolumes.go +++ b/service/ec2/api_op_DescribeVolumes.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -378,29 +377,18 @@ func (w *VolumeAvailableWaiter) WaitForOutput(ctx context.Context, params *Descr func volumeAvailableStateRetryable(ctx context.Context, input *DescribeVolumesInput, output *DescribeVolumesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Volumes[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Volumes + var v2 []types.VolumeState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "available" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.VolumeState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VolumeState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -410,26 +398,23 @@ func volumeAvailableStateRetryable(ctx context.Context, input *DescribeVolumesIn } if err == nil { - pathValue, err := jmespath.Search("Volumes[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Volumes + var v2 []types.VolumeState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleted" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.VolumeState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VolumeState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } @@ -596,29 +581,18 @@ func (w *VolumeDeletedWaiter) WaitForOutput(ctx context.Context, params *Describ func volumeDeletedStateRetryable(ctx context.Context, input *DescribeVolumesInput, output *DescribeVolumesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Volumes[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Volumes + var v2 []types.VolumeState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleted" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.VolumeState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VolumeState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -801,29 +775,18 @@ func (w *VolumeInUseWaiter) WaitForOutput(ctx context.Context, params *DescribeV func volumeInUseStateRetryable(ctx context.Context, input *DescribeVolumesInput, output *DescribeVolumesOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Volumes[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Volumes + var v2 []types.VolumeState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "in-use" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.VolumeState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VolumeState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -833,26 +796,23 @@ func volumeInUseStateRetryable(ctx context.Context, input *DescribeVolumesInput, } if err == nil { - pathValue, err := jmespath.Search("Volumes[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Volumes + var v2 []types.VolumeState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleted" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.VolumeState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VolumeState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } diff --git a/service/ec2/api_op_DescribeVpcPeeringConnections.go b/service/ec2/api_op_DescribeVpcPeeringConnections.go index 3f9ad7b0379..84769d3f621 100644 --- a/service/ec2/api_op_DescribeVpcPeeringConnections.go +++ b/service/ec2/api_op_DescribeVpcPeeringConnections.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -360,29 +359,19 @@ func (w *VpcPeeringConnectionDeletedWaiter) WaitForOutput(ctx context.Context, p func vpcPeeringConnectionDeletedStateRetryable(ctx context.Context, input *DescribeVpcPeeringConnectionsInput, output *DescribeVpcPeeringConnectionsOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("VpcPeeringConnections[].Status.Code", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.VpcPeeringConnections + var v2 []types.VpcPeeringConnectionStateReasonCode + for _, v := range v1 { + v3 := v.Status + v4 := v3.Code + v2 = append(v2, v4) } - expectedValue := "deleted" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.VpcPeeringConnectionStateReasonCode) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VpcPeeringConnectionStateReasonCode value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } diff --git a/service/ec2/api_op_DescribeVpcs.go b/service/ec2/api_op_DescribeVpcs.go index e8145f4f92e..ea0573932be 100644 --- a/service/ec2/api_op_DescribeVpcs.go +++ b/service/ec2/api_op_DescribeVpcs.go @@ -13,7 +13,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -362,29 +361,18 @@ func (w *VpcAvailableWaiter) WaitForOutput(ctx context.Context, params *Describe func vpcAvailableStateRetryable(ctx context.Context, input *DescribeVpcsInput, output *DescribeVpcsOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("Vpcs[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.Vpcs + var v2 []types.VpcState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "available" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.VpcState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VpcState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } diff --git a/service/ec2/api_op_DescribeVpnConnections.go b/service/ec2/api_op_DescribeVpnConnections.go index f6c4f0bde07..c549d35ad0f 100644 --- a/service/ec2/api_op_DescribeVpnConnections.go +++ b/service/ec2/api_op_DescribeVpnConnections.go @@ -11,7 +11,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "time" ) @@ -349,29 +348,18 @@ func (w *VpnConnectionAvailableWaiter) WaitForOutput(ctx context.Context, params func vpnConnectionAvailableStateRetryable(ctx context.Context, input *DescribeVpnConnectionsInput, output *DescribeVpnConnectionsOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("VpnConnections[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.VpnConnections + var v2 []types.VpnState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "available" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.VpnState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VpnState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -381,50 +369,44 @@ func vpnConnectionAvailableStateRetryable(ctx context.Context, input *DescribeVp } if err == nil { - pathValue, err := jmespath.Search("VpnConnections[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.VpnConnections + var v2 []types.VpnState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleting" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.VpnState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VpnState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } if err == nil { - pathValue, err := jmespath.Search("VpnConnections[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.VpnConnections + var v2 []types.VpnState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleted" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.VpnState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VpnState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } @@ -593,29 +575,18 @@ func (w *VpnConnectionDeletedWaiter) WaitForOutput(ctx context.Context, params * func vpnConnectionDeletedStateRetryable(ctx context.Context, input *DescribeVpnConnectionsInput, output *DescribeVpnConnectionsOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("VpnConnections[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.VpnConnections + var v2 []types.VpnState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "deleted" - var match = true - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - if len(listOfValues) == 0 { - match = false - } - for _, v := range listOfValues { - value, ok := v.(types.VpnState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VpnState value, got %T", pathValue) - } - - if string(value) != expectedValue { + match := len(v2) > 0 + for _, v := range v2 { + if string(v) != expectedValue { match = false + break } } @@ -625,26 +596,23 @@ func vpnConnectionDeletedStateRetryable(ctx context.Context, input *DescribeVpnC } if err == nil { - pathValue, err := jmespath.Search("VpnConnections[].State", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.VpnConnections + var v2 []types.VpnState + for _, v := range v1 { + v3 := v.State + v2 = append(v2, v3) } - expectedValue := "pending" - listOfValues, ok := pathValue.([]interface{}) - if !ok { - return false, fmt.Errorf("waiter comparator expected list got %T", pathValue) - } - - for _, v := range listOfValues { - value, ok := v.(types.VpnState) - if !ok { - return false, fmt.Errorf("waiter comparator expected types.VpnState value, got %T", pathValue) + var match bool + for _, v := range v2 { + if string(v) == expectedValue { + match = true + break } + } - if string(value) == expectedValue { - return false, fmt.Errorf("waiter state transitioned to Failure") - } + if match { + return false, fmt.Errorf("waiter state transitioned to Failure") } } diff --git a/service/ec2/api_op_GetPasswordData.go b/service/ec2/api_op_GetPasswordData.go index 2a4f65eeae4..1fc6dc060db 100644 --- a/service/ec2/api_op_GetPasswordData.go +++ b/service/ec2/api_op_GetPasswordData.go @@ -10,7 +10,6 @@ import ( smithytime "github.com/aws/smithy-go/time" smithyhttp "github.com/aws/smithy-go/transport/http" smithywaiter "github.com/aws/smithy-go/waiter" - jmespath "github.com/jmespath/go-jmespath" "strconv" "time" ) @@ -331,22 +330,20 @@ func (w *PasswordDataAvailableWaiter) WaitForOutput(ctx context.Context, params func passwordDataAvailableStateRetryable(ctx context.Context, input *GetPasswordDataInput, output *GetPasswordDataOutput, err error) (bool, error) { if err == nil { - pathValue, err := jmespath.Search("length(PasswordData) > `0`", output) - if err != nil { - return false, fmt.Errorf("error evaluating waiter state: %w", err) + v1 := output.PasswordData + var _v1 string + if v1 != nil { + _v1 = *v1 } - + v2 := len(_v1) + v3 := 0 + v4 := int64(v2) > int64(v3) expectedValue := "true" bv, err := strconv.ParseBool(expectedValue) if err != nil { return false, fmt.Errorf("error parsing boolean from string %w", err) } - value, ok := pathValue.(bool) - if !ok { - return false, fmt.Errorf("waiter comparator expected bool value got %T", pathValue) - } - - if value == bv { + if v4 == bv { return false, nil } } diff --git a/service/ec2/generated.json b/service/ec2/generated.json index 98b5eda155d..3387f7ef072 100644 --- a/service/ec2/generated.json +++ b/service/ec2/generated.json @@ -5,8 +5,7 @@ "github.com/aws/aws-sdk-go-v2/internal/endpoints/v2": "v2.0.0-00010101000000-000000000000", "github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding": "v1.0.5", "github.com/aws/aws-sdk-go-v2/service/internal/presigned-url": "v1.0.7", - "github.com/aws/smithy-go": "v1.4.0", - "github.com/jmespath/go-jmespath": "v0.4.0" + "github.com/aws/smithy-go": "v1.4.0" }, "files": [ "api_client.go", diff --git a/service/ec2/go.mod b/service/ec2/go.mod index 61f01059369..7bc499c845e 100644 --- a/service/ec2/go.mod +++ b/service/ec2/go.mod @@ -9,7 +9,6 @@ require ( github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.3 github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.17 github.com/aws/smithy-go v1.20.3 - github.com/jmespath/go-jmespath v0.4.0 ) replace github.com/aws/aws-sdk-go-v2 => ../../ diff --git a/service/ec2/go.sum b/service/ec2/go.sum index eb1604bcdab..07970476de0 100644 --- a/service/ec2/go.sum +++ b/service/ec2/go.sum @@ -1,14 +1,2 @@ github.com/aws/smithy-go v1.20.3 h1:ryHwveWzPV5BIof6fyDvor6V3iUL7nTfiTKXHiW05nE= github.com/aws/smithy-go v1.20.3/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= -github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=