From ed4c4eae084e4b35f13f6117cc9f2710e3661da2 Mon Sep 17 00:00:00 2001 From: David Fridrich Date: Wed, 10 Jun 2026 07:55:53 +0200 Subject: [PATCH] cmd: apply function context to invoke/logs flag defaults Bring NewInvokeCmd and NewLogsCmd in line with the cfg.Apply(f) idiom already used by deploy and build: fold the current function's state into the global config before registering flags, so function-contextual values become flag defaults. No flag defaults change yet at this point; this prepares for the cluster flag whose default must be the function's pinned cluster. --- cmd/invoke.go | 6 ++++++ cmd/logs.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/cmd/invoke.go b/cmd/invoke.go index 9ff96d37fa..a7c15bd7c8 100644 --- a/cmd/invoke.go +++ b/cmd/invoke.go @@ -118,6 +118,12 @@ EXAMPLES fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err) } + // Function Context + f, _ := fn.NewFunction(effectivePath()) + if f.Initialized() { + cfg = cfg.Apply(f) + } + // Flags cmd.Flags().StringP("format", "f", "", "Format of message to send, 'http' or 'cloudevent(s)'. Default is to choose automatically. ($FUNC_FORMAT)") cmd.Flags().StringP("target", "t", "", "Function instance to invoke. Can be 'local', 'remote' or a URL. Defaults to auto-discovery if not provided. ($FUNC_TARGET)") diff --git a/cmd/logs.go b/cmd/logs.go index 8a0bcb6135..9068a042c9 100644 --- a/cmd/logs.go +++ b/cmd/logs.go @@ -52,6 +52,12 @@ specified with --path. Abstracts away the underlying service name and pod detail fmt.Fprintf(cmd.OutOrStdout(), "error loading config at '%v'. %v\n", config.File(), err) } + // Function Context + f, _ := fn.NewFunction(effectivePath()) + if f.Initialized() { + cfg = cfg.Apply(f) + } + // Flags cmd.Flags().StringP("name", "", "", "Name of the function to get logs from ($FUNC_NAME)") cmd.Flags().StringP("namespace", "n", defaultNamespace(fn.Function{}, false), "The namespace of the function ($FUNC_NAMESPACE)")