From 9a97afc10c5d9ddc394190f2cb7a4c7ff6b42c85 Mon Sep 17 00:00:00 2001 From: Oscar Arbelaez Date: Fri, 13 Jun 2025 19:40:54 +0100 Subject: [PATCH 1/4] Use WithDefaultRegion instead of looking up the env var ourselves --- main.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index c35d4dd..b5c68c8 100644 --- a/main.go +++ b/main.go @@ -57,16 +57,8 @@ func main() { return errors.New("cannot see into the future just yet") } - region := cmd.String("region") - if region == "" { - region = os.Getenv("AWS_REGION") - } - - if region == "" { - return errors.New("cannot determine AWS region, checked the --region flag and the AWS_REGION environment variable") - } - - cfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(region)) + defaultRegion := cmd.String("region") + cfg, err := config.LoadDefaultConfig(ctx, config.WithDefaultRegion(defaultRegion)) if err != nil { return fmt.Errorf("unable to load SDK config, %v", err) } From e98f6016ebd9b0f7b74d5dd862572bd75a55c815 Mon Sep 17 00:00:00 2001 From: Oscar Arbelaez Date: Fri, 13 Jun 2025 19:47:05 +0100 Subject: [PATCH 2/4] Add target option --- main.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index b5c68c8..4b39f48 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,10 @@ import ( "gopkg.in/yaml.v3" ) +const ( + defaultTarget = 60.0 +) + func main() { defaultDuration, _ := time.ParseDuration("336h") @@ -42,6 +46,12 @@ func main() { Aliases: []string{"r"}, Usage: "AWS `REGION` to use", }, + &cli.FloatFlag{ + Name: "target", + Aliases: []string{"g"}, + Value: defaultTarget, + Usage: "Target resource utilization percentage", + }, }, Action: func(ctx context.Context, cmd *cli.Command) error { @@ -90,7 +100,8 @@ func main() { return fmt.Errorf("failed to get allocation: %w", err) } - newAllocation := allocation.Fix(usage, &models.Usage{CPU: 90, Memory: 90}) + target := cmd.Float("target") + newAllocation := allocation.Fix(usage, &models.Usage{CPU: target, Memory: target}) bytes, err := yaml.Marshal(newAllocation) if err != nil { From 2afd46ce26ef275edb87dcc11206e5e174910207 Mon Sep 17 00:00:00 2001 From: Oscar Arbelaez Date: Fri, 13 Jun 2025 19:48:40 +0100 Subject: [PATCH 3/4] Fix typos --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 4b39f48..1f34072 100644 --- a/main.go +++ b/main.go @@ -44,7 +44,7 @@ func main() { &cli.StringFlag{ Name: "region", Aliases: []string{"r"}, - Usage: "AWS `REGION` to use", + Usage: "AWS region to use", }, &cli.FloatFlag{ Name: "target", @@ -74,8 +74,8 @@ func main() { } awsCloudwatchClient := cloudwatch.NewFromConfig(cfg) - cloutwatchClient := clients.NewCloudWatchClient(awsCloudwatchClient) - usageService := services.NewUsageService(cloutwatchClient) + cloudwatchClient := clients.NewCloudWatchClient(awsCloudwatchClient) + usageService := services.NewUsageService(cloudwatchClient) awsEcsClient := ecs.NewFromConfig(cfg) ecsClient := clients.NewECSClient(awsEcsClient) From eadfc4aea4a832ff13cf8f653c8398b6ee2d2f59 Mon Sep 17 00:00:00 2001 From: Oscar Arbelaez Date: Fri, 13 Jun 2025 19:51:23 +0100 Subject: [PATCH 4/4] Bump the version --- .github/workflows/ship-version.yml | 4 ++-- main.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ship-version.yml b/.github/workflows/ship-version.yml index 43631a0..7cf7cde 100644 --- a/.github/workflows/ship-version.yml +++ b/.github/workflows/ship-version.yml @@ -28,8 +28,8 @@ jobs: platforms: linux/amd64,linux/arm64 tags: | nextroll/rightsizer:v3 - nextroll/rightsizer:v3.0 - nextroll/rightsizer:v3.0.0 + nextroll/rightsizer:v3.1 + nextroll/rightsizer:v3.1.0 - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/main.go b/main.go index 1f34072..20e8f2c 100644 --- a/main.go +++ b/main.go @@ -29,7 +29,7 @@ func main() { app := &cli.Command{ Name: "rigthsizer", Usage: "Right size your AWS ECS services.", - Version: "3.0.0", + Version: "3.1.0", HideHelpCommand: true, ArgsUsage: " ", UseShortOptionHandling: true,