Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit 933f40f

Browse files
author
Christopher Hein
authored
Merge pull request #20 from christopherhein/feature/5-add-s3bucket
Adding S3Bucket Resource
2 parents cef01e0 + e68c63a commit 933f40f

File tree

17 files changed

+1212
-1
lines changed

17 files changed

+1212
-1
lines changed

examples/s3bucket.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: operator.aws/v1alpha1
2+
kind: S3Bucket
3+
metadata:
4+
name: chrishein-test-bucket-104
5+
spec:
6+
bucketName: chrishein-test-bucket-name-104
7+
versioning: false
8+
logging:
9+
enabled: false
10+
prefix: "archive"

models/s3bucket.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
apiVersion: operator.aws/v1alpha1
2+
kind: ModelDefinition
3+
metadata:
4+
name: S3BucketResource
5+
spec:
6+
kind: S3Bucket
7+
type: Spec # can be Spec or Data
8+
queue: true
9+
useCloudFormation: true
10+
resource:
11+
name: s3bucket
12+
plural: s3buckets
13+
shortNames:
14+
- name: s3
15+
- name: bucket
16+
- name: buckets
17+
body:
18+
schema:
19+
type: object
20+
properties:
21+
- key: bucketName
22+
type: string
23+
description: |
24+
BucketName is the name of the S3 Bucket to be created.
25+
structKey: BucketName
26+
templateKey: BucketName
27+
- key: versioning
28+
type: bool
29+
description: |
30+
Versioning specifies if whether you want to automatically enable versioning of the content in the bucket.
31+
structKey: Versioning
32+
templateKey: EnableVersioning
33+
- key: logging
34+
type: object
35+
description: |
36+
Logging defines the options for managing the S3 logging options.
37+
structKey: Logging
38+
templateKey: logging
39+
properties:
40+
- key: enabled
41+
type: bool
42+
description: |
43+
Logging Enabled configures the S3 Bucket to log to a separate Logging bucket
44+
structKey: Enabled
45+
templateKey: EnableLogging
46+
- key: prefix
47+
type: string
48+
description: |
49+
Logging prefix to attach to all logs in the bucket.
50+
structKey: Prefix
51+
templateKey: LoggingPrefix
52+
output:
53+
schema:
54+
type: object
55+
properties:
56+
- key: bucketName
57+
type: string
58+
description: |
59+
BucketName is the output bucketname incase it changed
60+
structKey: BucketName
61+
templateKey: BucketName
62+
- key: bucketARN
63+
type: string
64+
description: |
65+
BucketARN is the full Amazon ARN for the bucket created
66+
structKey: BucketARN
67+
templateKey: BucketArn
68+
# additionalResources:
69+
# services:
70+
# - type: ExternalName
71+
# externalName: "{{.Obj.Spec.BucketName}}.s3-{{.Config.Region}}.amazonaws.com"
72+
# ports:
73+
# - protocol: tcp
74+
# port: 443
75+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package v1alpha1
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
"k8s.io/apimachinery/pkg/runtime"
6+
)
7+
8+
// +genclient
9+
// +genclient:noStatus
10+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
11+
12+
// S3Bucket defines the base resource
13+
type S3Bucket struct {
14+
metav1.TypeMeta `json:",inline"`
15+
metav1.ObjectMeta `json:"metadata"`
16+
Spec S3BucketSpec `json:"spec"`
17+
Status S3BucketStatus `json:"status"`
18+
Output S3BucketOutput `json:"output"`
19+
AdditionalResources S3BucketAdditionalResources `json:"additionalResources"`
20+
}
21+
// S3BucketLogging defines the Logging resource for S3Bucket
22+
type S3BucketLogging struct {
23+
Enabled bool `json:"enabled"`
24+
Prefix string `json:"prefix"`
25+
}
26+
27+
// S3BucketSpec defines the Spec resource for S3Bucket
28+
type S3BucketSpec struct {
29+
CloudFormationTemplateName string `json:"cloudFormationTemplateName"`
30+
CloudFormationTemplateNamespace string `json:"cloudFormationTemplateNamespace"`
31+
BucketName string `json:"bucketName"`
32+
Versioning bool `json:"versioning"`
33+
Logging S3BucketLogging `json:"logging"`
34+
}
35+
36+
37+
// S3BucketOutput defines the output resource for S3Bucket
38+
type S3BucketOutput struct {
39+
BucketName string `json:"bucketName"`
40+
BucketARN string `json:"bucketARN"`
41+
}
42+
43+
// S3BucketStatus holds the status of the Cloudformation template
44+
type S3BucketStatus struct {
45+
ResourceStatus string `json:"resourceStatus"`
46+
ResourceStatusReason string `json:"resourceStatusReason"`
47+
StackID string `json:"stackID"`
48+
}
49+
50+
// S3BucketAdditionalResources holds the additional resources
51+
type S3BucketAdditionalResources struct {
52+
}
53+
54+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
55+
56+
// S3BucketList defines the list attribute for the S3Bucket type
57+
type S3BucketList struct {
58+
metav1.TypeMeta `json:",inline"`
59+
metav1.ListMeta `json:"metadata"`
60+
Items []S3Bucket `json:"items"`
61+
}
62+
63+
func init() {
64+
localSchemeBuilder.Register(addS3BucketTypes)
65+
}
66+
67+
func addS3BucketTypes(scheme *runtime.Scheme) error {
68+
scheme.AddKnownTypes(SchemeGroupVersion,
69+
&S3Bucket{},
70+
&S3BucketList{},
71+
)
72+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
73+
return nil
74+
}

pkg/apis/operator.aws/v1alpha1/zz_generated.deepcopy.go

Lines changed: 144 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client/clientset/versioned/typed/operator.aws/v1alpha1/fake/fake_operator.aws_client.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)