Replace flag text with const (#1391)
This commit is contained in:
@@ -30,9 +30,9 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(Create),
|
||||
}
|
||||
wrapper.SetFlags(createCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.PkgEnvironmentFlag},
|
||||
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.NamespaceEnvironmentFlag,
|
||||
flag.PkgSrcArchiveFlag, flag.PkgDeployArchiveFlag, flag.PkgKeepURLFlag, flag.PkgBuildCmdFlag},
|
||||
Required: []flag.Flag{flag.PkgEnvironment},
|
||||
Optional: []flag.Flag{flag.PkgName, flag.NamespacePackage, flag.NamespaceEnvironment,
|
||||
flag.PkgSrcArchive, flag.PkgDeployArchive, flag.PkgKeepURL, flag.PkgBuildCmd},
|
||||
})
|
||||
|
||||
getSrcCmd := &cobra.Command{
|
||||
@@ -41,8 +41,8 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(GetSrc),
|
||||
}
|
||||
wrapper.SetFlags(getSrcCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.PkgNameFlag},
|
||||
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.PkgOutputFlag},
|
||||
Required: []flag.Flag{flag.PkgName},
|
||||
Optional: []flag.Flag{flag.NamespacePackage, flag.PkgOutput},
|
||||
})
|
||||
|
||||
getDeployCmd := &cobra.Command{
|
||||
@@ -51,8 +51,8 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(GetDeploy),
|
||||
}
|
||||
wrapper.SetFlags(getDeployCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.PkgNameFlag},
|
||||
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.PkgOutputFlag},
|
||||
Required: []flag.Flag{flag.PkgName},
|
||||
Optional: []flag.Flag{flag.NamespacePackage, flag.PkgOutput},
|
||||
})
|
||||
|
||||
updateCmd := &cobra.Command{
|
||||
@@ -61,10 +61,10 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(Update),
|
||||
}
|
||||
wrapper.SetFlags(updateCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.PkgNameFlag},
|
||||
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.PkgEnvironmentFlag, flag.NamespaceEnvironmentFlag,
|
||||
flag.PkgSrcArchiveFlag, flag.PkgDeployArchiveFlag, flag.PkgKeepURLFlag,
|
||||
flag.PkgBuildCmdFlag, flag.PkgForceFlag},
|
||||
Required: []flag.Flag{flag.PkgName},
|
||||
Optional: []flag.Flag{flag.NamespacePackage, flag.PkgEnvironment, flag.NamespaceEnvironment,
|
||||
flag.PkgSrcArchive, flag.PkgDeployArchive, flag.PkgKeepURL,
|
||||
flag.PkgBuildCmd, flag.PkgForce},
|
||||
})
|
||||
|
||||
deleteCmd := &cobra.Command{
|
||||
@@ -73,8 +73,7 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(Delete),
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.PkgNameFlag},
|
||||
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.PkgForceFlag, flag.PkgOrphanFlag},
|
||||
Optional: []flag.Flag{flag.PkgName, flag.NamespacePackage, flag.PkgForce, flag.PkgOrphan},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
@@ -83,7 +82,7 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(List),
|
||||
}
|
||||
wrapper.SetFlags(listCmd, flag.FlagSet{
|
||||
Optional: []flag.Flag{flag.PkgOrphanFlag, flag.PkgStatusFlag, flag.NamespacePackageFlag},
|
||||
Optional: []flag.Flag{flag.PkgOrphan, flag.PkgStatus, flag.NamespacePackage},
|
||||
})
|
||||
|
||||
infoCmd := &cobra.Command{
|
||||
@@ -92,7 +91,8 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(List),
|
||||
}
|
||||
wrapper.SetFlags(infoCmd, flag.FlagSet{
|
||||
Optional: []flag.Flag{flag.PkgNameFlag, flag.NamespacePackageFlag},
|
||||
Required: []flag.Flag{flag.PkgName},
|
||||
Optional: []flag.Flag{flag.NamespacePackage},
|
||||
})
|
||||
|
||||
rebuildCmd := &cobra.Command{
|
||||
@@ -101,7 +101,8 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(List),
|
||||
}
|
||||
wrapper.SetFlags(rebuildCmd, flag.FlagSet{
|
||||
Optional: []flag.Flag{flag.PkgNameFlag, flag.NamespacePackageFlag},
|
||||
Required: []flag.Flag{flag.PkgName},
|
||||
Optional: []flag.Flag{flag.NamespacePackage},
|
||||
})
|
||||
|
||||
command := &cobra.Command{
|
||||
|
||||
@@ -31,6 +31,8 @@ import (
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/spec"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
@@ -38,49 +40,49 @@ type CreateSubCommand struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
func Create(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(flags cli.Input) error {
|
||||
err := opts.complete(flags)
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
err := opts.run(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//return opts.run(flags)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) complete(flags cli.Input) error {
|
||||
pkgNamespace := flags.String("pkgNamespace")
|
||||
envName := flags.String("env")
|
||||
if len(envName) == 0 {
|
||||
return errors.New("Need --env argument.")
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
pkgName := input.String(flagkey.PkgName)
|
||||
if len(pkgName) == 0 {
|
||||
console.Warn(fmt.Sprintf("--%v will be soon marked as required flag, see 'help' for details", flagkey.HtName))
|
||||
}
|
||||
envNamespace := flags.String("envNamespace")
|
||||
srcArchiveFiles := flags.StringSlice("src")
|
||||
deployArchiveFiles := flags.StringSlice("deploy")
|
||||
buildcmd := flags.String("buildcmd")
|
||||
keepURL := flags.Bool("keepurl")
|
||||
pkgNamespace := input.String(flagkey.NamespacePackage)
|
||||
envName := input.String(flagkey.PkgEnvironment)
|
||||
envNamespace := input.String(flagkey.NamespaceEnvironment)
|
||||
srcArchiveFiles := input.StringSlice(flagkey.PkgSrcArchive)
|
||||
deployArchiveFiles := input.StringSlice(flagkey.PkgDeployArchive)
|
||||
buildcmd := input.String(flagkey.PkgBuildCmd)
|
||||
keepURL := input.Bool(flagkey.PkgKeepURL)
|
||||
|
||||
if len(srcArchiveFiles) == 0 && len(deployArchiveFiles) == 0 {
|
||||
return errors.New("Need --src to specify source archive, or use --deploy to specify deployment archive.")
|
||||
return errors.Errorf("need --%v or --%v flag", flagkey.PkgSrcArchive, flagkey.PkgDeployArchive)
|
||||
}
|
||||
|
||||
_, err := CreatePackage(flags, opts.client, pkgNamespace, envName, envNamespace,
|
||||
_, err := CreatePackage(input, opts.client, pkgName, pkgNamespace, envName, envNamespace,
|
||||
srcArchiveFiles, deployArchiveFiles, buildcmd, "", "", false, keepURL)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string, envName string, envNamespace string,
|
||||
func CreatePackage(input cli.Input, client *client.Client, pkgName string, pkgNamespace string, envName string, envNamespace string,
|
||||
srcArchiveFiles []string, deployArchiveFiles []string, buildcmd string, specDir string, specFile string, noZip bool, keepURL bool) (*metav1.ObjectMeta, error) {
|
||||
|
||||
pkgSpec := fv1.PackageSpec{
|
||||
@@ -91,7 +93,6 @@ func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string,
|
||||
}
|
||||
var pkgStatus fv1.BuildStatus = fv1.BuildStatusSucceeded
|
||||
|
||||
var pkgName string
|
||||
if len(deployArchiveFiles) > 0 {
|
||||
if len(specFile) > 0 { // we should do this in all cases, i think
|
||||
pkgStatus = fv1.BuildStatusNone
|
||||
@@ -101,7 +102,9 @@ func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string,
|
||||
return nil, err
|
||||
}
|
||||
pkgSpec.Deployment = *deployment
|
||||
pkgName = util.KubifyName(fmt.Sprintf("%v-%v", path.Base(deployArchiveFiles[0]), uniuri.NewLen(4)))
|
||||
if len(pkgName) == 0 {
|
||||
pkgName = util.KubifyName(fmt.Sprintf("%v-%v", path.Base(deployArchiveFiles[0]), uniuri.NewLen(4)))
|
||||
}
|
||||
}
|
||||
if len(srcArchiveFiles) > 0 {
|
||||
source, err := CreateArchive(client, srcArchiveFiles, false, keepURL, specDir, specFile)
|
||||
@@ -110,7 +113,9 @@ func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string,
|
||||
}
|
||||
pkgSpec.Source = *source
|
||||
pkgStatus = fv1.BuildStatusPending // set package build status to pending
|
||||
pkgName = util.KubifyName(fmt.Sprintf("%v-%v", path.Base(srcArchiveFiles[0]), uniuri.NewLen(4)))
|
||||
if len(pkgName) == 0 {
|
||||
pkgName = util.KubifyName(fmt.Sprintf("%v-%v", path.Base(srcArchiveFiles[0]), uniuri.NewLen(4)))
|
||||
}
|
||||
}
|
||||
|
||||
if len(buildcmd) > 0 {
|
||||
@@ -134,7 +139,7 @@ func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string,
|
||||
|
||||
if len(specFile) > 0 {
|
||||
// if a package sith the same spec exists, don't create a new spec file
|
||||
fr, err := spec.ReadSpecs(util.GetSpecDir(flags))
|
||||
fr, err := spec.ReadSpecs(util.GetSpecDir(input))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error reading specs")
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
@@ -35,42 +36,39 @@ type DeleteSubCommand struct {
|
||||
force bool
|
||||
}
|
||||
|
||||
func Delete(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func Delete(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := DeleteSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) do(flags cli.Input) error {
|
||||
err := opts.complete(flags)
|
||||
func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
err := opts.complete(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return opts.run(flags)
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) complete(flags cli.Input) error {
|
||||
opts.name = flags.String("name")
|
||||
opts.namespace = flags.String("pkgNamespace")
|
||||
opts.deleteOrphans = flags.Bool("orphan")
|
||||
opts.force = flags.Bool("f")
|
||||
func (opts *DeleteSubCommand) complete(input cli.Input) error {
|
||||
opts.name = input.String(flagkey.PkgName)
|
||||
opts.namespace = input.String(flagkey.NamespacePackage)
|
||||
opts.deleteOrphans = input.Bool(flagkey.PkgOrphan)
|
||||
opts.force = input.Bool(flagkey.PkgForce)
|
||||
|
||||
if len(opts.name) == 0 && !opts.deleteOrphans {
|
||||
return errors.New("need --name argument or --orphan flag")
|
||||
}
|
||||
if len(opts.name) != 0 && opts.deleteOrphans {
|
||||
return errors.New("need either --name argument or --orphan flag")
|
||||
return errors.Errorf("need --%v or --%v flag", flagkey.PkgName, flagkey.PkgOrphan)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) run(flags cli.Input) error {
|
||||
func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
if len(opts.name) != 0 {
|
||||
_, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
Namespace: opts.namespace,
|
||||
@@ -93,7 +91,10 @@ func (opts *DeleteSubCommand) run(flags cli.Input) error {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("Package '%v' deleted\n", opts.name)
|
||||
} else {
|
||||
}
|
||||
|
||||
// TODO improve list speed when --orphan
|
||||
if opts.deleteOrphans {
|
||||
err := deleteOrphanPkgs(opts.client, opts.namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "deleting orphan packages")
|
||||
|
||||
@@ -18,7 +18,6 @@ package _package
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@@ -28,6 +27,7 @@ import (
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
pkgutil "github.com/fission/fission/pkg/fission-cli/cmd/package/util"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
@@ -44,8 +44,8 @@ type GetSubCommand struct {
|
||||
archiveType int
|
||||
}
|
||||
|
||||
func GetSrc(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func GetSrc(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -53,11 +53,11 @@ func GetSrc(flags cli.Input) error {
|
||||
client: c,
|
||||
archiveType: sourceArchive,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func GetDeploy(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func GetDeploy(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -65,28 +65,25 @@ func GetDeploy(flags cli.Input) error {
|
||||
client: c,
|
||||
archiveType: deployArchive,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func (opts *GetSubCommand) do(flags cli.Input) error {
|
||||
err := opts.complete(flags)
|
||||
func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
err := opts.complete(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return opts.run(flags)
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *GetSubCommand) complete(flags cli.Input) error {
|
||||
opts.name = flags.String("name")
|
||||
if len(opts.name) == 0 {
|
||||
return errors.New("need name of package, use --name")
|
||||
}
|
||||
opts.namespace = flags.String("pkgNamespace")
|
||||
opts.output = flags.String("output")
|
||||
func (opts *GetSubCommand) complete(input cli.Input) error {
|
||||
opts.name = input.String(flagkey.PkgName)
|
||||
opts.namespace = input.String(flagkey.NamespacePackage)
|
||||
opts.output = input.String(flagkey.PkgOutput)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *GetSubCommand) run(flags cli.Input) error {
|
||||
func (opts *GetSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
Namespace: opts.namespace,
|
||||
Name: opts.name,
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
@@ -35,35 +36,32 @@ type InfoSubCommand struct {
|
||||
namespace string
|
||||
}
|
||||
|
||||
func Info(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func Info(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := InfoSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func (opts *InfoSubCommand) do(flags cli.Input) error {
|
||||
err := opts.complete(flags)
|
||||
func (opts *InfoSubCommand) do(input cli.Input) error {
|
||||
err := opts.complete(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return opts.run(flags)
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *InfoSubCommand) complete(flags cli.Input) error {
|
||||
opts.name = flags.String("name")
|
||||
if len(opts.name) == 0 {
|
||||
return errors.New("Need name of package, use --name")
|
||||
}
|
||||
opts.namespace = flags.String("pkgNamespace")
|
||||
func (opts *InfoSubCommand) complete(input cli.Input) error {
|
||||
opts.name = input.String(flagkey.PkgName)
|
||||
opts.namespace = input.String("pkgNamespace")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *InfoSubCommand) run(flags cli.Input) error {
|
||||
func (opts *InfoSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
Namespace: opts.namespace,
|
||||
Name: opts.name,
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
@@ -37,34 +38,34 @@ type ListSubCommand struct {
|
||||
pkgNamespace string
|
||||
}
|
||||
|
||||
func List(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(flags cli.Input) error {
|
||||
err := opts.complete(flags)
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
err := opts.complete(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return opts.run(flags)
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) complete(flags cli.Input) error {
|
||||
func (opts *ListSubCommand) complete(input cli.Input) error {
|
||||
// option for the user to list all orphan packages (not referenced by any function)
|
||||
opts.listOrphans = flags.Bool("orphan")
|
||||
opts.status = flags.String("status")
|
||||
opts.pkgNamespace = flags.String("pkgNamespace")
|
||||
opts.listOrphans = input.Bool(flagkey.PkgOrphan)
|
||||
opts.status = input.String(flagkey.PkgStatus)
|
||||
opts.pkgNamespace = input.String(flagkey.NamespacePackage)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) run(flags cli.Input) error {
|
||||
func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
pkgList, err := opts.client.PackageList(opts.pkgNamespace)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -80,6 +81,7 @@ func (opts *ListSubCommand) run(flags cli.Input) error {
|
||||
|
||||
for _, pkg := range pkgList {
|
||||
show := true
|
||||
// TODO improve list speed when --orphan
|
||||
if opts.listOrphans {
|
||||
fnList, err := GetFunctionsByPackage(opts.client, pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
if err != nil {
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
@@ -34,35 +35,32 @@ type RebuildSubCommand struct {
|
||||
namespace string
|
||||
}
|
||||
|
||||
func Rebuild(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func Rebuild(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := RebuildSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func (opts *RebuildSubCommand) do(flags cli.Input) error {
|
||||
err := opts.complete(flags)
|
||||
func (opts *RebuildSubCommand) do(input cli.Input) error {
|
||||
err := opts.complete(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return opts.run(flags)
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *RebuildSubCommand) complete(flags cli.Input) error {
|
||||
opts.name = flags.String("name")
|
||||
if len(opts.name) == 0 {
|
||||
return errors.New("Need name of package, use --name")
|
||||
}
|
||||
opts.namespace = flags.String("pkgNamespace")
|
||||
func (opts *RebuildSubCommand) complete(input cli.Input) error {
|
||||
opts.name = input.String(flagkey.PkgName)
|
||||
opts.namespace = input.String(flagkey.NamespacePackage)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *RebuildSubCommand) run(flags cli.Input) error {
|
||||
func (opts *RebuildSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
Name: opts.name,
|
||||
Namespace: opts.namespace,
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
@@ -42,51 +43,39 @@ type UpdateSubCommand struct {
|
||||
keepURL bool
|
||||
}
|
||||
|
||||
func Update(flags cli.Input) error {
|
||||
c, err := util.GetServer(flags)
|
||||
func Update(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := UpdateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(flags)
|
||||
return opts.do(input)
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) do(flags cli.Input) error {
|
||||
err := opts.complete(flags)
|
||||
func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
err := opts.complete(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return opts.run(flags)
|
||||
return opts.run(input)
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) complete(flags cli.Input) error {
|
||||
opts.pkgName = flags.String("name")
|
||||
if len(opts.pkgName) == 0 {
|
||||
return errors.New("Need --name argument.")
|
||||
}
|
||||
opts.pkgNamespace = flags.String("pkgNamespace")
|
||||
opts.force = flags.Bool("f")
|
||||
opts.envName = flags.String("env")
|
||||
opts.envNamespace = flags.String("envNamespace")
|
||||
opts.srcArchiveFiles = flags.StringSlice("src")
|
||||
opts.deployArchiveFiles = flags.StringSlice("deploy")
|
||||
opts.buildcmd = flags.String("buildcmd")
|
||||
opts.keepURL = flags.Bool("keepurl")
|
||||
|
||||
if len(opts.srcArchiveFiles) > 0 && len(opts.deployArchiveFiles) > 0 {
|
||||
return errors.New("Need either of --src or --deploy and not both arguments.")
|
||||
}
|
||||
|
||||
if len(opts.srcArchiveFiles) == 0 && len(opts.deployArchiveFiles) == 0 &&
|
||||
len(opts.envName) == 0 && len(opts.buildcmd) == 0 {
|
||||
return errors.New("Need --env or --src or --deploy or --buildcmd argument.")
|
||||
}
|
||||
func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
opts.pkgName = input.String(flagkey.PkgName)
|
||||
opts.pkgNamespace = input.String(flagkey.NamespacePackage)
|
||||
opts.force = input.Bool(flagkey.PkgForce)
|
||||
opts.envName = input.String(flagkey.PkgEnvironment)
|
||||
opts.envNamespace = input.String(flagkey.NamespaceEnvironment)
|
||||
opts.srcArchiveFiles = input.StringSlice(flagkey.PkgSrcArchive)
|
||||
opts.deployArchiveFiles = input.StringSlice(flagkey.PkgDeployArchive)
|
||||
opts.buildcmd = input.String(flagkey.PkgBuildCmd)
|
||||
opts.keepURL = input.Bool(flagkey.PkgKeepURL)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) run(flags cli.Input) error {
|
||||
func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
Namespace: opts.pkgNamespace,
|
||||
Name: opts.pkgName,
|
||||
|
||||
Reference in New Issue
Block a user