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

Commit

Permalink
Adding Code to Support AccountID and Templated Ouputs
Browse files Browse the repository at this point in the history
**Why:**

* Allows ECR to have a url as an output

**This change addresses the need by:**

* closes #54

Signed-off-by: Christopher Hein <me@christopherhein.com>
  • Loading branch information
christopherhein committed Aug 25, 2018
1 parent 5d4c87e commit cff7915
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cloudformation/ecrrepository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ Outputs:
RepositoryName:
Value: !Ref ECRRepository
Description: Name of the topic
RepositoryARN:
Value: !GetAtt ECRRepository.Arn
Description: ARN of the Repository
5 changes: 4 additions & 1 deletion cmd/aws-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

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

// rootCmd represents the base command when called without any subcommands
rootCmd = &cobra.Command{
Expand Down Expand Up @@ -45,6 +45,7 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&resources, "resources", "", "s3bucket,dynamodb", "Comma delimited list of CRDs to deploy")
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")
rootCmd.PersistentFlags().StringVarP(&bucket, "bucket", "b", "aws-operator", "To configure the operator you need a base bucket to contain the resources")
rootCmd.PersistentFlags().StringVarP(&accountID, "account-id", "a", "", "AWS Account ID, this is used to configure outputs and operate on the proper account.")

viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
viper.BindPFlag("kubeconfig", rootCmd.PersistentFlags().Lookup("kubeconfig"))
Expand All @@ -54,6 +55,7 @@ func init() {
viper.BindPFlag("resources", rootCmd.PersistentFlags().Lookup("resources"))
viper.BindPFlag("clustername", rootCmd.PersistentFlags().Lookup("cluster-name"))
viper.BindPFlag("bucket", rootCmd.PersistentFlags().Lookup("bucket"))
viper.BindPFlag("accountid", rootCmd.PersistentFlags().Lookup("account-id"))
}

// initConfig reads in config file and ENV variables if set.
Expand Down Expand Up @@ -94,6 +96,7 @@ func getConfig() (*config.Config, error) {
Resources: resourcesList,
ClusterName: clusterName,
Bucket: bucket,
AccountID: accountID,
}

return config, nil
Expand Down
13 changes: 13 additions & 0 deletions models/ecrrepository.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,16 @@ spec:
the repository name. For more information, see Name Type.
structKey: RepositoryName
templateKey: RepositoryName
- key: repositoryARN
type: string
description: |
ARN for the Amazon ECR Repository
structKey: RepositoryARN
templateKey: RepositoryARN
- key: repositoryURL
type: string
description: |
URL for the Amazon ECR Repository
structKey: RepositoryURL
templatized: true
template: "{{.Config.AccountID}}.dkr.ecr.{{.Config.Region}}.amazonaws.com/{{.Obj.Name}}"
1 change: 1 addition & 0 deletions pkg/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Config struct {
Resources []string
ClusterName string
Bucket string
AccountID string
}

// LoggingConfig defines the attributes for the logger
Expand Down

0 comments on commit cff7915

Please sign in to comment.