Skip to content

Commit

Permalink
fix s3 paymentConfiguration preventing bucket from being ready (#29)
Browse files Browse the repository at this point in the history
Signed-off-by: smcavallo <smcavallo@hotmail.com>

Co-authored-by: smcavallo <smcavallo@hotmail.com>
  • Loading branch information
2 people authored and tangenti committed Jan 19, 2022
1 parent 422dbd0 commit d0eacd6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/s3/bucket/requestPaymentConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (in *RequestPaymentConfigurationClient) Observe(ctx context.Context, bucket
// If the payer configuration is not set, do not check
return Updated, nil
}
external, err := in.client.GetBucketRequestPayment(ctx, &awss3.GetBucketRequestPaymentInput{Bucket: awsclient.String(meta.GetExternalName(bucket))})
external, err := in.client.GetBucketRequestPaymentRequest(&awss3.GetBucketRequestPaymentInput{Bucket: awsclient.String(meta.GetExternalName(bucket))}).Send(ctx)
if err != nil {
return NeedsUpdate, awsclient.Wrap(err, paymentGetFailed)
}
Expand Down
22 changes: 20 additions & 2 deletions pkg/controller/s3/bucket/requestPaymentConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,30 @@ func TestRequestPaymentObserve(t *testing.T) {
err: nil,
},
},
"UpdateNeededPayer": {
args: args{
b: s3Testing.Bucket(s3Testing.WithPayerConfig(generateRequestPaymentConfig())),
cl: NewRequestPaymentConfigurationClient(fake.MockBucketClient{
MockGetBucketRequestPaymentRequest: func(input *s3.GetBucketRequestPaymentInput) s3.GetBucketRequestPaymentRequest {
return s3.GetBucketRequestPaymentRequest{
Request: s3Testing.CreateRequest(nil, &s3.GetBucketRequestPaymentOutput{Payer: s3.PayerBucketOwner}),
}
},
}),
},
want: want{
status: NeedsUpdate,
err: nil,
},
},
"NoUpdateExists": {
args: args{
b: s3testing.Bucket(s3testing.WithPayerConfig(generateRequestPaymentConfig())),
cl: NewRequestPaymentConfigurationClient(fake.MockBucketClient{
MockGetBucketRequestPayment: func(ctx context.Context, input *s3.GetBucketRequestPaymentInput, opts []func(*s3.Options)) (*s3.GetBucketRequestPaymentOutput, error) {
return &s3.GetBucketRequestPaymentOutput{Payer: s3types.PayerRequester}, nil
MockGetBucketRequestPaymentRequest: func(input *s3.GetBucketRequestPaymentInput) s3.GetBucketRequestPaymentRequest {
return s3.GetBucketRequestPaymentRequest{
Request: s3Testing.CreateRequest(nil, &s3.GetBucketRequestPaymentOutput{Payer: s3.PayerRequester}),
}
},
}),
},
Expand Down

0 comments on commit d0eacd6

Please sign in to comment.