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

Specify multiple configmaps/secrets for a function #1055

Closed
life1347 opened this issue Jan 14, 2019 · 0 comments

Comments

@life1347
Copy link
Member

commented Jan 14, 2019

Looks like we only need to change replace StringFlag with StringSliceFlag

fission/fission/main.go

Lines 114 to 115 in 37f37c0

fnSecretFlag := cli.StringFlag{Name: "secret", Usage: "function access to secret, should be present in the same namespace as the function"}
fnCfgMapFlag := cli.StringFlag{Name: "configmap", Usage: "function access to configmap, should be present in the same namespace as the function"}

and change following place then we are able to support accepting multiple configmaps/secrets for a function

fission/fission/function.go

Lines 277 to 312 in 37f37c0

var secrets []fission.SecretReference
var cfgmaps []fission.ConfigMapReference
if len(secretName) > 0 {
// check the referenced secret is in the same ns as the function, if not give a warning.
_, err := client.SecretGet(&metav1.ObjectMeta{
Namespace: fnNamespace,
Name: secretName,
})
if k8serrors.IsNotFound(err) {
log.Warn(fmt.Sprintf("Secret %s not found in Namespace: %s. Secret needs to be present in the same namespace as function", secretName, fnNamespace))
}
newSecret := fission.SecretReference{
Name: secretName,
Namespace: fnNamespace,
}
secrets = []fission.SecretReference{newSecret}
}
if len(cfgMapName) > 0 {
// check the referenced cfgmap is in the same ns as the function, if not give a warning.
_, err := client.ConfigMapGet(&metav1.ObjectMeta{
Namespace: fnNamespace,
Name: cfgMapName,
})
if k8serrors.IsNotFound(err) {
log.Warn(fmt.Sprintf("ConfigMap %s not found in Namespace: %s. ConfigMap needs to be present in the same namespace as function", cfgMapName, fnNamespace))
}
newCfgMap := fission.ConfigMapReference{
Name: cfgMapName,
Namespace: fnNamespace,
}
cfgmaps = []fission.ConfigMapReference{newCfgMap}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.