Add controller API client interface (#1467)
This PR adds an interface for controller API client, it allows us to implement mock API client for unit testing with ease and we are able to generate spec file without accessing the real Fission server.
This commit is contained in:
@@ -24,27 +24,20 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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/types"
|
||||
)
|
||||
|
||||
type CreateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
canary *fv1.CanaryConfig
|
||||
}
|
||||
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&CreateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
@@ -74,7 +67,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
// check that the trigger exists in the same namespace.
|
||||
htTrigger, err := opts.client.HTTPTriggerGet(&metav1.ObjectMeta{
|
||||
htTrigger, err := opts.Client().V1().HTTPTrigger().Get(&metav1.ObjectMeta{
|
||||
Name: ht,
|
||||
Namespace: fnNs,
|
||||
})
|
||||
@@ -100,7 +93,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
// check that the functions exist in the same namespace
|
||||
fnList := []string{newFunc, oldFunc}
|
||||
err = util.CheckFunctionExistence(opts.client, fnList, fnNs)
|
||||
err = util.CheckFunctionExistence(opts.Client(), fnList, fnNs)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error checking functions existence")
|
||||
}
|
||||
@@ -129,7 +122,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.client.CanaryConfigCreate(opts.canary)
|
||||
_, err := opts.Client().V1().CanaryConfig().Create(opts.canary)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating canary config")
|
||||
}
|
||||
|
||||
@@ -22,25 +22,17 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Delete(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := DeleteSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.run(input)
|
||||
return (&DeleteSubCommand{}).run(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
@@ -49,7 +41,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
Namespace: input.String(flagkey.NamespaceCanary),
|
||||
}
|
||||
|
||||
err := opts.client.CanaryConfigDelete(m)
|
||||
err := opts.Client().V1().CanaryConfig().Delete(m)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error deleting canary config")
|
||||
}
|
||||
|
||||
@@ -24,29 +24,21 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 GetSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Get(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := GetSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.run(input)
|
||||
return (&GetSubCommand{}).run(input)
|
||||
}
|
||||
|
||||
func (opts *GetSubCommand) run(input cli.Input) error {
|
||||
canaryCfg, err := opts.client.CanaryConfigGet(&metav1.ObjectMeta{
|
||||
canaryCfg, err := opts.Client().V1().CanaryConfig().Get(&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.CanaryName),
|
||||
Namespace: input.String(flagkey.NamespaceCanary),
|
||||
})
|
||||
|
||||
@@ -23,26 +23,18 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
namespace string
|
||||
}
|
||||
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ListSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
@@ -59,7 +51,7 @@ func (opts *ListSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
canaryCfgs, err := opts.client.CanaryConfigList(opts.namespace)
|
||||
canaryCfgs, err := opts.Client().V1().CanaryConfig().List(opts.namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing canary config")
|
||||
}
|
||||
|
||||
@@ -24,26 +24,18 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 UpdateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
canary *fv1.CanaryConfig
|
||||
}
|
||||
|
||||
func Update(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := UpdateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&UpdateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
@@ -68,7 +60,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
return errors.Wrap(err, "error parsing time duration")
|
||||
}
|
||||
|
||||
canaryCfg, err := opts.client.CanaryConfigGet(&metav1.ObjectMeta{
|
||||
canaryCfg, err := opts.Client().V1().CanaryConfig().Get(&metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: ns,
|
||||
})
|
||||
@@ -100,7 +92,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.client.CanaryConfigUpdate(opts.canary)
|
||||
_, err := opts.Client().V1().CanaryConfig().Update(opts.canary)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating canary config")
|
||||
}
|
||||
|
||||
@@ -17,9 +17,28 @@ limitations under the License.
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
)
|
||||
|
||||
type (
|
||||
CommandAction func(input cli.Input) error
|
||||
CommandAction func(input cli.Input) error
|
||||
CommandActioner struct{}
|
||||
)
|
||||
|
||||
var (
|
||||
once = sync.Once{}
|
||||
defaultClientset client.Interface
|
||||
)
|
||||
|
||||
func SetClientset(clientset client.Interface) {
|
||||
once.Do(func() {
|
||||
defaultClientset = clientset
|
||||
})
|
||||
}
|
||||
|
||||
func (c *CommandActioner) Client() client.Interface {
|
||||
return defaultClientset
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/spec"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
@@ -34,19 +34,12 @@ import (
|
||||
)
|
||||
|
||||
type CreateSubCommand struct {
|
||||
client *client.Client
|
||||
env *fv1.Environment
|
||||
cmd.CommandActioner
|
||||
env *fv1.Environment
|
||||
}
|
||||
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&CreateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
@@ -72,7 +65,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
m := opts.env.Metadata
|
||||
|
||||
envList, err := opts.client.EnvironmentList(m.Namespace)
|
||||
envList, err := opts.Client().V1().Environment().List(m.Namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if len(envList) > 0 {
|
||||
@@ -92,7 +85,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err = opts.client.EnvironmentCreate(opts.env)
|
||||
_, err = opts.Client().V1().Environment().Create(opts.env)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating environment")
|
||||
}
|
||||
|
||||
@@ -22,25 +22,17 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Delete(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := DeleteSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&DeleteSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
@@ -49,7 +41,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
Namespace: input.String(flagkey.NamespaceEnvironment),
|
||||
}
|
||||
|
||||
err := opts.client.EnvironmentDelete(m)
|
||||
err := opts.Client().V1().Environment().Delete(m)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error deleting environment")
|
||||
}
|
||||
|
||||
@@ -24,25 +24,17 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 GetSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Get(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := GetSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&GetSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
@@ -51,7 +43,7 @@ func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
Namespace: input.String(flagkey.NamespaceEnvironment),
|
||||
}
|
||||
|
||||
env, err := opts.client.EnvironmentGet(m)
|
||||
env, err := opts.Client().V1().Environment().Get(m)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting environment")
|
||||
}
|
||||
|
||||
@@ -23,29 +23,21 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ListSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
envs, err := opts.client.EnvironmentList(input.String(flagkey.NamespaceEnvironment))
|
||||
envs, err := opts.Client().V1().Environment().List(input.String(flagkey.NamespaceEnvironment))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing environments")
|
||||
}
|
||||
|
||||
@@ -24,27 +24,19 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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"
|
||||
)
|
||||
|
||||
type UpdateSubCommand struct {
|
||||
client *client.Client
|
||||
env *fv1.Environment
|
||||
cmd.CommandActioner
|
||||
env *fv1.Environment
|
||||
}
|
||||
|
||||
func Update(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := UpdateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&UpdateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
@@ -56,7 +48,7 @@ func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
env, err := opts.client.EnvironmentGet(&metav1.ObjectMeta{
|
||||
env, err := opts.Client().V1().Environment().Get(&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.EnvName),
|
||||
Namespace: input.String(flagkey.NamespaceEnvironment),
|
||||
})
|
||||
@@ -74,7 +66,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.client.EnvironmentUpdate(opts.env)
|
||||
_, err := opts.Client().V1().Environment().Update(opts.env)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating environment")
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/httptrigger"
|
||||
_package "github.com/fission/fission/pkg/fission-cli/cmd/package"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/spec"
|
||||
@@ -44,20 +44,13 @@ const (
|
||||
)
|
||||
|
||||
type CreateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
function *fv1.Function
|
||||
specFile string
|
||||
}
|
||||
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&CreateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
@@ -83,7 +76,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
if !toSpec {
|
||||
// check for unique function names within a namespace
|
||||
fn, err := opts.client.FunctionGet(&metav1.ObjectMeta{
|
||||
fn, err := opts.Client().V1().Function().Get(&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.FnName),
|
||||
Namespace: input.String(flagkey.NamespaceFunction),
|
||||
})
|
||||
@@ -139,7 +132,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
pkgMetadata = &pkg.Metadata
|
||||
} else {
|
||||
// use existing package
|
||||
pkg, err = opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
pkg, err = opts.Client().V1().Package().Get(&metav1.ObjectMeta{
|
||||
Namespace: fnNamespace,
|
||||
Name: pkgName,
|
||||
})
|
||||
@@ -181,7 +174,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
fnName, envName))
|
||||
}
|
||||
} else {
|
||||
_, err := opts.client.EnvironmentGet(&metav1.ObjectMeta{
|
||||
_, err := opts.Client().V1().Environment().Get(&metav1.ObjectMeta{
|
||||
Namespace: envNamespace,
|
||||
Name: envName,
|
||||
})
|
||||
@@ -213,7 +206,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
pkgName := fmt.Sprintf("%v-%v", fnName, uuid.NewV4().String())
|
||||
|
||||
// create new package in the same namespace as the function.
|
||||
pkgMetadata, err = _package.CreatePackage(input, opts.client, pkgName, fnNamespace, envName, envNamespace,
|
||||
pkgMetadata, err = _package.CreatePackage(input, opts.Client(), pkgName, fnNamespace, envName, envNamespace,
|
||||
srcArchiveFiles, deployArchiveFiles, buildcmd, specDir, opts.specFile, noZip)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating package")
|
||||
@@ -227,7 +220,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
// check the referenced secret is in the same ns as the function, if not give a warning.
|
||||
if !toSpec { // TODO: workaround in order not to block users from creating function spec, remove it.
|
||||
for _, secretName := range secretNames {
|
||||
_, err := opts.client.SecretGet(&metav1.ObjectMeta{
|
||||
_, err := opts.Client().V1().Misc().SecretGet(&metav1.ObjectMeta{
|
||||
Namespace: fnNamespace,
|
||||
Name: secretName,
|
||||
})
|
||||
@@ -253,7 +246,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
// check the referenced cfgmap is in the same ns as the function, if not give a warning.
|
||||
if !toSpec {
|
||||
for _, cfgMapName := range cfgMapNames {
|
||||
_, err := opts.client.ConfigMapGet(&metav1.ObjectMeta{
|
||||
_, err := opts.Client().V1().Misc().ConfigMapGet(&metav1.ObjectMeta{
|
||||
Namespace: fnNamespace,
|
||||
Name: cfgMapName,
|
||||
})
|
||||
@@ -316,7 +309,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.client.FunctionCreate(opts.function)
|
||||
_, err := opts.Client().V1().Function().Create(opts.function)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating function")
|
||||
}
|
||||
@@ -352,7 +345,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
},
|
||||
},
|
||||
}
|
||||
_, err = opts.client.HTTPTriggerCreate(ht)
|
||||
_, err = opts.Client().V1().HTTPTrigger().Create(ht)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating HTTP trigger")
|
||||
}
|
||||
|
||||
@@ -22,25 +22,17 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Delete(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := DeleteSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&DeleteSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
@@ -49,7 +41,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
Namespace: input.String(flagkey.NamespaceFunction),
|
||||
}
|
||||
|
||||
err := opts.client.FunctionDelete(m)
|
||||
err := opts.Client().V1().Function().Delete(m)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("delete function '%v'", m.Name))
|
||||
}
|
||||
|
||||
@@ -22,29 +22,21 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 GetSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Get(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := GetSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&GetSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
fn, err := opts.client.FunctionGet(&metav1.ObjectMeta{
|
||||
fn, err := opts.Client().V1().Function().Get(&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.FnName),
|
||||
Namespace: input.String(flagkey.NamespaceFunction),
|
||||
})
|
||||
@@ -52,7 +44,7 @@ func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
return errors.Wrap(err, "error getting function")
|
||||
}
|
||||
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
pkg, err := opts.Client().V1().Package().Get(&metav1.ObjectMeta{
|
||||
Name: fn.Spec.Package.PackageRef.Name,
|
||||
Namespace: fn.Spec.Package.PackageRef.Namespace,
|
||||
})
|
||||
|
||||
@@ -24,29 +24,21 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 GetMetaSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func GetMeta(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := GetMetaSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&GetMetaSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *GetMetaSubCommand) do(input cli.Input) error {
|
||||
fn, err := opts.client.FunctionGet(&metav1.ObjectMeta{
|
||||
fn, err := opts.Client().V1().Function().Get(&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.FnName),
|
||||
Namespace: input.String(flagkey.NamespaceFunction),
|
||||
})
|
||||
|
||||
@@ -24,31 +24,23 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ListSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
ns := input.String(flagkey.NamespaceFunction)
|
||||
|
||||
fns, err := opts.client.FunctionList(ns)
|
||||
fns, err := opts.Client().V1().Function().List(ns)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing functions")
|
||||
}
|
||||
|
||||
@@ -24,26 +24,19 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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/logdb"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type LogSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Log(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := LogSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&LogSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *LogSubCommand) do(input cli.Input) error {
|
||||
@@ -57,7 +50,7 @@ func (opts *LogSubCommand) do(input cli.Input) error {
|
||||
recordLimit = 1000
|
||||
}
|
||||
|
||||
f, err := opts.client.FunctionGet(&metav1.ObjectMeta{
|
||||
f, err := opts.Client().V1().Function().Get(&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.FnName),
|
||||
Namespace: input.String(flagkey.NamespaceFunction),
|
||||
})
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/httptrigger"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
@@ -37,18 +38,11 @@ import (
|
||||
)
|
||||
|
||||
type TestSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Test(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := TestSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&TestSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *TestSubCommand) do(input cli.Input) error {
|
||||
@@ -124,7 +118,7 @@ func (opts *TestSubCommand) do(input cli.Input) error {
|
||||
}
|
||||
|
||||
console.Errorf("Error calling function %s: %d; Please try again or fix the error: %s\n", m.Name, resp.StatusCode, string(body))
|
||||
log, err := printPodLogs(opts.client, m)
|
||||
log, err := printPodLogs(opts.Client(), m)
|
||||
if err != nil {
|
||||
console.Errorf("Error getting function logs from controller: %v. Try to get logs from log database.", err)
|
||||
err = Log(input)
|
||||
@@ -163,8 +157,8 @@ func doHTTPRequest(ctx context.Context, url string, headers []string, method, bo
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func printPodLogs(client *client.Client, fnMeta *metav1.ObjectMeta) (string, error) {
|
||||
reader, statusCode, err := client.FunctionPodLogs(fnMeta)
|
||||
func printPodLogs(client client.Interface, fnMeta *metav1.ObjectMeta) (string, error) {
|
||||
reader, statusCode, err := client.V1().Misc().PodLogs(fnMeta)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "error executing get logs request")
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
_package "github.com/fission/fission/pkg/fission-cli/cmd/package"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
@@ -33,19 +33,12 @@ import (
|
||||
)
|
||||
|
||||
type UpdateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
function *fv1.Function
|
||||
}
|
||||
|
||||
func Update(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := UpdateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&UpdateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
@@ -60,7 +53,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
fnName := input.String(flagkey.FnName)
|
||||
fnNamespace := input.String(flagkey.NamespaceFunction)
|
||||
|
||||
function, err := opts.client.FunctionGet(&metav1.ObjectMeta{
|
||||
function, err := opts.Client().V1().Function().Get(&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.FnName),
|
||||
Namespace: input.String(flagkey.NamespaceFunction),
|
||||
})
|
||||
@@ -94,7 +87,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
// check that the referenced secret is in the same ns as the function, if not give a warning.
|
||||
for _, secretName := range secretNames {
|
||||
_, err := opts.client.SecretGet(&metav1.ObjectMeta{
|
||||
_, err := opts.Client().V1().Misc().SecretGet(&metav1.ObjectMeta{
|
||||
Namespace: fnNamespace,
|
||||
Name: secretName,
|
||||
})
|
||||
@@ -118,7 +111,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
// check that the referenced cfgmap is in the same ns as the function, if not give a warning.
|
||||
for _, cfgMapName := range cfgMapNames {
|
||||
_, err := opts.client.ConfigMapGet(&metav1.ObjectMeta{
|
||||
_, err := opts.Client().V1().Misc().ConfigMapGet(&metav1.ObjectMeta{
|
||||
Namespace: fnNamespace,
|
||||
Name: cfgMapName,
|
||||
})
|
||||
@@ -174,7 +167,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
function.Spec.Resources = *resReqs
|
||||
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
pkg, err := opts.Client().V1().Package().Get(&metav1.ObjectMeta{
|
||||
Namespace: fnNamespace,
|
||||
Name: pkgName,
|
||||
})
|
||||
@@ -184,7 +177,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
forceUpdate := input.Bool(flagkey.PkgForce)
|
||||
|
||||
fnList, err := _package.GetFunctionsByPackage(opts.client, pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
fnList, err := _package.GetFunctionsByPackage(opts.Client(), pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function list")
|
||||
}
|
||||
@@ -193,7 +186,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
return errors.Errorf("Package is used by multiple functions, use --%v to force update", flagkey.PkgForce)
|
||||
}
|
||||
|
||||
newPkgMeta, err := _package.UpdatePackage(input, opts.client, pkg)
|
||||
newPkgMeta, err := _package.UpdatePackage(input, opts.Client(), pkg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error updating package '%v'", pkgName))
|
||||
}
|
||||
@@ -210,7 +203,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
fns = append(fns, fn)
|
||||
}
|
||||
}
|
||||
err = _package.UpdateFunctionPackageResourceVersion(opts.client, newPkgMeta, fns...)
|
||||
err = _package.UpdateFunctionPackageResourceVersion(opts.Client(), newPkgMeta, fns...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating function package reference resource version")
|
||||
}
|
||||
@@ -238,7 +231,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.client.FunctionUpdate(opts.function)
|
||||
_, err := opts.Client().V1().Function().Update(opts.function)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating function")
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/spec"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
@@ -36,19 +36,12 @@ import (
|
||||
)
|
||||
|
||||
type CreateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
trigger *fv1.HTTPTrigger
|
||||
}
|
||||
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&CreateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
@@ -85,7 +78,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
Namespace: fnNamespace,
|
||||
}
|
||||
|
||||
htTrigger, err := opts.client.HTTPTriggerGet(m)
|
||||
htTrigger, err := opts.Client().V1().HTTPTrigger().Get(m)
|
||||
if err != nil && !ferror.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
@@ -128,7 +121,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err = util.CheckFunctionExistence(opts.client, functionList, fnNamespace)
|
||||
err = util.CheckFunctionExistence(opts.Client(), functionList, fnNamespace)
|
||||
if err != nil {
|
||||
console.Warn(err.Error())
|
||||
}
|
||||
@@ -173,7 +166,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.client.HTTPTriggerCreate(opts.trigger)
|
||||
_, err := opts.Client().V1().HTTPTrigger().Create(opts.trigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "create HTTP trigger")
|
||||
}
|
||||
|
||||
@@ -23,29 +23,21 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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"
|
||||
)
|
||||
|
||||
type DeleteSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
triggerName string
|
||||
functionName string
|
||||
namespace string
|
||||
}
|
||||
|
||||
func Delete(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := DeleteSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&DeleteSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
@@ -69,7 +61,7 @@ func (opts *DeleteSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
triggers, err := opts.client.HTTPTriggerList(opts.namespace)
|
||||
triggers, err := opts.Client().V1().HTTPTrigger().List(opts.namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting HTTP trigger list")
|
||||
}
|
||||
@@ -90,7 +82,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
errs := utils.MultiErrorWithFormat()
|
||||
|
||||
for _, name := range triggersToDelete {
|
||||
err := opts.client.HTTPTriggerDelete(&metav1.ObjectMeta{
|
||||
err := opts.Client().V1().HTTPTrigger().Delete(&metav1.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: opts.namespace,
|
||||
})
|
||||
|
||||
@@ -26,25 +26,17 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 GetSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Get(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := GetSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&GetSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
@@ -56,7 +48,7 @@ func (opts *GetSubCommand) run(input cli.Input) error {
|
||||
Name: input.String(flagkey.HtName),
|
||||
Namespace: input.String(flagkey.NamespaceFunction),
|
||||
}
|
||||
ht, err := opts.client.HTTPTriggerGet(m)
|
||||
ht, err := opts.Client().V1().HTTPTrigger().Get(m)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting http trigger")
|
||||
}
|
||||
|
||||
@@ -20,25 +20,17 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ListSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
@@ -46,7 +38,7 @@ func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
hts, err := opts.client.HTTPTriggerList(input.String(flagkey.NamespaceTrigger))
|
||||
hts, err := opts.Client().V1().HTTPTrigger().List(input.String(flagkey.NamespaceTrigger))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing HTTP triggers")
|
||||
}
|
||||
|
||||
@@ -23,27 +23,20 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type UpdateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
trigger *fv1.HTTPTrigger
|
||||
}
|
||||
|
||||
func Update(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := UpdateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&UpdateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
@@ -58,7 +51,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
htName := input.String(flagkey.HtName)
|
||||
triggerNamespace := input.String(flagkey.NamespaceTrigger)
|
||||
|
||||
ht, err := opts.client.HTTPTriggerGet(&metav1.ObjectMeta{
|
||||
ht, err := opts.Client().V1().HTTPTrigger().Get(&metav1.ObjectMeta{
|
||||
Name: htName,
|
||||
Namespace: triggerNamespace,
|
||||
})
|
||||
@@ -77,7 +70,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
if input.IsSet(flagkey.HtFnName) {
|
||||
// get the functions and their weights if specified
|
||||
functionList := input.StringSlice(flagkey.HtFnName)
|
||||
err := util.CheckFunctionExistence(opts.client, functionList, triggerNamespace)
|
||||
err := util.CheckFunctionExistence(opts.Client(), functionList, triggerNamespace)
|
||||
if err != nil {
|
||||
console.Warn(err.Error())
|
||||
}
|
||||
@@ -120,7 +113,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.client.HTTPTriggerUpdate(opts.trigger)
|
||||
_, err := opts.Client().V1().HTTPTrigger().Update(opts.trigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating the HTTP trigger")
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/spec"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
@@ -33,19 +33,12 @@ import (
|
||||
)
|
||||
|
||||
type CreateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
watcher *fv1.KubernetesWatchTrigger
|
||||
}
|
||||
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&CreateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
@@ -119,7 +112,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.client.WatchCreate(opts.watcher)
|
||||
_, err := opts.Client().V1().KubeWatcher().Create(opts.watcher)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating kubewatch")
|
||||
}
|
||||
|
||||
@@ -22,27 +22,19 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
name string
|
||||
namespace string
|
||||
}
|
||||
|
||||
func Delete(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := DeleteSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&DeleteSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
@@ -60,7 +52,7 @@ func (opts *DeleteSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
err := opts.client.WatchDelete(&metav1.ObjectMeta{
|
||||
err := opts.Client().V1().KubeWatcher().Delete(&metav1.ObjectMeta{
|
||||
Name: opts.name,
|
||||
Namespace: opts.namespace,
|
||||
})
|
||||
|
||||
@@ -23,26 +23,18 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
namespace string
|
||||
}
|
||||
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ListSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
@@ -59,7 +51,7 @@ func (opts *ListSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
ws, err := opts.client.WatchList(opts.namespace)
|
||||
ws, err := opts.Client().V1().KubeWatcher().List(opts.namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing kubewatches")
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/spec"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
@@ -34,19 +34,12 @@ import (
|
||||
)
|
||||
|
||||
type CreateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
trigger *fv1.MessageQueueTrigger
|
||||
}
|
||||
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&CreateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
@@ -164,7 +157,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.client.MessageQueueTriggerCreate(opts.trigger)
|
||||
_, err := opts.Client().V1().MessageQueueTrigger().Create(opts.trigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "create message queue trigger")
|
||||
}
|
||||
|
||||
@@ -22,26 +22,18 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
metadata *metav1.ObjectMeta
|
||||
}
|
||||
|
||||
func Delete(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := DeleteSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&DeleteSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
@@ -61,7 +53,7 @@ func (opts *DeleteSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
err := opts.client.MessageQueueTriggerDelete(opts.metadata)
|
||||
err := opts.Client().V1().MessageQueueTrigger().Delete(opts.metadata)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error deleting message queue trigger")
|
||||
}
|
||||
|
||||
@@ -23,26 +23,18 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
namespace string
|
||||
}
|
||||
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ListSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
@@ -59,7 +51,7 @@ func (opts *ListSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
mqts, err := opts.client.MessageQueueTriggerList(input.String(flagkey.MqtMQType), opts.namespace)
|
||||
mqts, err := opts.Client().V1().MessageQueueTrigger().List(input.String(flagkey.MqtMQType), opts.namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing message queue triggers")
|
||||
}
|
||||
|
||||
@@ -23,26 +23,18 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 UpdateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
trigger *fv1.MessageQueueTrigger
|
||||
}
|
||||
|
||||
func Update(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := UpdateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&UpdateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
@@ -54,7 +46,7 @@ func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
mqt, err := opts.client.MessageQueueTriggerGet(&metav1.ObjectMeta{
|
||||
mqt, err := opts.Client().V1().MessageQueueTrigger().Get(&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.MqtName),
|
||||
Namespace: input.String(flagkey.NamespaceTrigger),
|
||||
})
|
||||
@@ -111,7 +103,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.client.MessageQueueTriggerUpdate(opts.trigger)
|
||||
_, err := opts.Client().V1().MessageQueueTrigger().Update(opts.trigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating message queue trigger")
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/spec"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
@@ -37,18 +38,11 @@ import (
|
||||
)
|
||||
|
||||
type CreateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&CreateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
@@ -114,14 +108,14 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
specFile = fmt.Sprintf("package-%v.yaml", pkgName)
|
||||
}
|
||||
|
||||
_, err := CreatePackage(input, opts.client, pkgName, pkgNamespace, envName, envNamespace,
|
||||
_, err := CreatePackage(input, opts.Client(), pkgName, pkgNamespace, envName, envNamespace,
|
||||
srcArchiveFiles, deployArchiveFiles, buildcmd, specDir, specFile, noZip)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: get all necessary value from CLI input directly
|
||||
func CreatePackage(input cli.Input, client *client.Client, pkgName string, pkgNamespace string, envName string, envNamespace string,
|
||||
func CreatePackage(input cli.Input, client client.Interface, pkgName string, pkgNamespace string, envName string, envNamespace string,
|
||||
srcArchiveFiles []string, deployArchiveFiles []string, buildcmd string, specDir string, specFile string, noZip bool) (*metav1.ObjectMeta, error) {
|
||||
|
||||
insecure := input.Bool(flagkey.PkgInsecure)
|
||||
@@ -201,7 +195,7 @@ func CreatePackage(input cli.Input, client *client.Client, pkgName string, pkgNa
|
||||
}
|
||||
return &pkg.Metadata, nil
|
||||
} else {
|
||||
pkgMetadata, err := client.PackageCreate(pkg)
|
||||
pkgMetadata, err := client.V1().Package().Create(pkg)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating package")
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ import (
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
name string
|
||||
namespace string
|
||||
deleteOrphans bool
|
||||
@@ -37,14 +37,7 @@ type DeleteSubCommand struct {
|
||||
}
|
||||
|
||||
func Delete(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := DeleteSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&DeleteSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
@@ -70,7 +63,7 @@ func (opts *DeleteSubCommand) complete(input cli.Input) error {
|
||||
|
||||
func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
if len(opts.name) != 0 {
|
||||
_, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
_, err := opts.Client().V1().Package().Get(&metav1.ObjectMeta{
|
||||
Namespace: opts.namespace,
|
||||
Name: opts.name,
|
||||
})
|
||||
@@ -78,7 +71,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
return errors.Wrap(err, "find package")
|
||||
}
|
||||
|
||||
fnList, err := GetFunctionsByPackage(opts.client, opts.name, opts.namespace)
|
||||
fnList, err := GetFunctionsByPackage(opts.Client(), opts.name, opts.namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -86,7 +79,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
if !opts.force && len(fnList) > 0 {
|
||||
return errors.New("Package is used by at least one function, use -f to force delete")
|
||||
}
|
||||
err = deletePackage(opts.client, opts.name, opts.namespace)
|
||||
err = deletePackage(opts.Client(), opts.name, opts.namespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -95,7 +88,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
|
||||
// TODO improve list speed when --orphan
|
||||
if opts.deleteOrphans {
|
||||
err := deleteOrphanPkgs(opts.client, opts.namespace)
|
||||
err := deleteOrphanPkgs(opts.Client(), opts.namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "deleting orphan packages")
|
||||
}
|
||||
@@ -105,8 +98,8 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteOrphanPkgs(client *client.Client, pkgNamespace string) error {
|
||||
pkgList, err := client.PackageList(pkgNamespace)
|
||||
func deleteOrphanPkgs(client client.Interface, pkgNamespace string) error {
|
||||
pkgList, err := client.V1().Package().List(pkgNamespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -127,8 +120,8 @@ func deleteOrphanPkgs(client *client.Client, pkgNamespace string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func deletePackage(client *client.Client, pkgName string, pkgNamespace string) error {
|
||||
return client.PackageDelete(&metav1.ObjectMeta{
|
||||
func deletePackage(client client.Interface, pkgName string, pkgNamespace string) error {
|
||||
return client.V1().Package().Delete(&metav1.ObjectMeta{
|
||||
Namespace: pkgNamespace,
|
||||
Name: pkgName,
|
||||
})
|
||||
|
||||
@@ -24,11 +24,10 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
pkgutil "github.com/fission/fission/pkg/fission-cli/cmd/package/util"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -37,7 +36,7 @@ const (
|
||||
)
|
||||
|
||||
type GetSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
name string
|
||||
namespace string
|
||||
output string
|
||||
@@ -45,27 +44,11 @@ type GetSubCommand struct {
|
||||
}
|
||||
|
||||
func GetSrc(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := GetSubCommand{
|
||||
client: c,
|
||||
archiveType: sourceArchive,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&GetSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func GetDeploy(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := GetSubCommand{
|
||||
client: c,
|
||||
archiveType: deployArchive,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&GetSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
@@ -84,7 +67,7 @@ func (opts *GetSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *GetSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
pkg, err := opts.Client().V1().Package().Get(&metav1.ObjectMeta{
|
||||
Namespace: opts.namespace,
|
||||
Name: opts.name,
|
||||
})
|
||||
@@ -101,7 +84,7 @@ func (opts *GetSubCommand) run(input cli.Input) error {
|
||||
if pkg.Spec.Deployment.Type == fv1.ArchiveTypeLiteral {
|
||||
reader = bytes.NewReader(archive.Literal)
|
||||
} else if pkg.Spec.Deployment.Type == fv1.ArchiveTypeUrl {
|
||||
readCloser, err := pkgutil.DownloadStoragesvcURL(opts.client, archive.URL)
|
||||
readCloser, err := pkgutil.DownloadStoragesvcURL(opts.Client(), archive.URL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -22,28 +22,20 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
pkgutil "github.com/fission/fission/pkg/fission-cli/cmd/package/util"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type InfoSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
name string
|
||||
namespace string
|
||||
}
|
||||
|
||||
func Info(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := InfoSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&InfoSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *InfoSubCommand) do(input cli.Input) error {
|
||||
@@ -61,7 +53,7 @@ func (opts *InfoSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *InfoSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
pkg, err := opts.Client().V1().Package().Get(&metav1.ObjectMeta{
|
||||
Namespace: opts.namespace,
|
||||
Name: opts.name,
|
||||
})
|
||||
|
||||
@@ -25,28 +25,20 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
listOrphans bool
|
||||
status string
|
||||
pkgNamespace string
|
||||
}
|
||||
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ListSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
@@ -66,7 +58,7 @@ func (opts *ListSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
pkgList, err := opts.client.PackageList(opts.pkgNamespace)
|
||||
pkgList, err := opts.Client().V1().Package().List(opts.pkgNamespace)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -83,7 +75,7 @@ func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
show := true
|
||||
// TODO improve list speed when --orphan
|
||||
if opts.listOrphans {
|
||||
fnList, err := GetFunctionsByPackage(opts.client, pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
fnList, err := GetFunctionsByPackage(opts.Client(), pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("get functions sharing package %s", pkg.Metadata.Name))
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ import (
|
||||
// create an archive upload spec in the specs directory; otherwise
|
||||
// upload the archive using client. noZip avoids zipping the
|
||||
// includeFiles, but is ignored if there's more than one includeFile.
|
||||
func CreateArchive(client *client.Client, includeFiles []string, noZip bool, insecure bool, checksum string, specDir string, specFile string) (*fv1.Archive, error) {
|
||||
func CreateArchive(client client.Interface, includeFiles []string, noZip bool, insecure bool, checksum string, specDir string, specFile string) (*fv1.Archive, error) {
|
||||
// get root dir
|
||||
var rootDir string
|
||||
var err error
|
||||
@@ -241,8 +241,8 @@ func archiveName(givenNameHint string, includedFiles []string) string {
|
||||
return fmt.Sprintf("%v-%v", util.KubifyName(includedFiles[0]), uniuri.NewLen(4))
|
||||
}
|
||||
|
||||
func GetFunctionsByPackage(client *client.Client, pkgName, pkgNamespace string) ([]fv1.Function, error) {
|
||||
fnList, err := client.FunctionList(pkgNamespace)
|
||||
func GetFunctionsByPackage(client client.Interface, pkgName, pkgNamespace string) ([]fv1.Function, error) {
|
||||
fnList, err := client.V1().Function().List(pkgNamespace)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -23,27 +23,19 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 RebuildSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
name string
|
||||
namespace string
|
||||
}
|
||||
|
||||
func Rebuild(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := RebuildSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&RebuildSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *RebuildSubCommand) do(input cli.Input) error {
|
||||
@@ -61,7 +53,7 @@ func (opts *RebuildSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *RebuildSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
pkg, err := opts.Client().V1().Package().Get(&metav1.ObjectMeta{
|
||||
Name: opts.name,
|
||||
Namespace: opts.namespace,
|
||||
})
|
||||
@@ -74,7 +66,7 @@ func (opts *RebuildSubCommand) run(input cli.Input) error {
|
||||
pkg.Metadata.Name, fv1.BuildStatusFailed))
|
||||
}
|
||||
|
||||
_, err = updatePackageStatus(opts.client, pkg, fv1.BuildStatusPending)
|
||||
_, err = updatePackageStatus(opts.Client(), pkg, fv1.BuildStatusPending)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "update package status")
|
||||
}
|
||||
|
||||
@@ -27,26 +27,19 @@ import (
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 UpdateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
pkgName string
|
||||
pkgNamespace string
|
||||
force bool
|
||||
}
|
||||
|
||||
func Update(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := UpdateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&UpdateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
@@ -65,7 +58,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
|
||||
pkg, err := opts.Client().V1().Package().Get(&metav1.ObjectMeta{
|
||||
Namespace: opts.pkgNamespace,
|
||||
Name: opts.pkgName,
|
||||
})
|
||||
@@ -75,7 +68,7 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
|
||||
forceUpdate := input.Bool(flagkey.PkgForce)
|
||||
|
||||
fnList, err := GetFunctionsByPackage(opts.client, pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
fnList, err := GetFunctionsByPackage(opts.Client(), pkg.Metadata.Name, pkg.Metadata.Namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function list")
|
||||
}
|
||||
@@ -84,13 +77,13 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
return errors.Errorf("package is used by multiple functions, use --%v to force update", flagkey.PkgForce)
|
||||
}
|
||||
|
||||
newPkgMeta, err := UpdatePackage(input, opts.client, pkg)
|
||||
newPkgMeta, err := UpdatePackage(input, opts.Client(), pkg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating package")
|
||||
}
|
||||
|
||||
if pkg.Metadata.ResourceVersion != newPkgMeta.ResourceVersion {
|
||||
err = UpdateFunctionPackageResourceVersion(opts.client, newPkgMeta, fnList...)
|
||||
err = UpdateFunctionPackageResourceVersion(opts.Client(), newPkgMeta, fnList...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating function package reference resource version")
|
||||
}
|
||||
@@ -99,7 +92,7 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdatePackage(input cli.Input, client *client.Client, pkg *fv1.Package) (*metav1.ObjectMeta, error) {
|
||||
func UpdatePackage(input cli.Input, client client.Interface, pkg *fv1.Package) (*metav1.ObjectMeta, error) {
|
||||
envName := input.String(flagkey.PkgEnvironment)
|
||||
envNamespace := input.String(flagkey.NamespaceEnvironment)
|
||||
srcArchiveFiles := input.StringSlice(flagkey.PkgSrcArchive)
|
||||
@@ -185,7 +178,7 @@ func UpdatePackage(input cli.Input, client *client.Client, pkg *fv1.Package) (*m
|
||||
}
|
||||
}
|
||||
|
||||
newPkgMeta, err := client.PackageUpdate(pkg)
|
||||
newPkgMeta, err := client.V1().Package().Update(pkg)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "update package")
|
||||
}
|
||||
@@ -195,13 +188,13 @@ func UpdatePackage(input cli.Input, client *client.Client, pkg *fv1.Package) (*m
|
||||
return newPkgMeta, err
|
||||
}
|
||||
|
||||
func UpdateFunctionPackageResourceVersion(client *client.Client, pkgMeta *metav1.ObjectMeta, fnList ...fv1.Function) error {
|
||||
func UpdateFunctionPackageResourceVersion(client client.Interface, pkgMeta *metav1.ObjectMeta, fnList ...fv1.Function) error {
|
||||
errs := &multierror.Error{}
|
||||
|
||||
// update resource version of package reference of functions that shared the same package
|
||||
for _, fn := range fnList {
|
||||
fn.Spec.Package.PackageRef.ResourceVersion = pkgMeta.ResourceVersion
|
||||
_, err := client.FunctionUpdate(&fn)
|
||||
_, err := client.V1().Function().Update(&fn)
|
||||
if err != nil {
|
||||
errs = multierror.Append(errs, errors.Wrapf(err, "error updating package resource version of function '%v'", fn.Metadata.Name))
|
||||
}
|
||||
@@ -210,14 +203,14 @@ func UpdateFunctionPackageResourceVersion(client *client.Client, pkgMeta *metav1
|
||||
return errs.ErrorOrNil()
|
||||
}
|
||||
|
||||
func updatePackageStatus(client *client.Client, pkg *fv1.Package, status fv1.BuildStatus) (*metav1.ObjectMeta, error) {
|
||||
func updatePackageStatus(client client.Interface, pkg *fv1.Package, status fv1.BuildStatus) (*metav1.ObjectMeta, error) {
|
||||
switch status {
|
||||
case fv1.BuildStatusNone, fv1.BuildStatusPending, fv1.BuildStatusRunning, fv1.BuildStatusSucceeded, fv1.CanaryConfigStatusAborted:
|
||||
pkg.Status = fv1.PackageStatus{
|
||||
BuildStatus: status,
|
||||
LastUpdateTimestamp: time.Now().UTC(),
|
||||
}
|
||||
pkg, err := client.PackageUpdate(pkg)
|
||||
pkg, err := client.V1().Package().Update(pkg)
|
||||
return pkg, err
|
||||
}
|
||||
return nil, errors.New("unknown package status")
|
||||
|
||||
@@ -37,7 +37,7 @@ import (
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
func UploadArchiveFile(ctx context.Context, client *client.Client, fileName string) (*fv1.Archive, error) {
|
||||
func UploadArchiveFile(ctx context.Context, client client.Interface, fileName string) (*fv1.Archive, error) {
|
||||
var archive fv1.Archive
|
||||
|
||||
size, err := utils.FileSize(fileName)
|
||||
@@ -52,7 +52,7 @@ func UploadArchiveFile(ctx context.Context, client *client.Client, fileName stri
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
u := strings.TrimSuffix(client.Url, "/") + "/proxy/storage"
|
||||
u := strings.TrimSuffix(client.ServerURL(), "/") + "/proxy/storage"
|
||||
ssClient := storageSvcClient.MakeClient(u)
|
||||
|
||||
// TODO add a progress bar
|
||||
@@ -61,7 +61,7 @@ func UploadArchiveFile(ctx context.Context, client *client.Client, fileName stri
|
||||
return nil, errors.Wrapf(err, "error uploading file %v", fileName)
|
||||
}
|
||||
|
||||
storageSvc, err := client.GetSvcURL("application=fission-storage")
|
||||
storageSvc, err := client.V1().Misc().GetSvcURL("application=fission-storage")
|
||||
storageSvcURL := "http://" + storageSvc
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error getting fission storage service name")
|
||||
@@ -161,14 +161,14 @@ func WriteArchiveToFile(fileName string, reader io.Reader) error {
|
||||
}
|
||||
|
||||
// DownloadStoragesvcURL downloads and return archive content with given storage service url
|
||||
func DownloadStoragesvcURL(client *client.Client, fileUrl string) (io.ReadCloser, error) {
|
||||
func DownloadStoragesvcURL(client client.Interface, fileUrl string) (io.ReadCloser, error) {
|
||||
u, err := url.ParseRequestURI(fileUrl)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// replace in-cluster storage service host with controller server url
|
||||
fileDownloadUrl := strings.TrimSuffix(client.Url, "/") + "/proxy/storage/" + u.RequestURI()
|
||||
fileDownloadUrl := strings.TrimSuffix(client.ServerURL(), "/") + "/proxy/storage/" + u.RequestURI()
|
||||
reader, err := DownloadURL(fileDownloadUrl)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, fmt.Sprintf("error downloading from storage service url: %v", fileUrl))
|
||||
|
||||
@@ -21,25 +21,17 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/plugin"
|
||||
)
|
||||
|
||||
type ListSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := &ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ListSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
pkgutil "github.com/fission/fission/pkg/fission-cli/cmd/package/util"
|
||||
spectypes "github.com/fission/fission/pkg/fission-cli/cmd/spec/types"
|
||||
"github.com/fission/fission/pkg/fission-cli/console"
|
||||
@@ -44,7 +45,7 @@ import (
|
||||
)
|
||||
|
||||
type ApplySubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
// Apply compares the specs in the spec/config/ directory to the
|
||||
@@ -57,14 +58,7 @@ type ApplySubCommand struct {
|
||||
// etc, while doing an apply, they will get a partially applied deployment. However,
|
||||
// they can retry their apply command once they're back online.
|
||||
func Apply(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ApplySubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ApplySubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ApplySubCommand) do(input cli.Input) error {
|
||||
@@ -83,7 +77,7 @@ func (opts *ApplySubCommand) run(input cli.Input) error {
|
||||
|
||||
if watchResources || waitForBuild {
|
||||
// init package build watcher
|
||||
pbw = makePackageBuildWatcher(opts.client)
|
||||
pbw = makePackageBuildWatcher(opts.Client())
|
||||
}
|
||||
|
||||
if watchResources {
|
||||
@@ -129,7 +123,7 @@ func (opts *ApplySubCommand) run(input cli.Input) error {
|
||||
}
|
||||
|
||||
// make changes to the cluster based on the specs
|
||||
pkgMetas, as, err := applyResources(opts.client, specDir, fr, deleteResources)
|
||||
pkgMetas, as, err := applyResources(opts.Client(), specDir, fr, deleteResources)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error applying specs")
|
||||
}
|
||||
@@ -258,7 +252,7 @@ func pluralize(num int, word string) string {
|
||||
}
|
||||
|
||||
// applyArchives figures out the set of archives that need to be uploaded, and uploads them.
|
||||
func applyArchives(fclient *client.Client, specDir string, fr *FissionResources) error {
|
||||
func applyArchives(fclient client.Interface, specDir string, fr *FissionResources) error {
|
||||
|
||||
// archive:// URL -> archive map.
|
||||
archiveFiles := make(map[string]fv1.Archive)
|
||||
@@ -278,7 +272,7 @@ func applyArchives(fclient *client.Client, specDir string, fr *FissionResources)
|
||||
|
||||
// get list of packages, make content-indexed map of available archives
|
||||
availableArchives := make(map[string]string) // (sha256 -> url)
|
||||
pkgs, err := fclient.PackageList(metav1.NamespaceAll)
|
||||
pkgs, err := fclient.V1().Package().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -332,7 +326,7 @@ func applyArchives(fclient *client.Client, specDir string, fr *FissionResources)
|
||||
}
|
||||
|
||||
// applyResources applies the given set of fission resources.
|
||||
func applyResources(fclient *client.Client, specDir string, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, map[string]ResourceApplyStatus, error) {
|
||||
func applyResources(fclient client.Interface, specDir string, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, map[string]ResourceApplyStatus, error) {
|
||||
|
||||
applyStatus := make(map[string]ResourceApplyStatus)
|
||||
|
||||
@@ -527,7 +521,7 @@ func hasDeploymentConfig(m *metav1.ObjectMeta, fr *FissionResources) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func waitForPackageBuild(fclient *client.Client, pkg *fv1.Package) (*fv1.Package, error) {
|
||||
func waitForPackageBuild(fclient client.Interface, pkg *fv1.Package) (*fv1.Package, error) {
|
||||
start := time.Now()
|
||||
for {
|
||||
if pkg.Status.BuildStatus != fv1.BuildStatusRunning {
|
||||
@@ -541,16 +535,16 @@ func waitForPackageBuild(fclient *client.Client, pkg *fv1.Package) (*fv1.Package
|
||||
time.Sleep(time.Second)
|
||||
|
||||
var err error
|
||||
pkg, err = fclient.PackageGet(&pkg.Metadata)
|
||||
pkg, err = fclient.V1().Package().Get(&pkg.Metadata)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func applyPackages(fclient *client.Client, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
func applyPackages(fclient client.Interface, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
// get list
|
||||
allObjs, err := fclient.PackageList(metav1.NamespaceAll)
|
||||
allObjs, err := fclient.V1().Package().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -620,7 +614,7 @@ func applyPackages(fclient *client.Client, fr *FissionResources, delete bool) (m
|
||||
pkg.Status.BuildStatus = fv1.BuildStatusPending
|
||||
}
|
||||
|
||||
newmeta, err := fclient.PackageUpdate(pkg)
|
||||
newmeta, err := fclient.V1().Package().Update(pkg)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
// TODO check for resourceVersion conflict errors and retry
|
||||
@@ -631,7 +625,7 @@ func applyPackages(fclient *client.Client, fr *FissionResources, delete bool) (m
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
newmeta, err := fclient.PackageCreate(&o)
|
||||
newmeta, err := fclient.V1().Package().Create(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -646,7 +640,7 @@ func applyPackages(fclient *client.Client, fr *FissionResources, delete bool) (m
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
if !wanted {
|
||||
err := fclient.PackageDelete(&o.Metadata)
|
||||
err := fclient.V1().Package().Delete(&o.Metadata)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -659,9 +653,9 @@ func applyPackages(fclient *client.Client, fr *FissionResources, delete bool) (m
|
||||
return metadataMap, &ras, nil
|
||||
}
|
||||
|
||||
func applyFunctions(fclient *client.Client, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
func applyFunctions(fclient client.Interface, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
// get list
|
||||
allObjs, err := fclient.FunctionList(metav1.NamespaceAll)
|
||||
allObjs, err := fclient.V1().Function().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -704,7 +698,7 @@ func applyFunctions(fclient *client.Client, fr *FissionResources, delete bool) (
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
newmeta, err := fclient.FunctionUpdate(&o)
|
||||
newmeta, err := fclient.V1().Function().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -714,7 +708,7 @@ func applyFunctions(fclient *client.Client, fr *FissionResources, delete bool) (
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
newmeta, err := fclient.FunctionCreate(&o)
|
||||
newmeta, err := fclient.V1().Function().Create(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -729,7 +723,7 @@ func applyFunctions(fclient *client.Client, fr *FissionResources, delete bool) (
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
if !wanted {
|
||||
err := fclient.FunctionDelete(&o.Metadata)
|
||||
err := fclient.V1().Function().Delete(&o.Metadata)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -742,9 +736,9 @@ func applyFunctions(fclient *client.Client, fr *FissionResources, delete bool) (
|
||||
return metadataMap, &ras, nil
|
||||
}
|
||||
|
||||
func applyEnvironments(fclient *client.Client, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
func applyEnvironments(fclient client.Interface, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
// get list
|
||||
allObjs, err := fclient.EnvironmentList(metav1.NamespaceAll)
|
||||
allObjs, err := fclient.V1().Environment().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -787,7 +781,7 @@ func applyEnvironments(fclient *client.Client, fr *FissionResources, delete bool
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
newmeta, err := fclient.EnvironmentUpdate(&o)
|
||||
newmeta, err := fclient.V1().Environment().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -797,7 +791,7 @@ func applyEnvironments(fclient *client.Client, fr *FissionResources, delete bool
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
newmeta, err := fclient.EnvironmentCreate(&o)
|
||||
newmeta, err := fclient.V1().Environment().Create(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -812,7 +806,7 @@ func applyEnvironments(fclient *client.Client, fr *FissionResources, delete bool
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
if !wanted {
|
||||
err := fclient.EnvironmentDelete(&o.Metadata)
|
||||
err := fclient.V1().Environment().Delete(&o.Metadata)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -825,9 +819,9 @@ func applyEnvironments(fclient *client.Client, fr *FissionResources, delete bool
|
||||
return metadataMap, &ras, nil
|
||||
}
|
||||
|
||||
func applyHTTPTriggers(fclient *client.Client, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
func applyHTTPTriggers(fclient client.Interface, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
// get list
|
||||
allObjs, err := fclient.HTTPTriggerList(metav1.NamespaceAll)
|
||||
allObjs, err := fclient.V1().HTTPTrigger().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -870,7 +864,7 @@ func applyHTTPTriggers(fclient *client.Client, fr *FissionResources, delete bool
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
newmeta, err := fclient.HTTPTriggerUpdate(&o)
|
||||
newmeta, err := fclient.V1().HTTPTrigger().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -880,7 +874,7 @@ func applyHTTPTriggers(fclient *client.Client, fr *FissionResources, delete bool
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
newmeta, err := fclient.HTTPTriggerCreate(&o)
|
||||
newmeta, err := fclient.V1().HTTPTrigger().Create(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -895,7 +889,7 @@ func applyHTTPTriggers(fclient *client.Client, fr *FissionResources, delete bool
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
if !wanted {
|
||||
err := fclient.HTTPTriggerDelete(&o.Metadata)
|
||||
err := fclient.V1().HTTPTrigger().Delete(&o.Metadata)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -908,9 +902,9 @@ func applyHTTPTriggers(fclient *client.Client, fr *FissionResources, delete bool
|
||||
return metadataMap, &ras, nil
|
||||
}
|
||||
|
||||
func applyKubernetesWatchTriggers(fclient *client.Client, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
func applyKubernetesWatchTriggers(fclient client.Interface, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
// get list
|
||||
allObjs, err := fclient.WatchList(metav1.NamespaceAll)
|
||||
allObjs, err := fclient.V1().KubeWatcher().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -953,7 +947,7 @@ func applyKubernetesWatchTriggers(fclient *client.Client, fr *FissionResources,
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
newmeta, err := fclient.WatchUpdate(&o)
|
||||
newmeta, err := fclient.V1().KubeWatcher().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -963,7 +957,7 @@ func applyKubernetesWatchTriggers(fclient *client.Client, fr *FissionResources,
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
newmeta, err := fclient.WatchCreate(&o)
|
||||
newmeta, err := fclient.V1().KubeWatcher().Create(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -978,7 +972,7 @@ func applyKubernetesWatchTriggers(fclient *client.Client, fr *FissionResources,
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
if !wanted {
|
||||
err := fclient.WatchDelete(&o.Metadata)
|
||||
err := fclient.V1().KubeWatcher().Delete(&o.Metadata)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -991,9 +985,9 @@ func applyKubernetesWatchTriggers(fclient *client.Client, fr *FissionResources,
|
||||
return metadataMap, &ras, nil
|
||||
}
|
||||
|
||||
func applyTimeTriggers(fclient *client.Client, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
func applyTimeTriggers(fclient client.Interface, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
// get list
|
||||
allObjs, err := fclient.TimeTriggerList(metav1.NamespaceAll)
|
||||
allObjs, err := fclient.V1().TimeTrigger().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -1036,7 +1030,7 @@ func applyTimeTriggers(fclient *client.Client, fr *FissionResources, delete bool
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
newmeta, err := fclient.TimeTriggerUpdate(&o)
|
||||
newmeta, err := fclient.V1().TimeTrigger().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -1046,7 +1040,7 @@ func applyTimeTriggers(fclient *client.Client, fr *FissionResources, delete bool
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
newmeta, err := fclient.TimeTriggerCreate(&o)
|
||||
newmeta, err := fclient.V1().TimeTrigger().Create(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -1061,7 +1055,7 @@ func applyTimeTriggers(fclient *client.Client, fr *FissionResources, delete bool
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
if !wanted {
|
||||
err := fclient.TimeTriggerDelete(&o.Metadata)
|
||||
err := fclient.V1().TimeTrigger().Delete(&o.Metadata)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -1074,9 +1068,9 @@ func applyTimeTriggers(fclient *client.Client, fr *FissionResources, delete bool
|
||||
return metadataMap, &ras, nil
|
||||
}
|
||||
|
||||
func applyMessageQueueTriggers(fclient *client.Client, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
func applyMessageQueueTriggers(fclient client.Interface, fr *FissionResources, delete bool) (map[string]metav1.ObjectMeta, *ResourceApplyStatus, error) {
|
||||
// get list
|
||||
allObjs, err := fclient.MessageQueueTriggerList("", metav1.NamespaceAll)
|
||||
allObjs, err := fclient.V1().MessageQueueTrigger().List("", metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -1119,7 +1113,7 @@ func applyMessageQueueTriggers(fclient *client.Client, fr *FissionResources, del
|
||||
} else {
|
||||
// update
|
||||
o.Metadata.ResourceVersion = existingObj.Metadata.ResourceVersion
|
||||
newmeta, err := fclient.MessageQueueTriggerUpdate(&o)
|
||||
newmeta, err := fclient.V1().MessageQueueTrigger().Update(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -1129,7 +1123,7 @@ func applyMessageQueueTriggers(fclient *client.Client, fr *FissionResources, del
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
newmeta, err := fclient.MessageQueueTriggerCreate(&o)
|
||||
newmeta, err := fclient.V1().MessageQueueTrigger().Create(&o)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -1144,7 +1138,7 @@ func applyMessageQueueTriggers(fclient *client.Client, fr *FissionResources, del
|
||||
for _, o := range objs {
|
||||
_, wanted := desired[mapKey(&o.Metadata)]
|
||||
if !wanted {
|
||||
err := fclient.MessageQueueTriggerDelete(&o.Metadata)
|
||||
err := fclient.V1().MessageQueueTrigger().Delete(&o.Metadata)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ type (
|
||||
// packageBuildWatcher is used to watch a set of in-progress builds.
|
||||
packageBuildWatcher struct {
|
||||
// fission client
|
||||
fclient *client.Client
|
||||
fclient client.Interface
|
||||
|
||||
// set of packages already printed, ensures we don't duplicate the notifications
|
||||
finished map[string]bool
|
||||
@@ -44,7 +44,7 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func makePackageBuildWatcher(fclient *client.Client) *packageBuildWatcher {
|
||||
func makePackageBuildWatcher(fclient client.Interface) *packageBuildWatcher {
|
||||
return &packageBuildWatcher{
|
||||
fclient: fclient,
|
||||
finished: make(map[string]bool),
|
||||
@@ -68,7 +68,7 @@ func (w *packageBuildWatcher) watch(ctx context.Context) {
|
||||
}
|
||||
|
||||
// pull list of packages (TODO: convert to watch)
|
||||
pkgs, err := w.fclient.PackageList(metav1.NamespaceAll)
|
||||
pkgs, err := w.fclient.V1().Package().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
fmt.Printf("Getting list of packages: %v", err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -19,25 +19,18 @@ package spec
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type DestroySubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
// Destroy destroys everything in the spec.
|
||||
func Destroy(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := &DestroySubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&DestroySubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *DestroySubCommand) do(input cli.Input) error {
|
||||
@@ -59,7 +52,7 @@ func (opts *DestroySubCommand) run(input cli.Input) error {
|
||||
emptyFr.DeploymentConfig = fr.DeploymentConfig
|
||||
|
||||
// "apply" the empty state
|
||||
_, _, err = applyResources(opts.client, specDir, &emptyFr, true)
|
||||
_, _, err = applyResources(opts.Client(), specDir, &emptyFr, true)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error deleting resources")
|
||||
}
|
||||
|
||||
@@ -26,27 +26,20 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
spectypes "github.com/fission/fission/pkg/fission-cli/cmd/spec/types"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type InitSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
deployConfig *spectypes.DeploymentConfig
|
||||
}
|
||||
|
||||
func Init(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := InitSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&InitSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *InitSubCommand) do(input cli.Input) error {
|
||||
|
||||
@@ -378,7 +378,7 @@ func (fr *FissionResources) Validate(input cli.Input) error {
|
||||
return err
|
||||
}
|
||||
for _, cm := range f.Spec.ConfigMaps {
|
||||
_, err := client.ConfigMapGet(&metav1.ObjectMeta{
|
||||
_, err := client.V1().Misc().ConfigMapGet(&metav1.ObjectMeta{
|
||||
Name: cm.Name,
|
||||
Namespace: cm.Namespace,
|
||||
})
|
||||
@@ -388,7 +388,7 @@ func (fr *FissionResources) Validate(input cli.Input) error {
|
||||
}
|
||||
|
||||
for _, s := range f.Spec.Secrets {
|
||||
_, err := client.SecretGet(&metav1.ObjectMeta{
|
||||
_, err := client.V1().Misc().SecretGet(&metav1.ObjectMeta{
|
||||
Name: s.Name,
|
||||
Namespace: s.Namespace,
|
||||
})
|
||||
|
||||
@@ -27,26 +27,19 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type ValidateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
// Validate parses a set of specs and checks for references to
|
||||
// resources that don't exist.
|
||||
func Validate(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := &ValidateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ValidateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ValidateSubCommand) do(input cli.Input) error {
|
||||
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd/support/resources"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
@@ -39,18 +39,11 @@ const (
|
||||
)
|
||||
|
||||
type DumpSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Dump(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := &DumpSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&DumpSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *DumpSubCommand) do(input cli.Input) error {
|
||||
@@ -86,7 +79,7 @@ func (opts *DumpSubCommand) do(input cli.Input) error {
|
||||
"kubernetes-nodes": resources.NewKubernetesObjectDumper(k8sClient, resources.KubernetesNode, ""),
|
||||
|
||||
// fission info
|
||||
"fission-version": resources.NewFissionVersion(opts.client),
|
||||
"fission-version": resources.NewFissionVersion(opts.Client()),
|
||||
|
||||
// fission component logs & spec
|
||||
"fission-components-svc-spec": resources.NewKubernetesObjectDumper(k8sClient, resources.KubernetesService,
|
||||
@@ -113,13 +106,13 @@ func (opts *DumpSubCommand) do(input cli.Input) error {
|
||||
"fission-function-pod-log": resources.NewKubernetesPodLogDumper(k8sClient, "executorType in (poolmgr, newdeploy)"),
|
||||
|
||||
// CRD resources
|
||||
"fission-crd-packages": resources.NewCrdDumper(opts.client, resources.CrdPackage),
|
||||
"fission-crd-environments": resources.NewCrdDumper(opts.client, resources.CrdEnvironment),
|
||||
"fission-crd-functions": resources.NewCrdDumper(opts.client, resources.CrdFunction),
|
||||
"fission-crd-httptriggers": resources.NewCrdDumper(opts.client, resources.CrdHttpTrigger),
|
||||
"fission-crd-kubewatchers": resources.NewCrdDumper(opts.client, resources.CrdKubeWatcher),
|
||||
"fission-crd-mqtriggers": resources.NewCrdDumper(opts.client, resources.CrdMessageQueueTrigger),
|
||||
"fission-crd-timetriggers": resources.NewCrdDumper(opts.client, resources.CrdTimeTrigger),
|
||||
"fission-crd-packages": resources.NewCrdDumper(opts.Client(), resources.CrdPackage),
|
||||
"fission-crd-environments": resources.NewCrdDumper(opts.Client(), resources.CrdEnvironment),
|
||||
"fission-crd-functions": resources.NewCrdDumper(opts.Client(), resources.CrdFunction),
|
||||
"fission-crd-httptriggers": resources.NewCrdDumper(opts.Client(), resources.CrdHttpTrigger),
|
||||
"fission-crd-kubewatchers": resources.NewCrdDumper(opts.Client(), resources.CrdKubeWatcher),
|
||||
"fission-crd-mqtriggers": resources.NewCrdDumper(opts.Client(), resources.CrdMessageQueueTrigger),
|
||||
"fission-crd-timetriggers": resources.NewCrdDumper(opts.Client(), resources.CrdTimeTrigger),
|
||||
}
|
||||
|
||||
dumpName := fmt.Sprintf("%v_%v", DUMP_ARCHIVE_PREFIX, time.Now().Unix())
|
||||
|
||||
@@ -39,11 +39,11 @@ const (
|
||||
)
|
||||
|
||||
type CrdDumper struct {
|
||||
client *client.Client
|
||||
client client.Interface
|
||||
crdType string
|
||||
}
|
||||
|
||||
func NewCrdDumper(client *client.Client, crdType string) Resource {
|
||||
func NewCrdDumper(client client.Interface, crdType string) Resource {
|
||||
return CrdDumper{client: client, crdType: crdType}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
|
||||
switch res.crdType {
|
||||
case CrdEnvironment:
|
||||
items, err := res.client.EnvironmentList(metav1.NamespaceAll)
|
||||
items, err := res.client.V1().Environment().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
console.Warn(fmt.Sprintf("Error getting %v list: %v", res.crdType, err))
|
||||
return
|
||||
@@ -63,7 +63,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
case CrdFunction:
|
||||
items, err := res.client.FunctionList(metav1.NamespaceAll)
|
||||
items, err := res.client.V1().Function().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
console.Warn(fmt.Sprintf("Error getting %v list: %v", res.crdType, err))
|
||||
return
|
||||
@@ -75,7 +75,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
case CrdPackage:
|
||||
items, err := res.client.PackageList(metav1.NamespaceAll)
|
||||
items, err := res.client.V1().Package().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
console.Warn(fmt.Sprintf("Error getting %v list: %v", res.crdType, err))
|
||||
return
|
||||
@@ -88,7 +88,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
case CrdHttpTrigger:
|
||||
items, err := res.client.HTTPTriggerList(metav1.NamespaceAll)
|
||||
items, err := res.client.V1().HTTPTrigger().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
console.Warn(fmt.Sprintf("Error getting %v list: %v", res.crdType, err))
|
||||
return
|
||||
@@ -100,7 +100,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
case CrdKubeWatcher:
|
||||
items, err := res.client.WatchList(metav1.NamespaceAll)
|
||||
items, err := res.client.V1().KubeWatcher().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
console.Warn(fmt.Sprintf("Error getting %v list: %v", res.crdType, err))
|
||||
return
|
||||
@@ -115,7 +115,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
var triggers []fv1.MessageQueueTrigger
|
||||
|
||||
for _, mqType := range []string{types.MessageQueueTypeNats, types.MessageQueueTypeASQ} {
|
||||
l, err := res.client.MessageQueueTriggerList(mqType, metav1.NamespaceAll)
|
||||
l, err := res.client.V1().MessageQueueTrigger().List(mqType, metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
console.Warn(fmt.Sprintf("Error getting %v list: %v", res.crdType, err))
|
||||
break
|
||||
@@ -129,7 +129,7 @@ func (res CrdDumper) Dump(dumpDir string) {
|
||||
}
|
||||
|
||||
case CrdTimeTrigger:
|
||||
items, err := res.client.TimeTriggerList(metav1.NamespaceAll)
|
||||
items, err := res.client.V1().TimeTrigger().List(metav1.NamespaceAll)
|
||||
if err != nil {
|
||||
console.Warn(fmt.Sprintf("Error getting %v list: %v", res.crdType, err))
|
||||
return
|
||||
|
||||
@@ -25,10 +25,10 @@ import (
|
||||
)
|
||||
|
||||
type FissionVersion struct {
|
||||
client *client.Client
|
||||
client client.Interface
|
||||
}
|
||||
|
||||
func NewFissionVersion(client *client.Client) Resource {
|
||||
func NewFissionVersion(client client.Interface) Resource {
|
||||
return FissionVersion{client: client}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package timetrigger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -35,19 +36,12 @@ import (
|
||||
)
|
||||
|
||||
type CreateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
trigger *fv1.TimeTrigger
|
||||
}
|
||||
|
||||
func Create(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := CreateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&CreateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *CreateSubCommand) do(input cli.Input) error {
|
||||
@@ -126,14 +120,14 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.client.TimeTriggerCreate(opts.trigger)
|
||||
_, err := opts.Client().V1().TimeTrigger().Create(opts.trigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating Time trigger")
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' created\n", opts.trigger.Metadata.Name)
|
||||
|
||||
t, err := getAPITimeInfo(opts.client)
|
||||
t, err := getAPITimeInfo(opts.Client())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -146,8 +140,8 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getAPITimeInfo(client *client.Client) (time.Time, error) {
|
||||
serverInfo, err := client.ServerInfo()
|
||||
func getAPITimeInfo(client client.Interface) (time.Time, error) {
|
||||
serverInfo, err := client.V1().Misc().ServerInfo()
|
||||
if err != nil {
|
||||
return time.Time{}, errors.Errorf("Error syncing server time information: %v", err)
|
||||
}
|
||||
|
||||
@@ -22,25 +22,17 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Delete(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := DeleteSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&DeleteSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
@@ -49,7 +41,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
Namespace: input.String(flagkey.NamespaceTrigger),
|
||||
}
|
||||
|
||||
err := opts.client.TimeTriggerDelete(m)
|
||||
err := opts.Client().V1().TimeTrigger().Delete(m)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error deleting trigger")
|
||||
}
|
||||
|
||||
@@ -21,31 +21,24 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"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"
|
||||
)
|
||||
|
||||
type ListSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func List(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ListSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ListSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
ttNs := input.String(flagkey.NamespaceTrigger)
|
||||
tts, err := opts.client.TimeTriggerList(ttNs)
|
||||
tts, err := opts.Client().V1().TimeTrigger().List(ttNs)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "list Time triggers")
|
||||
}
|
||||
|
||||
@@ -19,25 +19,17 @@ package timetrigger
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 ShowSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Show(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := ShowSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&ShowSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *ShowSubCommand) do(input cli.Input) error {
|
||||
@@ -51,7 +43,7 @@ func (opts *ShowSubCommand) run(flaginput cli.Input) error {
|
||||
return errors.New("need a cron spec like '0 30 * * * *', '@every 1h30m', or '@hourly'; use --cron")
|
||||
}
|
||||
|
||||
t, err := getAPITimeInfo(opts.client)
|
||||
t, err := getAPITimeInfo(opts.Client())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -23,26 +23,18 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"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 UpdateSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
trigger *fv1.TimeTrigger
|
||||
}
|
||||
|
||||
func Update(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := UpdateSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&UpdateSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
@@ -54,7 +46,7 @@ func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
tt, err := opts.client.TimeTriggerGet(&metav1.ObjectMeta{
|
||||
tt, err := opts.Client().V1().TimeTrigger().Get(&metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.TtName),
|
||||
Namespace: input.String(flagkey.NamespaceTrigger),
|
||||
})
|
||||
@@ -88,14 +80,14 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
|
||||
func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.client.TimeTriggerUpdate(opts.trigger)
|
||||
_, err := opts.Client().V1().TimeTrigger().Update(opts.trigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating Time trigger")
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' updated\n", opts.trigger.Metadata.Name)
|
||||
|
||||
t, err := getAPITimeInfo(opts.client)
|
||||
t, err := getAPITimeInfo(opts.Client())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -22,28 +22,21 @@ import (
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/fission/fission/pkg/controller/client"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
)
|
||||
|
||||
type VersionSubCommand struct {
|
||||
client *client.Client
|
||||
cmd.CommandActioner
|
||||
}
|
||||
|
||||
func Version(input cli.Input) error {
|
||||
c, err := util.GetServer(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts := &VersionSubCommand{
|
||||
client: c,
|
||||
}
|
||||
return opts.do(input)
|
||||
return (&VersionSubCommand{}).do(input)
|
||||
}
|
||||
|
||||
func (opts *VersionSubCommand) do(input cli.Input) error {
|
||||
ver := util.GetVersion(opts.client)
|
||||
ver := util.GetVersion(opts.Client())
|
||||
bs, err := yaml.Marshal(ver)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error formatting versions")
|
||||
|
||||
Reference in New Issue
Block a user