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:
neha_gupta
2022-11-07 21:42:39 +05:30
committed by GitHub
co-authored by Sanket Sudake
parent 261bf24974
commit b71a36dc1c
86 changed files with 1115 additions and 978 deletions
+8 -7
View File
@@ -54,14 +54,11 @@ func (opts *UpdateSubCommand) do(input cli.Input) error {
func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
_, currentContextNS, err := util.GetResourceNamespace(input, flagkey.NamespaceEnvironment)
_, currentContextNS, err := opts.GetResourceNamespace(input, flagkey.NamespaceEnvironment)
if err != nil {
return errors.Wrap(err, "error creating environment")
}
env, err := opts.Client().V1().Environment().Get(&metav1.ObjectMeta{
Name: input.String(flagkey.EnvName),
Namespace: currentContextNS,
})
env, err := opts.Client().FissionClientSet.CoreV1().Environments(currentContextNS).Get(input.Context(), input.String(flagkey.EnvName), metav1.GetOptions{})
if err != nil {
return errors.Wrap(err, "error finding environment")
}
@@ -81,12 +78,16 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
}
func (opts *UpdateSubCommand) run(input cli.Input) error {
_, err := opts.Client().V1().Environment().Update(opts.env)
enew, err := opts.Client().FissionClientSet.CoreV1().Environments(opts.env.ObjectMeta.Namespace).Update(input.Context(), opts.env, metav1.UpdateOptions{})
if err != nil {
return errors.Wrap(err, "error updating environment")
}
if err != nil {
return errors.Wrap(err, "error updating environment")
}
fmt.Printf("environment '%v' updated\n", opts.env.ObjectMeta.Name)
fmt.Printf("environment '%v' updated\n", enew.ObjectMeta.Name)
return nil
}