From 14db660ce4df8765d3e34d8d18af7ec8517d00a5 Mon Sep 17 00:00:00 2001 From: Erik Kristensen Date: Thu, 26 Sep 2024 16:12:34 -0600 Subject: [PATCH] feat(gamelift-mm-config): add properties and pagination --- resources/gamelift-mm-config.go | 44 +++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/resources/gamelift-mm-config.go b/resources/gamelift-mm-config.go index 8d792dbb..ff41001b 100644 --- a/resources/gamelift-mm-config.go +++ b/resources/gamelift-mm-config.go @@ -2,11 +2,13 @@ package resources import ( "context" + "time" "github.com/aws/aws-sdk-go/service/gamelift" "github.com/ekristen/libnuke/pkg/registry" "github.com/ekristen/libnuke/pkg/resource" + "github.com/ekristen/libnuke/pkg/types" "github.com/ekristen/aws-nuke/v3/pkg/nuke" ) @@ -25,29 +27,41 @@ type GameLiftMatchmakingConfigurationLister struct{} func (l *GameLiftMatchmakingConfigurationLister) List(_ context.Context, o interface{}) ([]resource.Resource, error) { opts := o.(*nuke.ListerOpts) + var resources []resource.Resource svc := gamelift.New(opts.Session) - resp, err := svc.DescribeMatchmakingConfigurations(&gamelift.DescribeMatchmakingConfigurationsInput{}) - if err != nil { - return nil, err - } + params := &gamelift.DescribeMatchmakingConfigurationsInput{} - configs := make([]resource.Resource, 0) - for _, config := range resp.Configurations { - q := &GameLiftMatchmakingConfiguration{ - svc: svc, - Name: config.Name, + for { + resp, err := svc.DescribeMatchmakingConfigurations(params) + if err != nil { + return nil, err } - configs = append(configs, q) + + for _, config := range resp.Configurations { + q := &GameLiftMatchmakingConfiguration{ + svc: svc, + Name: config.Name, + CreationTime: config.CreationTime, + } + resources = append(resources, q) + } + + if resp.NextToken == nil { + break + } + + params.NextToken = resp.NextToken } - return configs, nil + return resources, nil } type GameLiftMatchmakingConfiguration struct { - svc *gamelift.GameLift - Name *string + svc *gamelift.GameLift + Name *string + CreationTime *time.Time } func (r *GameLiftMatchmakingConfiguration) Remove(_ context.Context) error { @@ -63,6 +77,10 @@ func (r *GameLiftMatchmakingConfiguration) Remove(_ context.Context) error { return nil } +func (r *GameLiftMatchmakingConfiguration) Properties() types.Properties { + return types.NewPropertiesFromStruct(r) +} + func (r *GameLiftMatchmakingConfiguration) String() string { return *r.Name }