diff --git a/cmd/build.go b/cmd/build.go index 1617305ff..491799767 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -303,17 +303,13 @@ func (c buildConfig) Prompt() (buildConfig, error) { // value and will always use the value from the config (flag or env variable). // This is not strictly correct and will be fixed when Global Config: Function // Context is available (PR#1416) - hasFunc, err := fn.IsFunctionInitialized(c.Path) - if err != nil { - return c, err - } - if !hasFunc { - return c, fmt.Errorf("no function has been initialized in the current directory. Please initialize a function by running either:\n- func init --language \n- func create --language ") - } f, err := fn.NewFunction(c.Path) if err != nil { return c, err } + if !f.Initialized() { + return c, fmt.Errorf("no function has been initialized in %q. Please initialize a function by running:\n- func init --language ", c.Path) + } if (f.Registry == "" && c.Registry == "" && c.Image == "") || c.Confirm { fmt.Println("A registry for function images is required. For example, 'docker.io/tigerteam'.") err := survey.AskOne( diff --git a/pkg/functions/client.go b/pkg/functions/client.go index a3b696d5a..254273944 100644 --- a/pkg/functions/client.go +++ b/pkg/functions/client.go @@ -1276,9 +1276,6 @@ func isEffectivelyEmpty(path string) (bool, error) { } return true, nil } -func IsFunctionInitialized(path string) (bool, error) { - return hasInitializedFunction(path) -} // returns true if the given path contains an initialized function. func hasInitializedFunction(path string) (bool, error) {