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
@@ -17,10 +17,12 @@ limitations under the License.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -29,16 +31,40 @@ type (
|
||||
)
|
||||
|
||||
var (
|
||||
once = sync.Once{}
|
||||
defaultClientset client.Interface
|
||||
once = sync.Once{}
|
||||
defaultClient Client
|
||||
)
|
||||
|
||||
func SetClientset(clientset client.Interface) {
|
||||
func SetClientset(client Client) {
|
||||
once.Do(func() {
|
||||
defaultClientset = clientset
|
||||
defaultClient = client
|
||||
})
|
||||
}
|
||||
|
||||
func (c *CommandActioner) Client() client.Interface {
|
||||
return defaultClientset
|
||||
func (c *CommandActioner) Client() Client {
|
||||
return defaultClient
|
||||
}
|
||||
|
||||
func (c *CommandActioner) GetResourceNamespace(input cli.Input, deprecatedFlag string) (namespace, currentNS string, err error) {
|
||||
namespace = input.String(deprecatedFlag)
|
||||
currentNS = namespace
|
||||
|
||||
if input.String(flagkey.Namespace) != "" {
|
||||
namespace = input.String(flagkey.Namespace)
|
||||
currentNS = namespace
|
||||
console.Verbose(2, "Namespace for resource %s ", currentNS)
|
||||
return namespace, currentNS, err
|
||||
}
|
||||
|
||||
if namespace == "" {
|
||||
if os.Getenv("FISSION_DEFAULT_NAMESPACE") != "" {
|
||||
currentNS = os.Getenv("FISSION_DEFAULT_NAMESPACE")
|
||||
} else {
|
||||
currentNS = c.Client().Namespace
|
||||
return namespace, currentNS, err
|
||||
}
|
||||
}
|
||||
|
||||
console.Verbose(2, "Namespace for resource %s ", currentNS)
|
||||
return namespace, currentNS, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user