Skip to content

Commit

Permalink
chore(env): make openebs service account configurable (#28)
Browse files Browse the repository at this point in the history
defaults to service account `openebs-maya-operator` in case
not provided.

Signed-off-by: prateekpandey14 <[email protected]>
  • Loading branch information
prateekpandey14 authored Mar 26, 2020
1 parent 2d2469b commit 2ee96e0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/util/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ const (
//
// This environment variable is set via kubernetes downward API
Namespace = "NAMESPACE"

// DefaultOpenEBSServiceAccount name of the default openebs service accout with
// required permissions
DefaultOpenEBSServiceAccount = "openebs-maya-operator"

// OpenEBSServiceAccount is the environment variable to get operator service
// account name
//
// This environment variable is set via kubernetes downward API in cvc and
// cspc operators deployments
OpenEBSServiceAccount = "OPENEBS_SERVICEACCOUNT_NAME"
)

// LookupOrFalse looks up an environment variable and returns a string "false"
Expand Down Expand Up @@ -76,3 +87,13 @@ func GetOpenebsBaseDirPath() string {
func GetNamespace() string {
return GetEnv(OpenEBSNamespace)
}

// GetServiceAccountName gets the name of OPENEBS_SERVICEACCOUNT_NAME env value which is set by the
// downward API of cvc and cspc operator deployments
func GetServiceAccountName() string {
name, present := os.LookupEnv(OpenEBSServiceAccount)
if !present {
name = DefaultOpenEBSServiceAccount
}
return name
}

0 comments on commit 2ee96e0

Please sign in to comment.