Added ignorenotfound flag for all resources' deletion (#2293)
Treat \"resource not found\" as a successful delete if ignorenotfound flag passed while deletion of Fission resource.
This commit is contained in:
@@ -65,7 +65,7 @@ func Commands() *cobra.Command {
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.CanaryName},
|
||||
Optional: []flag.Flag{flag.NamespaceCanary},
|
||||
Optional: []flag.Flag{flag.NamespaceCanary, flag.IgnoreNotFound},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type DeleteSubCommand struct {
|
||||
@@ -43,6 +44,9 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
|
||||
err := opts.Client().V1().CanaryConfig().Delete(m)
|
||||
if err != nil {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting canary config")
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ func Commands() *cobra.Command {
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.EnvName},
|
||||
Optional: []flag.Flag{flag.NamespaceEnvironment},
|
||||
Optional: []flag.Flag{flag.NamespaceEnvironment, flag.IgnoreNotFound},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type DeleteSubCommand struct {
|
||||
@@ -43,6 +44,9 @@ func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
|
||||
err := opts.Client().V1().Environment().Delete(m)
|
||||
if err != nil {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting environment")
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ func Commands() *cobra.Command {
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.FnName},
|
||||
Optional: []flag.Flag{flag.NamespaceFunction},
|
||||
Optional: []flag.Flag{flag.NamespaceFunction, flag.IgnoreNotFound},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type DeleteSubCommand struct {
|
||||
@@ -43,6 +44,9 @@ func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
|
||||
err := opts.Client().V1().Function().Delete(m)
|
||||
if err != nil {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, fmt.Sprintf("delete function '%v'", m.Name))
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(Delete),
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Optional: []flag.Flag{flag.HtName, flag.HtFnFilter, flag.NamespaceTrigger},
|
||||
Optional: []flag.Flag{flag.HtName, flag.HtFnFilter, flag.NamespaceTrigger, flag.IgnoreNotFound},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -94,6 +95,9 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
}
|
||||
|
||||
if errs.ErrorOrNil() != nil {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(errs.ErrorOrNil(), "error deleting trigger(s)")
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ func Commands() *cobra.Command {
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.KwFnName},
|
||||
Optional: []flag.Flag{flag.NamespaceTrigger},
|
||||
Optional: []flag.Flag{flag.NamespaceTrigger, flag.IgnoreNotFound},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type DeleteSubCommand struct {
|
||||
@@ -57,6 +58,9 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
Namespace: opts.namespace,
|
||||
})
|
||||
if err != nil {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting kubewatch")
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ func Commands() *cobra.Command {
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.MqtName},
|
||||
Optional: []flag.Flag{flag.NamespaceTrigger},
|
||||
Optional: []flag.Flag{flag.NamespaceTrigger, flag.IgnoreNotFound},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type DeleteSubCommand struct {
|
||||
@@ -55,6 +56,9 @@ func (opts *DeleteSubCommand) complete(input cli.Input) error {
|
||||
func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
err := opts.Client().V1().MessageQueueTrigger().Delete(opts.metadata)
|
||||
if err != nil {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting message queue trigger")
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ func Commands() *cobra.Command {
|
||||
RunE: wrapper.Wrapper(Delete),
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Optional: []flag.Flag{flag.PkgName, flag.PkgForce, flag.PkgOrphan, flag.NamespacePackage},
|
||||
Optional: []flag.Flag{flag.PkgName, flag.PkgForce, flag.PkgOrphan, flag.NamespacePackage, flag.IgnoreNotFound},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type DeleteSubCommand struct {
|
||||
@@ -68,6 +69,9 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
Name: opts.name,
|
||||
})
|
||||
if err != nil {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "find package")
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ func Commands() *cobra.Command {
|
||||
}
|
||||
wrapper.SetFlags(deleteCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.TtName},
|
||||
Optional: []flag.Flag{flag.NamespaceTrigger},
|
||||
Optional: []flag.Flag{flag.NamespaceTrigger, flag.IgnoreNotFound},
|
||||
})
|
||||
|
||||
listCmd := &cobra.Command{
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type DeleteSubCommand struct {
|
||||
@@ -43,6 +44,9 @@ func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
|
||||
err := opts.Client().V1().TimeTrigger().Delete(m)
|
||||
if err != nil {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting trigger")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user