Functions have access to secrets/configmaps specified by the user (#399)

This commit solves part of the issue #52 , functions are able to access secrets/configmaps specified by the user. For now, CLI only accept one secret/configmap. For advanced users, it will be able to use YAML to declare multiple secrets/configmaps in later changes.
This commit is contained in:
prithviramesh
2018-02-05 17:49:26 +08:00
committed by Ta-Ching Chen
parent 4cf195768e
commit 1eb0453ce4
14 changed files with 411 additions and 31 deletions
+12 -3
View File
@@ -20,9 +20,12 @@ import (
// Usage: fetcher <shared volume path>
func main() {
flag.Usage = fetcherUsage
specializeOnStart := flag.Bool("specialize-on-startup", false, "Flag to activate specialize process at pod starup")
fetchPayload := flag.String("fetch-request", "", "JSON Payload for fetch request")
loadPayload := flag.String("load-request", "", "JSON payload for Load request")
specializeOnStart := flag.Bool("specialize-on-startup", false, "Flag to activate specialize process at pod starup")
secretDir := flag.String("secret-dir", "", "Path to shared secrets directory")
configDir := flag.String("cfgmap-dir", "", "Path to shared configmap directory")
flag.Parse()
if flag.NArg() == 0 {
flag.Usage()
@@ -39,7 +42,7 @@ func main() {
}
}
fetcher := fetcher.MakeFetcher(dir)
fetcher := fetcher.MakeFetcher(dir, *secretDir, *configDir)
if *specializeOnStart {
specializePod(fetcher, fetchPayload, loadPayload)
@@ -55,7 +58,7 @@ func main() {
}
func fetcherUsage() {
fmt.Printf("Usage: fetcher [-specialize-on-startup] [-fetch-request <json>] [-load-request <json>] <shared volume path> \n")
fmt.Printf("Usage: fetcher [-specialize-on-startup] [-fetch-request <json>] [-load-request <json>] [-secret-dir <string>] [-cfgmap-dir <string>] <shared volume path> \n")
}
func specializePod(f *fetcher.Fetcher, fetchPayload *string, loadPayload *string) {
@@ -70,6 +73,12 @@ func specializePod(f *fetcher.Fetcher, fetchPayload *string, loadPayload *string
log.Fatalf("Error fetching: %v", err)
}
_, err = f.FetchSecretsAndCfgMaps(fetchReq.Secrets, fetchReq.ConfigMaps)
if err != nil {
log.Fatalf("Error fetching secerts/configmaps: %v", err)
return
}
// Specialize the pod
envVersion, err := strconv.Atoi(os.Getenv("ENV_VERSION"))