Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(env): make openebs service account configurable #28

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}