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

Commit

Permalink
Merge pull request #20 from christopherhein/feature/5-add-s3bucket
Browse files Browse the repository at this point in the history
Adding S3Bucket Resource
  • Loading branch information
Christopher Hein committed Aug 2, 2018
2 parents cef01e0 + e68c63a commit 933f40f
Show file tree
Hide file tree
Showing 17 changed files with 1,212 additions and 1 deletion.
10 changes: 10 additions & 0 deletions examples/s3bucket.yaml
@@ -0,0 +1,10 @@
apiVersion: operator.aws/v1alpha1
kind: S3Bucket
metadata:
name: chrishein-test-bucket-104
spec:
bucketName: chrishein-test-bucket-name-104
versioning: false
logging:
enabled: false
prefix: "archive"
75 changes: 75 additions & 0 deletions models/s3bucket.yaml
@@ -0,0 +1,75 @@
apiVersion: operator.aws/v1alpha1
kind: ModelDefinition
metadata:
name: S3BucketResource
spec:
kind: S3Bucket
type: Spec # can be Spec or Data
queue: true
useCloudFormation: true
resource:
name: s3bucket
plural: s3buckets
shortNames:
- name: s3
- name: bucket
- name: buckets
body:
schema:
type: object
properties:
- key: bucketName
type: string
description: |
BucketName is the name of the S3 Bucket to be created.
structKey: BucketName
templateKey: BucketName
- key: versioning
type: bool
description: |
Versioning specifies if whether you want to automatically enable versioning of the content in the bucket.
structKey: Versioning
templateKey: EnableVersioning
- key: logging
type: object
description: |
Logging defines the options for managing the S3 logging options.
structKey: Logging
templateKey: logging
properties:
- key: enabled
type: bool
description: |
Logging Enabled configures the S3 Bucket to log to a separate Logging bucket
structKey: Enabled
templateKey: EnableLogging
- key: prefix
type: string
description: |
Logging prefix to attach to all logs in the bucket.
structKey: Prefix
templateKey: LoggingPrefix
output:
schema:
type: object
properties:
- key: bucketName
type: string
description: |
BucketName is the output bucketname incase it changed
structKey: BucketName
templateKey: BucketName
- key: bucketARN
type: string
description: |
BucketARN is the full Amazon ARN for the bucket created
structKey: BucketARN
templateKey: BucketArn
# additionalResources:
# services:
# - type: ExternalName
# externalName: "{{.Obj.Spec.BucketName}}.s3-{{.Config.Region}}.amazonaws.com"
# ports:
# - protocol: tcp
# port: 443

74 changes: 74 additions & 0 deletions pkg/apis/operator.aws/v1alpha1/s3bucket.go
@@ -0,0 +1,74 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)

// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// S3Bucket defines the base resource
type S3Bucket struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec S3BucketSpec `json:"spec"`
Status S3BucketStatus `json:"status"`
Output S3BucketOutput `json:"output"`
AdditionalResources S3BucketAdditionalResources `json:"additionalResources"`
}
// S3BucketLogging defines the Logging resource for S3Bucket
type S3BucketLogging struct {
Enabled bool `json:"enabled"`
Prefix string `json:"prefix"`
}

// S3BucketSpec defines the Spec resource for S3Bucket
type S3BucketSpec struct {
CloudFormationTemplateName string `json:"cloudFormationTemplateName"`
CloudFormationTemplateNamespace string `json:"cloudFormationTemplateNamespace"`
BucketName string `json:"bucketName"`
Versioning bool `json:"versioning"`
Logging S3BucketLogging `json:"logging"`
}


// S3BucketOutput defines the output resource for S3Bucket
type S3BucketOutput struct {
BucketName string `json:"bucketName"`
BucketARN string `json:"bucketARN"`
}

// S3BucketStatus holds the status of the Cloudformation template
type S3BucketStatus struct {
ResourceStatus string `json:"resourceStatus"`
ResourceStatusReason string `json:"resourceStatusReason"`
StackID string `json:"stackID"`
}

// S3BucketAdditionalResources holds the additional resources
type S3BucketAdditionalResources struct {
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// S3BucketList defines the list attribute for the S3Bucket type
type S3BucketList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []S3Bucket `json:"items"`
}

func init() {
localSchemeBuilder.Register(addS3BucketTypes)
}

func addS3BucketTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&S3Bucket{},
&S3BucketList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
144 changes: 144 additions & 0 deletions pkg/apis/operator.aws/v1alpha1/zz_generated.deepcopy.go

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

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

0 comments on commit 933f40f

Please sign in to comment.