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

Commit b4e9c44

Browse files
Adding Support For Creating ECR Repos
**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 <[email protected]>
1 parent e6bad3f commit b4e9c44

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

cloudformation/ecrrepository.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
AWSTemplateFormatVersion: 2010-09-09
2+
Description: 'AWS Service Broker - Amazon SNS (qs-1nt0fs93c)'
3+
Parameters:
4+
Namespace:
5+
Description: >-
6+
This is the namespace for the Kubernetes object.
7+
Type: String
8+
ResourceVersion:
9+
Type: String
10+
Description: >-
11+
This is the resource version for the Kubernetes object.
12+
ResourceName:
13+
Description: >-
14+
This is the resource name for the Kubernetes object
15+
Type: String
16+
ClusterName:
17+
Description: >-
18+
This is the cluster name for the operator
19+
Type: String
20+
RepositoryName:
21+
Type: String
22+
Description: >-
23+
What should the ECR Repository be named
24+
Resources:
25+
ECRRepository:
26+
Type: AWS::ECR::Repository
27+
Properties:
28+
RepositoryName: !Ref RepositoryName
29+
30+
Outputs:
31+
RepositoryName:
32+
Value: !Ref ECRRepository
33+
Description: Name of the topic

examples/ecrrepository.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: operator.aws/v1alpha1
2+
kind: ECRRepository
3+
metadata:
4+
name: aws-operator

models/ecrrepository.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
apiVersion: operator.aws/v1alpha1
2+
kind: ModelDefinition
3+
metadata:
4+
name: ECRRepositoryResource
5+
spec:
6+
kind: ECRRepository
7+
type: Spec # can be Spec or Data
8+
queue: true
9+
useCloudFormation: true
10+
resource:
11+
name: ecrrepository
12+
plural: ecrrepositories
13+
shortNames:
14+
- name: ecr
15+
- name: repository
16+
body:
17+
schema:
18+
type: object
19+
properties:
20+
- key: repositoryName
21+
type: resourceName
22+
description: |
23+
A name for the image repository. If you don't specify a name, AWS
24+
CloudFormation generates a unique physical ID and uses that ID for
25+
the repository name. For more information, see Name Type.
26+
structKey: RepositoryName
27+
templateKey: RepositoryName
28+
# - key: lifecyclePolicy
29+
# type: string
30+
# description: |
31+
# A lifecycle policy for the repository.
32+
# structKey: LifecyclePolicy
33+
# templateKey: LifecyclePolicy
34+
# - key: repositoryPolicy
35+
# type: string
36+
# description: |
37+
# A policy that controls who has access to the repository and which
38+
# actions they can perform on it. For more information, see Amazon ECR
39+
# Repository Policies in the Amazon Elastic Container Registry User
40+
# Guide.
41+
# structKey: repositoryPolicy
42+
# templateKey: repositoryPolicy
43+
44+
output:
45+
schema:
46+
type: object
47+
properties:
48+
- key: repositoryName
49+
type: string
50+
description: |
51+
A name for the image repository. If you don't specify a name, AWS
52+
CloudFormation generates a unique physical ID and uses that ID for
53+
the repository name. For more information, see Name Type.
54+
structKey: RepositoryName
55+
templateKey: RepositoryName

pkg/server/server.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/christopherhein/aws-operator/pkg/config"
1212
"github.com/christopherhein/aws-operator/pkg/operator/cloudformationtemplate"
1313
"github.com/christopherhein/aws-operator/pkg/operator/dynamodb"
14+
"github.com/christopherhein/aws-operator/pkg/operator/ecrrepository"
1415
"github.com/christopherhein/aws-operator/pkg/operator/s3bucket"
1516
"github.com/christopherhein/aws-operator/pkg/operator/snstopic"
1617
"github.com/christopherhein/aws-operator/pkg/operator/sqsqueue"
@@ -50,6 +51,7 @@ func (c *Server) Run(stopChan chan struct{}) {
5051
dynamodb.Resource,
5152
sqsqueue.Resource,
5253
snstopic.Resource,
54+
ecrrepository.Resource,
5355
}
5456
err = opkit.CreateCustomResources(*context, resources)
5557
if err != nil {
@@ -94,8 +96,12 @@ func (c *Server) Run(stopChan chan struct{}) {
9496
sqscontroller := sqsqueue.NewController(config, context, awsClientset)
9597
sqscontroller.StartWatch(v1.NamespaceAll, stopChan)
9698

99+
ecrcontroller := ecrrepository.NewController(config, context, awsClientset)
100+
ecrcontroller.StartWatch(v1.NamespaceAll, stopChan)
101+
97102
snscontroller := snstopic.NewController(config, context, awsClientset)
98103
snscontroller.StartWatch(v1.NamespaceAll, stopChan)
104+
99105
}
100106

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

0 commit comments

Comments
 (0)