mirror of https://github.com/knative/func.git
feat: completion --build flag of deploy sub-cmd (#802)
* feat: completion --build flag of deploy sub-cmd Signed-off-by: Matej Vasek <mvasek@redhat.com> * src: refactor Moved functionality. Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
parent
6c6ea0dadc
commit
fff00497f8
|
@ -125,3 +125,9 @@ func CompleteBuilderList(cmd *cobra.Command, args []string, complete string) (st
|
|||
directive = cobra.ShellCompDirectiveDefault
|
||||
return
|
||||
}
|
||||
|
||||
func CompleteDeployBuildType(cmd *cobra.Command, args []string, complete string) (buildTypes []string, directive cobra.ShellCompDirective) {
|
||||
buildTypes = fn.AllBuildTypes()
|
||||
directive = cobra.ShellCompDirectiveDefault
|
||||
return
|
||||
}
|
||||
|
|
|
@ -124,6 +124,10 @@ kn func deploy --image quay.io/myuser/myfunc -n myns
|
|||
setPathFlag(cmd)
|
||||
setNamespaceFlag(cmd)
|
||||
|
||||
if err := cmd.RegisterFlagCompletionFunc("build", CompleteDeployBuildType); err != nil {
|
||||
fmt.Println("internal: error while calling RegisterFlagCompletionFunc: ", err)
|
||||
}
|
||||
|
||||
cmd.RunE = func(cmd *cobra.Command, args []string) error {
|
||||
return runDeploy(cmd, args, clientFn)
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ const (
|
|||
//BuildTypeRemote = "remote" // TODO not supported yet
|
||||
)
|
||||
|
||||
func AllBuildTypes() []string {
|
||||
return []string{BuildTypeLocal, BuildTypeGit, BuildTypeDisabled}
|
||||
}
|
||||
|
||||
// ValidateBuild validates input Build type option from Function config.
|
||||
// If "allowUnset" is set to true, the specified type could be "" -> fallback to DefaultBuildType,
|
||||
// this option should be used for validating func.yaml file, where users don't have to specify the build type.
|
||||
|
|
Loading…
Reference in New Issue