Files
fission-src/pkg/fission-cli/cmd/kubewatch/command.go
T
Shubham BansalandGitHub f37e9e6f89 Use informer for kube watcher handling with multiple namespace support (#2594)
* changes to add informer for kube watcher
* code refactor and fix cli issue for deleting watch
2022-11-02 19:10:06 +05:30

71 lines
2.0 KiB
Go

/*
Copyright 2019 The Fission Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package kubewatch
import (
"github.com/spf13/cobra"
wrapper "github.com/fission/fission/pkg/fission-cli/cliwrapper/driver/cobra"
"github.com/fission/fission/pkg/fission-cli/flag"
)
func Commands() *cobra.Command {
createCmd := &cobra.Command{
Use: "create",
Short: "Create a kube watcher",
RunE: wrapper.Wrapper(Create),
}
wrapper.SetFlags(createCmd, flag.FlagSet{
Required: []flag.Flag{flag.KwFnName},
Optional: []flag.Flag{flag.KwName, flag.KwObjType, flag.KwNamespace, flag.NamespaceFunction, flag.SpecSave, flag.SpecDry},
// TODO: add label selector flag
// flag.KwLabelsFlag
})
deleteCmd := &cobra.Command{
Use: "delete",
Aliases: []string{},
Short: "Delete a kube watcher",
RunE: wrapper.Wrapper(Delete),
}
wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.KwName},
Optional: []flag.Flag{flag.NamespaceTrigger, flag.IgnoreNotFound, flag.KwFnName},
})
listCmd := &cobra.Command{
Use: "list",
Aliases: []string{},
Short: "List kube watchers",
Long: "List all kube watchers in a namespace if specified, else, list kube watchers across all namespaces",
RunE: wrapper.Wrapper(List),
}
wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.NamespaceTrigger, flag.AllNamespaces},
})
command := &cobra.Command{
Use: "watch",
Aliases: []string{"w"},
Short: "Create, update and manage kube watcher",
}
command.AddCommand(createCmd, deleteCmd, listCmd)
return command
}