Skip to content

test: add test asserting partition is not empty #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ack_generate_info:
build_date: "2025-07-22T21:50:37Z"
build_hash: b2dc0f44e0b08f041de14c3944a5cc005ba97c8f
go_version: go1.24.5
version: v0.50.0
build_date: "2025-07-30T23:41:55Z"
build_hash: 300e3ab143b837dda0dc00794c21b0edc1530c58
go_version: go1.24.4
version: v0.50.0-2-g300e3ab-dirty
api_directory_checksum: 2108338a86d704419192e545c0bfb433bab8c836
api_version: v1alpha1
aws_sdk_go_version: v1.32.6
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/s3.services.k8s.aws_buckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1219,12 +1219,17 @@ spec:
OwnerAccountID is the AWS Account ID of the account that owns the
backend AWS service API resource.
type: string
partition:
description: Partition is the AWS partition in which the resource
exists or will exist
type: string
region:
description: Region is the AWS region in which the resource exists
or will exist.
type: string
required:
- ownerAccountID
- partition
- region
type: object
conditions:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/aws-controllers-k8s/runtime => github.com/michaelhtm/ack-runtime v0.49.1-0.20250730215011-f7ca6ab251ea
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
github.com/aws-controllers-k8s/runtime v0.50.0 h1:6BXOBdnb+xw6uSMEDeALhTKc4veZR9NfXIsl5QJKZ8k=
github.com/aws-controllers-k8s/runtime v0.50.0/go.mod h1:OkUJN+Ds799JLYZsMJrO2vDJ4snxUeHK2MgrQHbU+Qc=
github.com/aws/aws-sdk-go v1.49.0 h1:g9BkW1fo9GqKfwg2+zCD+TW/D36Ux+vtfJ8guF4AYmY=
github.com/aws/aws-sdk-go v1.49.0/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go-v2 v1.34.0 h1:9iyL+cjifckRGEVpRKZP3eIxVlL06Qk1Tk13vreaVQU=
Expand Down Expand Up @@ -117,6 +115,8 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/michaelhtm/ack-runtime v0.49.1-0.20250730215011-f7ca6ab251ea h1:hyMdoRxWLIS1ner6atIh2BeaKMxnRQhTXdzs2WDZBjs=
github.com/michaelhtm/ack-runtime v0.49.1-0.20250730215011-f7ca6ab251ea/go.mod h1:OkUJN+Ds799JLYZsMJrO2vDJ4snxUeHK2MgrQHbU+Qc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
Expand Down
5 changes: 5 additions & 0 deletions helm/crds/s3.services.k8s.aws_buckets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1219,12 +1219,17 @@ spec:
OwnerAccountID is the AWS Account ID of the account that owns the
backend AWS service API resource.
type: string
partition:
description: Partition is the AWS partition in which the resource
exists or will exist
type: string
region:
description: Region is the AWS region in which the resource exists
or will exist.
type: string
required:
- ownerAccountID
- partition
- region
type: object
conditions:
Expand Down
14 changes: 0 additions & 14 deletions pkg/resource/bucket/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package bucket

import (
"context"
"fmt"
"strings"

"github.com/pkg/errors"
Expand All @@ -29,19 +28,6 @@ import (
svcsdktypes "github.com/aws/aws-sdk-go-v2/service/s3/types"
)

// bucketARN returns the ARN of the S3 bucket with the given name.
func bucketARN(bucketName string) string {
// TODO(a-hilaly): I know there could be other partitions, but I'm
// not sure how to determine at this level of abstraction. Probably
// something the SDK/runtime should handle. For now, we'll just use
// the `aws` partition.
//
// NOTE(a-hilaly): Other parts of ACK also use this default partition
// e.g the generated function `ARNFromName` also uses `aws` as the
// default partition.
return fmt.Sprintf("arn:aws:s3:::%s", bucketName)
}

var (
DefaultAccelerationStatus = svcsdktypes.BucketAccelerateStatusSuspended
DefaultRequestPayer = svcsdktypes.PayerBucketOwner
Expand Down
9 changes: 9 additions & 0 deletions pkg/resource/bucket/identifiers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion pkg/resource/bucket/manager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 27 additions & 13 deletions pkg/resource/bucket/manager_factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pkg/resource/bucket/sdk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
}

// Set bucket ARN in the output
bucketARN := ackv1alpha1.AWSResourceName(bucketARN(*ko.Spec.Name))
bucketARN := ackv1alpha1.AWSResourceName(rm.ARNFromName(*ko.Spec.Name))
ko.Status.ACKResourceMetadata.ARN = &bucketARN
2 changes: 1 addition & 1 deletion test/e2e/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@a49300708a1a5586fec36fd28a2494d9cb2288ab
acktest @ git+https://github.com/michaelhtm/ack-test-infra.git@38295c88b5b47c2c7cedd98ef2fc2f505f11551a
8 changes: 4 additions & 4 deletions test/e2e/tests/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from acktest.resources import random_suffix_name
from acktest.k8s import resource as k8s
from acktest.aws.identity import get_region
from acktest.aws.identity import get_region, get_account_id, get_partition
from acktest import adoption as adoption
from acktest import tags as tags
from e2e import service_marker, CRD_GROUP, CRD_VERSION, load_s3_resource
Expand Down Expand Up @@ -116,9 +116,9 @@ def basic_bucket(s3_client) -> Generator[Bucket, None, None]:
assert k8s.get_resource_exists(bucket.ref)

# assert bucket ARN is present in status
# hardcoding partition for now as the test infra is local
bucket_k8s = bucket.resource_data = k8s.get_resource(bucket.ref)
assert "arn:aws:s3:::" + bucket.resource_name == bucket_k8s["status"]["ackResourceMetadata"]["arn"]

assert "arn:"+ get_partition() +":s3:" + get_region() + ":" + get_account_id() + ":" + bucket.resource_name == bucket_k8s["status"]["ackResourceMetadata"]["arn"]
exists = bucket_exists(s3_client, bucket)
assert exists
except:
Expand Down Expand Up @@ -344,4 +344,4 @@ def _update_assert_website(self, bucket: Bucket, s3_resource):
latest = website

assert desired["errorDocument"]["key"] == latest.error_document["Key"]
assert desired["indexDocument"]["suffix"] == latest.index_document["Suffix"]
assert desired["indexDocument"]["suffix"] == latest.index_document["Suffix"]