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

Commit cff7915

Browse files
Adding Code to Support AccountID and Templated Ouputs
**Why:** * Allows ECR to have a url as an output **This change addresses the need by:** * closes #54 Signed-off-by: Christopher Hein <[email protected]>
1 parent 5d4c87e commit cff7915

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

cloudformation/ecrrepository.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ Outputs:
3131
RepositoryName:
3232
Value: !Ref ECRRepository
3333
Description: Name of the topic
34+
RepositoryARN:
35+
Value: !GetAtt ECRRepository.Arn
36+
Description: ARN of the Repository

cmd/aws-operator/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
var (
1616
// cfgFile, kubeConfig, awsRegion all help support passed in flags into the server
17-
cfgFile, kubeconfig, awsRegion, logLevel, logFile, resources, clusterName, bucket string
17+
cfgFile, kubeconfig, awsRegion, logLevel, logFile, resources, clusterName, bucket, accountID string
1818

1919
// rootCmd represents the base command when called without any subcommands
2020
rootCmd = &cobra.Command{
@@ -45,6 +45,7 @@ func init() {
4545
rootCmd.PersistentFlags().StringVarP(&resources, "resources", "", "s3bucket,dynamodb", "Comma delimited list of CRDs to deploy")
4646
rootCmd.PersistentFlags().StringVarP(&clusterName, "cluster-name", "i", "aws-operator", "Cluster name for the Application to run as, used to label the Cloudformation templated to avoid conflict")
4747
rootCmd.PersistentFlags().StringVarP(&bucket, "bucket", "b", "aws-operator", "To configure the operator you need a base bucket to contain the resources")
48+
rootCmd.PersistentFlags().StringVarP(&accountID, "account-id", "a", "", "AWS Account ID, this is used to configure outputs and operate on the proper account.")
4849

4950
viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
5051
viper.BindPFlag("kubeconfig", rootCmd.PersistentFlags().Lookup("kubeconfig"))
@@ -54,6 +55,7 @@ func init() {
5455
viper.BindPFlag("resources", rootCmd.PersistentFlags().Lookup("resources"))
5556
viper.BindPFlag("clustername", rootCmd.PersistentFlags().Lookup("cluster-name"))
5657
viper.BindPFlag("bucket", rootCmd.PersistentFlags().Lookup("bucket"))
58+
viper.BindPFlag("accountid", rootCmd.PersistentFlags().Lookup("account-id"))
5759
}
5860

5961
// initConfig reads in config file and ENV variables if set.
@@ -94,6 +96,7 @@ func getConfig() (*config.Config, error) {
9496
Resources: resourcesList,
9597
ClusterName: clusterName,
9698
Bucket: bucket,
99+
AccountID: accountID,
97100
}
98101

99102
return config, nil

models/ecrrepository.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,16 @@ spec:
5353
the repository name. For more information, see Name Type.
5454
structKey: RepositoryName
5555
templateKey: RepositoryName
56+
- key: repositoryARN
57+
type: string
58+
description: |
59+
ARN for the Amazon ECR Repository
60+
structKey: RepositoryARN
61+
templateKey: RepositoryARN
62+
- key: repositoryURL
63+
type: string
64+
description: |
65+
URL for the Amazon ECR Repository
66+
structKey: RepositoryURL
67+
templatized: true
68+
template: "{{.Config.AccountID}}.dkr.ecr.{{.Config.Region}}.amazonaws.com/{{.Obj.Name}}"

pkg/config/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Config struct {
2121
Resources []string
2222
ClusterName string
2323
Bucket string
24+
AccountID string
2425
}
2526

2627
// LoggingConfig defines the attributes for the logger

0 commit comments

Comments
 (0)