Use Kubernetes Client instead of Controller APIs from CLI (#2605)
Use the Kubernetes and Fission Client from CLI instead of Controller API. This removes port-forwarding for the controller across Fission CLI mostly. * Use configurable client in CLI * Move resource namespace under cmd client * use server to get fission version * get archive with URL Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
co-authored by
Sanket Sudake
parent
261bf24974
commit
b71a36dc1c
@@ -22,12 +22,11 @@ import (
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
v1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
"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 ListSubCommand struct {
|
||||
@@ -48,7 +47,7 @@ func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) complete(input cli.Input) (err error) {
|
||||
_, opts.namespace, err = util.GetResourceNamespace(input, flagkey.NamespaceCanary)
|
||||
_, opts.namespace, err = opts.GetResourceNamespace(input, flagkey.NamespaceCanary)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in listing canary config ")
|
||||
}
|
||||
@@ -57,19 +56,18 @@ func (opts *ListSubCommand) complete(input cli.Input) (err error) {
|
||||
|
||||
func (opts *ListSubCommand) run(input cli.Input) (err error) {
|
||||
|
||||
var canaryCfgs []v1.CanaryConfig
|
||||
if input.Bool(flagkey.AllNamespaces) {
|
||||
canaryCfgs, err = opts.Client().V1().CanaryConfig().List("")
|
||||
} else {
|
||||
canaryCfgs, err = opts.Client().V1().CanaryConfig().List(opts.namespace)
|
||||
opts.namespace = metav1.NamespaceAll
|
||||
}
|
||||
canaryCfgs, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(opts.namespace).List(input.Context(), metav1.ListOptions{})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing canary config")
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", "NAME", "TRIGGER", "FUNCTION-N", "FUNCTION-N-1", "WEIGHT-INCREMENT", "INTERVAL", "FAILURE-THRESHOLD", "FAILURE-TYPE", "STATUS")
|
||||
for _, canaryCfg := range canaryCfgs {
|
||||
for _, canaryCfg := range canaryCfgs.Items {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
|
||||
canaryCfg.ObjectMeta.Name, canaryCfg.Spec.Trigger, canaryCfg.Spec.NewFunction, canaryCfg.Spec.OldFunction, canaryCfg.Spec.WeightIncrement, canaryCfg.Spec.WeightIncrementDuration,
|
||||
canaryCfg.Spec.FailureThreshold, canaryCfg.Spec.FailureType, canaryCfg.Status.Status)
|
||||
|
||||
Reference in New Issue
Block a user