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 #125 from joerocklin/default-namespace
Browse files Browse the repository at this point in the history
Allow the override of the default namespace
  • Loading branch information
Christopher Hein committed Oct 19, 2018
2 parents 20d7d37 + ddc0a30 commit 51ad4a7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
12 changes: 8 additions & 4 deletions cmd/aws-service-operator/main.go
Expand Up @@ -17,6 +17,7 @@ import (
var (
// cfgFile, masterURL, kubeConfig, awsRegion all help support passed in flags into the server
cfgFile, masterURL, kubeconfig, awsRegion, logLevel, logFile, resources, clusterName, bucket, accountID string
defaultNamespace string

// rootCmd represents the base command when called without any subcommands
rootCmd = &cobra.Command{
Expand Down Expand Up @@ -50,6 +51,7 @@ func init() {
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.")
rootCmd.PersistentFlags().StringVarP(&defaultNamespace, "default-namespace", "", "default", "The default namespace in which to look for CloudFormation templates")

viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
viper.BindPFlag("masterurl", rootCmd.PersistentFlags().Lookup("master-url"))
Expand All @@ -61,6 +63,7 @@ func init() {
viper.BindPFlag("clustername", rootCmd.PersistentFlags().Lookup("cluster-name"))
viper.BindPFlag("bucket", rootCmd.PersistentFlags().Lookup("bucket"))
viper.BindPFlag("accountid", rootCmd.PersistentFlags().Lookup("account-id"))
viper.BindPFlag("defaultnamespace", rootCmd.PersistentFlags().Lookup("default-namespace"))
}

// initConfig reads in config file and ENV variables if set.
Expand Down Expand Up @@ -118,10 +121,11 @@ func getConfig() (c *config.Config, err error) {
FullTimestamps: true,
DisableTimestamps: false,
},
Resources: resourcesMap,
ClusterName: clusterName,
Bucket: bucket,
AccountID: accountID,
Resources: resourcesMap,
ClusterName: clusterName,
Bucket: bucket,
AccountID: accountID,
DefaultNamespace: defaultNamespace,
}

err = c.CreateContext(masterURL, kubeconfig)
Expand Down
30 changes: 16 additions & 14 deletions pkg/config/types.go
Expand Up @@ -2,6 +2,7 @@ package config

import (
"fmt"

"github.com/aws/aws-sdk-go/aws/session"
awsclient "github.com/awslabs/aws-service-operator/pkg/client/clientset/versioned/typed/service-operator.aws/v1alpha1"
"github.com/sirupsen/logrus"
Expand All @@ -13,20 +14,21 @@ import (

// Config defines the configuration for the operator
type Config struct {
Region string
Kubeconfig string
MasterURL string
AWSSession *session.Session
AWSClientset awsclient.ServiceoperatorV1alpha1Interface
KubeClientset kubernetes.Interface
RESTConfig *rest.Config
LoggingConfig *LoggingConfig
Logger *logrus.Entry
Resources map[string]bool
ClusterName string
Bucket string
AccountID string
Recorder record.EventRecorder
Region string
Kubeconfig string
MasterURL string
AWSSession *session.Session
AWSClientset awsclient.ServiceoperatorV1alpha1Interface
KubeClientset kubernetes.Interface
RESTConfig *rest.Config
LoggingConfig *LoggingConfig
Logger *logrus.Entry
Resources map[string]bool
ClusterName string
Bucket string
AccountID string
DefaultNamespace string
Recorder record.EventRecorder
}

// LoggingConfig defines the attributes for the logger
Expand Down
2 changes: 1 addition & 1 deletion pkg/helpers/helpers.go
Expand Up @@ -95,7 +95,7 @@ func GetCloudFormationTemplate(config *config.Config, rType string, name string,
cName = rType
}
if namespace == "" {
cNamespace = "default"
cNamespace = config.DefaultNamespace
}

resource, err := clientSet.CloudFormationTemplates(cNamespace).Get(cName, metav1.GetOptions{})
Expand Down

0 comments on commit 51ad4a7

Please sign in to comment.