From 474636799afc4f18e95d094a93d6b5f083a6e4a0 Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Tue, 17 Oct 2023 15:47:35 +0100 Subject: [PATCH] Enable name override for --from-store Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- commands/generate.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/commands/generate.go b/commands/generate.go index e71a3867..f97c3bed 100644 --- a/commands/generate.go +++ b/commands/generate.go @@ -31,6 +31,7 @@ const ( var ( api string + name string functionNamespace string crdFunctionNamespace string fromStore string @@ -41,6 +42,7 @@ var ( func init() { generateCmd.Flags().StringVar(&fromStore, "from-store", "", "generate using a store image") + generateCmd.Flags().StringVar(&name, "name", "", "for use with --from-store, override the name for the Function CR") generateCmd.Flags().StringVar(&api, "api", defaultAPIVersion, "CRD API version e.g openfaas.com/v1, serving.knative.dev/v1") generateCmd.Flags().StringVarP(&crdFunctionNamespace, "namespace", "n", "openfaas-fn", "Kubernetes namespace for functions") @@ -147,8 +149,13 @@ func runGenerate(cmd *cobra.Command, args []string) error { } } - services.Functions[item.Name] = stack.Function{ - Name: item.Name, + fullName := item.Name + if len(name) > 0 { + fullName = name + } + + services.Functions[fullName] = stack.Function{ + Name: fullName, Image: item.Images[desiredArch], Labels: &item.Labels, Annotations: &allAnnotations,