diff --git a/services/s3/apis/v1alpha1/bucket.go b/services/s3/apis/v1alpha1/bucket.go index a6d18d3d38..292b7c2784 100644 --- a/services/s3/apis/v1alpha1/bucket.go +++ b/services/s3/apis/v1alpha1/bucket.go @@ -49,6 +49,7 @@ type BucketStatus struct { // Bucket is the Schema for the Buckets API // +kubebuilder:object:root=true +// +kubebuilder:subresource:status type Bucket struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/services/s3/config/controller/deployment.yaml b/services/s3/config/controller/deployment.yaml index 5fc034f038..2baa7b332b 100644 --- a/services/s3/config/controller/deployment.yaml +++ b/services/s3/config/controller/deployment.yaml @@ -27,11 +27,11 @@ spec: - ./bin/controller args: - --aws-account-id - - "${AWS_ACCOUNT_ID}" + - "$(AWS_ACCOUNT_ID)" - --aws-region - - "${AWS_REGION}" + - "$(AWS_REGION)" - --enable-development-logging - - "${ACK_ENABLE_DEVELOPMENT_LOGGING}" + - "$(ACK_ENABLE_DEVELOPMENT_LOGGING)" image: controller:latest name: controller resources: diff --git a/services/s3/config/crd/bases/s3.services.k8s.aws_buckets.yaml b/services/s3/config/crd/bases/s3.services.k8s.aws_buckets.yaml index 44c2a1992c..18c7220c31 100644 --- a/services/s3/config/crd/bases/s3.services.k8s.aws_buckets.yaml +++ b/services/s3/config/crd/bases/s3.services.k8s.aws_buckets.yaml @@ -1,10 +1,10 @@ --- -apiVersion: apiextensions.k8s.io/v1beta1 +apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.3.1-0.20200716001835-4a903ddb7005 + controller-gen.kubebuilder.io/version: v0.4.0 creationTimestamp: null name: buckets.s3.services.k8s.aws spec: @@ -15,120 +15,122 @@ spec: plural: buckets singular: bucket scope: Namespaced - validation: - openAPIV3Schema: - description: Bucket is the Schema for the Buckets API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: BucketSpec defines the desired state of Bucket - properties: - acl: - type: string - createBucketConfiguration: - properties: - locationConstraint: - type: string - type: object - grantFullControl: - type: string - grantRead: - type: string - grantReadACP: - type: string - grantWrite: - type: string - grantWriteACP: - type: string - name: - type: string - objectLockEnabledForBucket: - type: boolean - type: object - status: - description: BucketStatus defines the observed state of Bucket - properties: - ackResourceMetadata: - description: All CRs managed by ACK have a common `Status.ACKResourceMetadata` - member that is used to contain resource sync state, account ownership, - constructed ARN for the resource - properties: - arn: - description: ARN is the Amazon Resource Name for the resource. This - is a globally-unique identifier and is set only by the ACK service - controller once the controller has orchestrated the creation of - the resource OR when it has verified that an "adopted" resource - (a resource where the ARN annotation was set by the Kubernetes - user on the CR) exists and matches the supplied CR's Spec field - values. - type: string - ownerAccountID: - description: OwnerAccountID is the AWS Account ID of the account - that owns the backend AWS service API resource. - type: string - required: - - arn - - ownerAccountID - type: object - conditions: - description: All CRS managed by ACK have a common `Status.Conditions` - member that contains a collection of `ackv1alpha1.Condition` objects - that describe the various terminal states of the CR and its backend - AWS service API resource - items: - description: Condition is the common struct used by all CRDs managed - by ACK service controllers to indicate terminal states of the CR - and its backend AWS service API resource + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: Bucket is the Schema for the Buckets API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: BucketSpec defines the desired state of Bucket + properties: + acl: + type: string + createBucketConfiguration: properties: - lastTransitionTime: - description: Last time the condition transitioned from one status - to another. - format: date-time - type: string - message: - description: A human readable message indicating details about - the transition. - type: string - reason: - description: The reason for the condition's last transition. + locationConstraint: type: string - status: - description: Status of the condition, one of True, False, Unknown. + type: object + grantFullControl: + type: string + grantRead: + type: string + grantReadACP: + type: string + grantWrite: + type: string + grantWriteACP: + type: string + name: + type: string + objectLockEnabledForBucket: + type: boolean + type: object + status: + description: BucketStatus defines the observed state of Bucket + properties: + ackResourceMetadata: + description: All CRs managed by ACK have a common `Status.ACKResourceMetadata` + member that is used to contain resource sync state, account ownership, + constructed ARN for the resource + properties: + arn: + description: 'ARN is the Amazon Resource Name for the resource. + This is a globally-unique identifier and is set only by the + ACK service controller once the controller has orchestrated + the creation of the resource OR when it has verified that an + "adopted" resource (a resource where the ARN annotation was + set by the Kubernetes user on the CR) exists and matches the + supplied CR''s Spec field values. TODO(vijat@): Find a better + strategy for resources that do not have ARN in CreateOutputResponse + https://github.com/aws/aws-controllers-k8s/issues/270' type: string - type: - description: Type is the type of the Condition + ownerAccountID: + description: OwnerAccountID is the AWS Account ID of the account + that owns the backend AWS service API resource. type: string required: - - status - - type + - ownerAccountID type: object - type: array - location: - type: string - required: - - ackResourceMetadata - - conditions - type: object - type: object - version: v1alpha1 - versions: - - name: v1alpha1 + conditions: + description: All CRS managed by ACK have a common `Status.Conditions` + member that contains a collection of `ackv1alpha1.Condition` objects + that describe the various terminal states of the CR and its backend + AWS service API resource + items: + description: Condition is the common struct used by all CRDs managed + by ACK service controllers to indicate terminal states of the + CR and its backend AWS service API resource + properties: + lastTransitionTime: + description: Last time the condition transitioned from one status + to another. + format: date-time + type: string + message: + description: A human readable message indicating details about + the transition. + type: string + reason: + description: The reason for the condition's last transition. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: Type is the type of the Condition + type: string + required: + - status + - type + type: object + type: array + location: + type: string + required: + - ackResourceMetadata + - conditions + type: object + type: object served: true storage: true + subresources: + status: {} status: acceptedNames: kind: "" plural: "" - conditions: null - storedVersions: null + conditions: [] + storedVersions: [] diff --git a/services/s3/pkg/resource/bucket/descriptor.go b/services/s3/pkg/resource/bucket/descriptor.go index 2b089d7907..7bad9b1154 100644 --- a/services/s3/pkg/resource/bucket/descriptor.go +++ b/services/s3/pkg/resource/bucket/descriptor.go @@ -98,7 +98,7 @@ func (d *resourceDescriptor) Diff( func (d *resourceDescriptor) UpdateCRStatus( res acktypes.AWSResource, ) (bool, error) { - updated := false + updated := true return updated, nil } diff --git a/services/s3/pkg/resource/bucket/sdk.go b/services/s3/pkg/resource/bucket/sdk.go index aa1b8ae88a..707ffc209f 100644 --- a/services/s3/pkg/resource/bucket/sdk.go +++ b/services/s3/pkg/resource/bucket/sdk.go @@ -115,6 +115,8 @@ func (rm *resourceManager) sdkCreate( ko.Status.Location = resp.Location } + ko.Status.ACKResourceMetadata = &ackv1alpha1.ResourceMetadata{OwnerAccountID: &rm.awsAccountID} + ko.Status.Conditions = []*ackv1alpha1.Condition{} return &resource{ko}, nil }