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

Commit

Permalink
Adding Support For Creating ECR Repos
Browse files Browse the repository at this point in the history
**Why:**

* Allows a team to provision an ECR Repo via a CRD

**This change addresses the need by:**

* closes #45

Signed-off-by: Christopher Hein <me@christopherhein.com>
  • Loading branch information
christopherhein committed Aug 25, 2018
1 parent e6bad3f commit b4e9c44
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cloudformation/ecrrepository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
AWSTemplateFormatVersion: 2010-09-09
Description: 'AWS Service Broker - Amazon SNS (qs-1nt0fs93c)'
Parameters:
Namespace:
Description: >-
This is the namespace for the Kubernetes object.
Type: String
ResourceVersion:
Type: String
Description: >-
This is the resource version for the Kubernetes object.
ResourceName:
Description: >-
This is the resource name for the Kubernetes object
Type: String
ClusterName:
Description: >-
This is the cluster name for the operator
Type: String
RepositoryName:
Type: String
Description: >-
What should the ECR Repository be named
Resources:
ECRRepository:
Type: AWS::ECR::Repository
Properties:
RepositoryName: !Ref RepositoryName

Outputs:
RepositoryName:
Value: !Ref ECRRepository
Description: Name of the topic
4 changes: 4 additions & 0 deletions examples/ecrrepository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: operator.aws/v1alpha1
kind: ECRRepository
metadata:
name: aws-operator
55 changes: 55 additions & 0 deletions models/ecrrepository.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
apiVersion: operator.aws/v1alpha1
kind: ModelDefinition
metadata:
name: ECRRepositoryResource
spec:
kind: ECRRepository
type: Spec # can be Spec or Data
queue: true
useCloudFormation: true
resource:
name: ecrrepository
plural: ecrrepositories
shortNames:
- name: ecr
- name: repository
body:
schema:
type: object
properties:
- key: repositoryName
type: resourceName
description: |
A name for the image repository. If you don't specify a name, AWS
CloudFormation generates a unique physical ID and uses that ID for
the repository name. For more information, see Name Type.
structKey: RepositoryName
templateKey: RepositoryName
# - key: lifecyclePolicy
# type: string
# description: |
# A lifecycle policy for the repository.
# structKey: LifecyclePolicy
# templateKey: LifecyclePolicy
# - key: repositoryPolicy
# type: string
# description: |
# A policy that controls who has access to the repository and which
# actions they can perform on it. For more information, see Amazon ECR
# Repository Policies in the Amazon Elastic Container Registry User
# Guide.
# structKey: repositoryPolicy
# templateKey: repositoryPolicy

output:
schema:
type: object
properties:
- key: repositoryName
type: string
description: |
A name for the image repository. If you don't specify a name, AWS
CloudFormation generates a unique physical ID and uses that ID for
the repository name. For more information, see Name Type.
structKey: RepositoryName
templateKey: RepositoryName
6 changes: 6 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/christopherhein/aws-operator/pkg/config"
"github.com/christopherhein/aws-operator/pkg/operator/cloudformationtemplate"
"github.com/christopherhein/aws-operator/pkg/operator/dynamodb"
"github.com/christopherhein/aws-operator/pkg/operator/ecrrepository"
"github.com/christopherhein/aws-operator/pkg/operator/s3bucket"
"github.com/christopherhein/aws-operator/pkg/operator/snstopic"
"github.com/christopherhein/aws-operator/pkg/operator/sqsqueue"
Expand Down Expand Up @@ -50,6 +51,7 @@ func (c *Server) Run(stopChan chan struct{}) {
dynamodb.Resource,
sqsqueue.Resource,
snstopic.Resource,
ecrrepository.Resource,
}
err = opkit.CreateCustomResources(*context, resources)
if err != nil {
Expand Down Expand Up @@ -94,8 +96,12 @@ func (c *Server) Run(stopChan chan struct{}) {
sqscontroller := sqsqueue.NewController(config, context, awsClientset)
sqscontroller.StartWatch(v1.NamespaceAll, stopChan)

ecrcontroller := ecrrepository.NewController(config, context, awsClientset)
ecrcontroller.StartWatch(v1.NamespaceAll, stopChan)

snscontroller := snstopic.NewController(config, context, awsClientset)
snscontroller.StartWatch(v1.NamespaceAll, stopChan)

}

func getClientConfig(kubeconfig string) (*rest.Config, error) {
Expand Down

0 comments on commit b4e9c44

Please sign in to comment.