diff --git a/Makefile b/Makefile index b45629f..4924f3d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # SHELL is set as bash to use some bashisms. SHELL = bash -BOTTLEROCKET_SDK_VERSION = v0.33.0 +BOTTLEROCKET_SDK_VERSION = v0.37.0 BOTTLEROCKET_SDK_ARCH = x86_64 UPDATER_TARGET_ARCH = amd64 diff --git a/updater/aws.go b/updater/aws.go index 9750d50..3a44250 100644 --- a/updater/aws.go +++ b/updater/aws.go @@ -85,7 +85,7 @@ func (u *updater) listContainerInstances() ([]*string, error) { Cluster: &u.cluster, Status: aws.String(ecs.ContainerInstanceStatusActive), } - if err := u.ecs.ListContainerInstancesPages(input, func(output *ecs.ListContainerInstancesOutput, lastpage bool) bool { + if err := u.ecs.ListContainerInstancesPages(input, func(output *ecs.ListContainerInstancesOutput, _ bool) bool { containerInstances = append(containerInstances, output.ContainerInstanceArns...) return true }); err != nil { @@ -412,9 +412,8 @@ func (u *updater) verifyUpdate(inst instance) (bool, error) { log.Printf("Container instance %q was updated to version %q successfully, however another newer version was recently released;"+ " Instance will be updated to newer version in next iteration.", inst.containerInstanceID, updatedVersion) return true, nil - } else { - log.Printf("Container instance %q updated to version %q", inst.containerInstanceID, updatedVersion) } + log.Printf("Container instance %q updated to version %q", inst.containerInstanceID, updatedVersion) return true, nil } diff --git a/updater/aws_test.go b/updater/aws_test.go index 91196bc..98909df 100644 --- a/updater/aws_test.go +++ b/updater/aws_test.go @@ -78,7 +78,7 @@ func TestFilterAvailableUpdates(t *testing.T) { StandardOutputContent: aws.String(responses[*input.InstanceId]), }, nil }, - SendCommandFn: func(input *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { + SendCommandFn: func(_ *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { sendCommandCalls++ return &ssm.SendCommandOutput{ Command: &ssm.Command{ @@ -87,7 +87,7 @@ func TestFilterAvailableUpdates(t *testing.T) { }, }, nil }, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { m.Lock() commandWaiterCalls++ m.Unlock() @@ -134,11 +134,11 @@ func TestPaginatedFilterAvailableUpdatesSuccess(t *testing.T) { commandWaiterCalls := 0 getCommandInvocationCalls := 0 mockSSM := MockSSM{ - GetCommandInvocationFn: func(input *ssm.GetCommandInvocationInput) (*ssm.GetCommandInvocationOutput, error) { + GetCommandInvocationFn: func(_ *ssm.GetCommandInvocationInput) (*ssm.GetCommandInvocationOutput, error) { getCommandInvocationCalls++ return getOut, nil }, - SendCommandFn: func(input *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { + SendCommandFn: func(_ *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { sendCommandCalls++ return &ssm.SendCommandOutput{ Command: &ssm.Command{ @@ -147,7 +147,7 @@ func TestPaginatedFilterAvailableUpdatesSuccess(t *testing.T) { }, }, nil }, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { m.Lock() commandWaiterCalls++ m.Unlock() @@ -178,7 +178,7 @@ func TestPaginatedFilterAvailableUpdatesAllFail(t *testing.T) { sendCommandCalls := 0 mockSSM := MockSSM{ - SendCommandFn: func(input *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { + SendCommandFn: func(_ *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { sendCommandCalls++ return nil, errors.New("Failed to send document") }, @@ -211,7 +211,7 @@ func TestPaginatedFilterAvailableUpdatesInPageFailures(t *testing.T) { getCommandInvocationCalls := 0 count := 0 mockSSM := MockSSM{ - GetCommandInvocationFn: func(input *ssm.GetCommandInvocationInput) (*ssm.GetCommandInvocationOutput, error) { + GetCommandInvocationFn: func(_ *ssm.GetCommandInvocationInput) (*ssm.GetCommandInvocationOutput, error) { count++ getCommandInvocationCalls++ switch count % 3 { @@ -230,7 +230,7 @@ func TestPaginatedFilterAvailableUpdatesInPageFailures(t *testing.T) { } return nil, nil }, - SendCommandFn: func(input *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { + SendCommandFn: func(_ *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { sendCommandCalls++ return &ssm.SendCommandOutput{ Command: &ssm.Command{ @@ -239,7 +239,7 @@ func TestPaginatedFilterAvailableUpdatesInPageFailures(t *testing.T) { }, }, nil }, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) m.Lock() commandWaiterCalls++ @@ -289,11 +289,11 @@ func TestPaginatedFilterAvailableUpdatesSingleErr(t *testing.T) { getCommandInvocationCalls := 0 callCount := 0 mockSSM := MockSSM{ - GetCommandInvocationFn: func(input *ssm.GetCommandInvocationInput) (*ssm.GetCommandInvocationOutput, error) { + GetCommandInvocationFn: func(_ *ssm.GetCommandInvocationInput) (*ssm.GetCommandInvocationOutput, error) { getCommandInvocationCalls++ return getOut, nil }, - SendCommandFn: func(input *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { + SendCommandFn: func(_ *ssm.SendCommandInput) (*ssm.SendCommandOutput, error) { require.Less(t, callCount, len(pageErrors)) failErr := pageErrors[callCount] callCount++ @@ -305,7 +305,7 @@ func TestPaginatedFilterAvailableUpdatesSingleErr(t *testing.T) { }, }, failErr }, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) m.Lock() commandWaiterCalls++ @@ -391,7 +391,7 @@ func TestSendCommandSuccess(t *testing.T) { assert.Equal(t, aws.StringSlice(instances), input.InstanceIds) return &ssm.SendCommandOutput{Command: &ssm.Command{CommandId: aws.String("command-id")}}, nil }, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) m.Lock() waitInstanceIDs = append(waitInstanceIDs, aws.StringValue(input.InstanceId)) @@ -451,7 +451,7 @@ func TestSendCommandWaitErr(t *testing.T) { Command: &ssm.Command{CommandId: aws.String("command-id")}, }, nil }, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) return waitError }, @@ -486,7 +486,7 @@ func TestSendCommandWaitSuccess(t *testing.T) { failedInstanceIDs := []string{} mockSSM := MockSSM{ SendCommandFn: mockSendCommand, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { if aws.StringValue(input.InstanceId) == commandSuccessInstance { return nil } @@ -512,7 +512,7 @@ func TestSendCommandWaitSuccess(t *testing.T) { waitInstanceIDs := []string{} mockSSM := MockSSM{ SendCommandFn: mockSendCommand, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) m.Lock() waitInstanceIDs = append(waitInstanceIDs, aws.StringValue(input.InstanceId)) @@ -1040,7 +1040,7 @@ func TestDrainInstance(t *testing.T) { mockECS := MockECS{ UpdateContainerInstancesStateFn: mockStateChange, ListTasksFn: mockListTasks, - WaitUntilTasksStoppedWithContextFn: func(ctx aws.Context, input *ecs.DescribeTasksInput, opts ...request.WaiterOption) error { + WaitUntilTasksStoppedWithContextFn: func(_ aws.Context, input *ecs.DescribeTasksInput, _ ...request.WaiterOption) error { assert.Equal(t, []*string{ aws.String("task-arn-1"), }, input.Tasks) @@ -1120,7 +1120,7 @@ func TestDrainInstance(t *testing.T) { mockECS := MockECS{ UpdateContainerInstancesStateFn: mockStateChange, ListTasksFn: mockListTasks, - WaitUntilTasksStoppedWithContextFn: func(ctx aws.Context, input *ecs.DescribeTasksInput, opts ...request.WaiterOption) error { + WaitUntilTasksStoppedWithContextFn: func(_ aws.Context, input *ecs.DescribeTasksInput, _ ...request.WaiterOption) error { assert.Equal(t, []*string{ aws.String("task-arn-1"), }, input.Tasks) @@ -1193,7 +1193,7 @@ func TestUpdateInstance(t *testing.T) { assert.Equal(t, "instance-id", aws.StringValue(input.InstanceId)) return tc.invocationOut, nil }, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) assert.Equal(t, "instance-id", aws.StringValue(input.InstanceId)) return nil @@ -1240,7 +1240,7 @@ func TestUpdateInstanceErr(t *testing.T) { StandardOutputContent: aws.String("{\"update_state\": \"Available\", \"active_partition\": { \"image\": { \"version\": \"0.0.0\"}}}"), }, nil } - mockWaitCommandExecution := func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + mockWaitCommandExecution := func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) assert.Equal(t, "instance-id", aws.StringValue(input.InstanceId)) return nil @@ -1328,7 +1328,7 @@ func TestUpdateInstanceErr(t *testing.T) { waitExecErr := errors.New("failed to wait ssm execution complete") mockSSM := MockSSM{ SendCommandFn: mockSendCommand, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) assert.Equal(t, "instance-id", aws.StringValue(input.InstanceId)) return waitExecErr @@ -1420,7 +1420,7 @@ func TestVerifyUpdate(t *testing.T) { assert.Equal(t, "instance-id", aws.StringValue(input.InstanceId)) return tc.invocationOut, nil }, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) assert.Equal(t, "instance-id", aws.StringValue(input.InstanceId)) return nil @@ -1449,7 +1449,7 @@ func TestVerifyUpdateErr(t *testing.T) { }, }, nil } - mockWaitCommandExecution := func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + mockWaitCommandExecution := func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) assert.Equal(t, "instance-id", aws.StringValue(input.InstanceId)) return nil @@ -1485,7 +1485,7 @@ func TestVerifyUpdateErr(t *testing.T) { waitExecErr := errors.New("failed to wait ssm execution complete") mockSSM := MockSSM{ SendCommandFn: mockSSMCommandOut, - WaitUntilCommandExecutedWithContextFn: func(ctx aws.Context, input *ssm.GetCommandInvocationInput, opts ...request.WaiterOption) error { + WaitUntilCommandExecutedWithContextFn: func(_ aws.Context, input *ssm.GetCommandInvocationInput, _ ...request.WaiterOption) error { assert.Equal(t, "command-id", aws.StringValue(input.CommandId)) assert.Equal(t, "instance-id", aws.StringValue(input.InstanceId)) return waitExecErr @@ -1586,7 +1586,7 @@ func TestActivateInstance(t *testing.T) { for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { mockECS := MockECS{ - UpdateContainerInstancesStateFn: func(input *ecs.UpdateContainerInstancesStateInput) (*ecs.UpdateContainerInstancesStateOutput, error) { + UpdateContainerInstancesStateFn: func(_ *ecs.UpdateContainerInstancesStateInput) (*ecs.UpdateContainerInstancesStateOutput, error) { return tc.stateOut, tc.stateErr }, } @@ -1639,7 +1639,7 @@ func TestAlreadyRunning(t *testing.T) { for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { mockECS := MockECS{ - ListTasksFn: func(input *ecs.ListTasksInput) (*ecs.ListTasksOutput, error) { + ListTasksFn: func(_ *ecs.ListTasksInput) (*ecs.ListTasksOutput, error) { return tc.listOut, tc.listErr }, } diff --git a/updater/go.mod b/updater/go.mod index bd1da8d..29e698d 100644 --- a/updater/go.mod +++ b/updater/go.mod @@ -3,7 +3,7 @@ module github.com/bottlerocket-os/bottlerocket-ecs-updater go 1.19 require ( - github.com/aws/aws-sdk-go v1.44.217 + github.com/aws/aws-sdk-go v1.50.17 github.com/stretchr/testify v1.8.1 ) diff --git a/updater/go.sum b/updater/go.sum index 2ee7b19..39d189e 100644 --- a/updater/go.sum +++ b/updater/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.44.217 h1:FcWC56MRl+k756aH3qeMQTylSdeJ58WN0iFz3fkyRz0= -github.com/aws/aws-sdk-go v1.44.217/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.50.17 h1:KsbzUKDgGNlkDHGvoQDhiJ63a9jtZd+O+/s3pTOr/ns= +github.com/aws/aws-sdk-go v1.50.17/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -7,7 +7,6 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y 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/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 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= @@ -17,29 +16,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=