Skip to content

Commit

Permalink
Refactor func init check in build.go
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunsunny3 committed Nov 15, 2024
1 parent c2267b9 commit d9a9159
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
10 changes: 3 additions & 7 deletions cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <your language>\n- func create <function name> --language <your_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 <your 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(
Expand Down
3 changes: 0 additions & 3 deletions pkg/functions/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d9a9159

Please sign in to comment.