mirror of https://github.com/knative/func.git
fix: only use flag value as default or if altered (#1223)
This commit is contained in:
parent
2ee2c61b8b
commit
4e5e9927b2
17
cmd/build.go
17
cmd/build.go
|
|
@ -87,6 +87,13 @@ func runBuild(cmd *cobra.Command, _ []string, newClient ClientFactory) (err erro
|
||||||
|
|
||||||
// Load the Function at path, and if it is initialized, update it with
|
// Load the Function at path, and if it is initialized, update it with
|
||||||
// pertinent values from the config.
|
// pertinent values from the config.
|
||||||
|
//
|
||||||
|
// NOTE: the checks for .Changed and altered conditionals for defaults will
|
||||||
|
// be removed when Global Config is integreated, because the config object
|
||||||
|
// will at that time contain the final value for the attribute, taking into
|
||||||
|
// account whether or not the value was altered via flags or env variables.
|
||||||
|
// This condition is also only necessary for config members whose default
|
||||||
|
// value deviates from the zero value.
|
||||||
f, err := fn.NewFunction(config.Path)
|
f, err := fn.NewFunction(config.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
@ -94,15 +101,17 @@ func runBuild(cmd *cobra.Command, _ []string, newClient ClientFactory) (err erro
|
||||||
if !f.Initialized() {
|
if !f.Initialized() {
|
||||||
return fmt.Errorf("'%v' does not contain an initialized function", config.Path)
|
return fmt.Errorf("'%v' does not contain an initialized function", config.Path)
|
||||||
}
|
}
|
||||||
if config.Registry != "" {
|
if f.Registry == "" || cmd.Flags().Changed("registry") {
|
||||||
|
// Sets default AND accepts any user-provided overrides
|
||||||
f.Registry = config.Registry
|
f.Registry = config.Registry
|
||||||
}
|
}
|
||||||
|
if f.Builder == "" || cmd.Flags().Changed("builder") {
|
||||||
|
// Sets default AND accepts any user-provided overrides
|
||||||
|
f.Builder = config.Builder
|
||||||
|
}
|
||||||
if config.Image != "" {
|
if config.Image != "" {
|
||||||
f.Image = config.Image
|
f.Image = config.Image
|
||||||
}
|
}
|
||||||
if config.Builder != "" {
|
|
||||||
f.Builder = config.Builder
|
|
||||||
}
|
|
||||||
|
|
||||||
// Choose a builder based on the value of the --builder flag
|
// Choose a builder based on the value of the --builder flag
|
||||||
var builder fn.Builder
|
var builder fn.Builder
|
||||||
|
|
|
||||||
|
|
@ -128,15 +128,17 @@ func runDeploy(cmd *cobra.Command, _ []string, newClient ClientFactory) (err err
|
||||||
if !f.Initialized() {
|
if !f.Initialized() {
|
||||||
return fmt.Errorf("'%v' does not contain an initialized function", config.Path)
|
return fmt.Errorf("'%v' does not contain an initialized function", config.Path)
|
||||||
}
|
}
|
||||||
if config.Registry != "" {
|
if f.Registry == "" || cmd.Flags().Changed("registry") {
|
||||||
|
// Sets default AND accepts any user-provided overrides
|
||||||
f.Registry = config.Registry
|
f.Registry = config.Registry
|
||||||
}
|
}
|
||||||
|
if f.Builder == "" || cmd.Flags().Changed("builder") {
|
||||||
|
// Sets default AND accepts any user-provided overrides
|
||||||
|
f.Builder = config.Builder
|
||||||
|
}
|
||||||
if config.Image != "" {
|
if config.Image != "" {
|
||||||
f.Image = config.Image
|
f.Image = config.Image
|
||||||
}
|
}
|
||||||
if config.Builder != "" {
|
|
||||||
f.Builder = config.Builder
|
|
||||||
}
|
|
||||||
|
|
||||||
f.Namespace, err = checkNamespaceDeploy(f.Namespace, config.Namespace)
|
f.Namespace, err = checkNamespaceDeploy(f.Namespace, config.Namespace)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue