Remove github.com/pkg/errors with appropriate replacements (#3172)
* errors.Wrap* removal Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * remove errors.Errorf Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Remove remaining calls Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Few more errors Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Fix golint errors Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> --------- Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -17,10 +17,10 @@ limitations under the License.
|
||||
package canaryconfig
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -57,7 +57,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
|
||||
|
||||
_, fnNs, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in creating canaryconfig")
|
||||
return fmt.Errorf("error in creating canaryconfig: %w", err)
|
||||
}
|
||||
incrementStep := input.Int(flagkey.CanaryWeightIncrement)
|
||||
failureThreshold := input.Int(flagkey.CanaryFailureThreshold)
|
||||
@@ -66,13 +66,13 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
|
||||
// check for time parsing
|
||||
_, err = time.ParseDuration(incrementInterval)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error parsing time duration")
|
||||
return fmt.Errorf("error parsing time duration: %w", err)
|
||||
}
|
||||
|
||||
// check that the trigger exists in the same namespace.
|
||||
htTrigger, err := opts.Client().FissionClientSet.CoreV1().HTTPTriggers(fnNs).Get(input.Context(), ht, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error finding http trigger referenced in the canary config")
|
||||
return fmt.Errorf("error finding http trigger referenced in the canary config: %w", err)
|
||||
}
|
||||
|
||||
// check that the trigger has function reference type function weights
|
||||
@@ -95,7 +95,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
|
||||
fnList := []string{newFunc, oldFunc}
|
||||
err = util.CheckFunctionExistence(input.Context(), opts.Client(), fnList, fnNs)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error checking functions existence")
|
||||
return fmt.Errorf("error checking functions existence: %w", err)
|
||||
}
|
||||
|
||||
// finally create canaryCfg in the same namespace as the functions referenced
|
||||
@@ -124,7 +124,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
|
||||
func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(opts.canary.ObjectMeta.Namespace).Create(input.Context(), opts.canary, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating canary config")
|
||||
return fmt.Errorf("error creating canary config: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("canary config '%s' created\n", opts.canary.ObjectMeta.Name)
|
||||
|
||||
@@ -19,7 +19,6 @@ package canaryconfig
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -39,7 +38,7 @@ func Delete(input cli.Input) error {
|
||||
func (opts *DeleteSubCommand) run(input cli.Input) (err error) {
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceCanary)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting canaryConfig ")
|
||||
return fmt.Errorf("error in deleting canaryConfig: %w", err)
|
||||
}
|
||||
|
||||
err = opts.Client().FissionClientSet.CoreV1().CanaryConfigs(namespace).Delete(input.Context(), input.String(flagkey.CanaryName), metav1.DeleteOptions{})
|
||||
@@ -47,7 +46,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) (err error) {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting canary config")
|
||||
return fmt.Errorf("error deleting canary config: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("canaryconfig '%v.%v' deleted\n", input.String(flagkey.CanaryName), namespace)
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -41,12 +40,12 @@ func (opts *GetSubCommand) run(input cli.Input) (err error) {
|
||||
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceCanary)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting canary config")
|
||||
return fmt.Errorf("error getting canary config: %w", err)
|
||||
}
|
||||
|
||||
canaryCfg, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(namespace).Get(input.Context(), input.String(flagkey.CanaryName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting canary config")
|
||||
return fmt.Errorf("error getting canary config: %w", err)
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -49,7 +48,7 @@ func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
func (opts *ListSubCommand) complete(input cli.Input) (err error) {
|
||||
_, opts.namespace, err = opts.GetResourceNamespace(input, flagkey.NamespaceCanary)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in listing canary config ")
|
||||
return fmt.Errorf("error in listing canary config: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -62,7 +61,7 @@ func (opts *ListSubCommand) run(input cli.Input) (err error) {
|
||||
canaryCfgs, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(opts.namespace).List(input.Context(), metav1.ListOptions{})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing canary config")
|
||||
return fmt.Errorf("error listing canary config: %w", err)
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -50,7 +49,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
|
||||
// get the current config
|
||||
_, ns, err := opts.GetResourceNamespace(input, flagkey.NamespaceCanary)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating canary config")
|
||||
return fmt.Errorf("error updating canary config: %w", err)
|
||||
}
|
||||
incrementStep := input.Int(flagkey.CanaryWeightIncrement)
|
||||
failureThreshold := input.Int(flagkey.CanaryFailureThreshold)
|
||||
@@ -59,12 +58,12 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
|
||||
// check for time parsing
|
||||
_, err = time.ParseDuration(incrementInterval)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error parsing time duration")
|
||||
return fmt.Errorf("error parsing time duration: %w", err)
|
||||
}
|
||||
|
||||
canaryCfg, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(ns).Get(input.Context(), input.String(flagkey.CanaryName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting canary config")
|
||||
return fmt.Errorf("error getting canary config: %w", err)
|
||||
}
|
||||
|
||||
var updateNeeded bool
|
||||
@@ -93,7 +92,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
|
||||
func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().CanaryConfigs(opts.canary.ObjectMeta.Namespace).Update(input.Context(), opts.canary, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating canary config")
|
||||
return fmt.Errorf("error updating canary config: %w", err)
|
||||
}
|
||||
fmt.Printf("canary config '%v' updated\n", opts.canary.ObjectMeta.Name)
|
||||
return nil
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -101,7 +100,7 @@ func (opts *CreateSubCommand) run(input cli.Input) (err error) {
|
||||
specFile := fmt.Sprintf("env-%v.yaml", opts.env.ObjectMeta.Name)
|
||||
err = spec.SpecSave(*opts.env, specFile, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving environment spec")
|
||||
return fmt.Errorf("error saving environment spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -110,7 +109,7 @@ func (opts *CreateSubCommand) run(input cli.Input) (err error) {
|
||||
|
||||
_, err = opts.Client().FissionClientSet.CoreV1().Environments(opts.env.Namespace).Create(input.Context(), opts.env, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating resource")
|
||||
return fmt.Errorf("error creating resource: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("environment '%v' created\n", opts.env.ObjectMeta.Name)
|
||||
|
||||
@@ -17,9 +17,9 @@ limitations under the License.
|
||||
package environment
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -41,7 +41,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) (err error) {
|
||||
|
||||
_, currentContextNS, err := opts.GetResourceNamespace(input, flagkey.NamespaceEnvironment)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating environment")
|
||||
return fmt.Errorf("error creating environment: %w", err)
|
||||
}
|
||||
console.Verbose(2, "Searching for resource in %s Namespace", currentContextNS)
|
||||
envName := input.String(flagkey.EnvName)
|
||||
@@ -49,7 +49,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) (err error) {
|
||||
if !input.Bool(flagkey.EnvForce) {
|
||||
fns, err := opts.Client().FissionClientSet.CoreV1().Functions(metav1.NamespaceAll).List(input.Context(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error getting functions wrt environment.")
|
||||
return fmt.Errorf("Error getting functions wrt environment.: %w", err)
|
||||
}
|
||||
|
||||
for _, fn := range fns.Items {
|
||||
@@ -65,7 +65,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) (err error) {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && kerrors.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting environment")
|
||||
return fmt.Errorf("error deleting environment: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("environment '%s' deleted\n", envName)
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -41,12 +40,12 @@ func (opts *GetSubCommand) do(input cli.Input) (err error) {
|
||||
|
||||
_, currentNS, err := opts.GetResourceNamespace(input, flagkey.NamespaceEnvironment)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating environment")
|
||||
return fmt.Errorf("error creating environment: %w", err)
|
||||
}
|
||||
|
||||
env, err := opts.Client().FissionClientSet.CoreV1().Environments(currentNS).Get(input.Context(), input.String(flagkey.EnvName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting environment")
|
||||
return fmt.Errorf("error getting environment: %w", err)
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -41,7 +40,7 @@ func (opts *ListSubCommand) do(input cli.Input) (err error) {
|
||||
|
||||
_, currentNS, err := opts.GetResourceNamespace(input, flagkey.NamespaceEnvironment)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating environment")
|
||||
return fmt.Errorf("error creating environment: %w", err)
|
||||
}
|
||||
|
||||
if input.Bool(flagkey.AllNamespaces) {
|
||||
@@ -50,7 +49,7 @@ func (opts *ListSubCommand) do(input cli.Input) (err error) {
|
||||
|
||||
response, err := opts.Client().FissionClientSet.CoreV1().Environments(currentNS).List(input.Context(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing environments")
|
||||
return fmt.Errorf("error listing environments: %w", err)
|
||||
}
|
||||
|
||||
envs := response.Items
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
||||
@@ -44,12 +43,12 @@ func (opts *ListPodsSubCommand) do(input cli.Input) (err error) {
|
||||
|
||||
_, currentNS, err := opts.GetResourceNamespace(input, flagkey.NamespaceEnvironment)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating environment")
|
||||
return fmt.Errorf("error creating environment: %w", err)
|
||||
}
|
||||
|
||||
_, err = opts.Client().FissionClientSet.CoreV1().Environments(currentNS).Get(input.Context(), input.String(flagkey.EnvName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting environment")
|
||||
return fmt.Errorf("error getting environment: %w", err)
|
||||
}
|
||||
|
||||
// label selector
|
||||
@@ -65,7 +64,7 @@ func (opts *ListPodsSubCommand) do(input cli.Input) (err error) {
|
||||
LabelSelector: labels.Set(selector).AsSelector().String(),
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing environments")
|
||||
return fmt.Errorf("error listing environments: %w", err)
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||
|
||||
@@ -17,11 +17,12 @@ limitations under the License.
|
||||
package environment
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -57,11 +58,11 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
|
||||
|
||||
_, currentContextNS, err := opts.GetResourceNamespace(input, flagkey.NamespaceEnvironment)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating environment")
|
||||
return fmt.Errorf("error creating environment: %w", err)
|
||||
}
|
||||
env, err := opts.Client().FissionClientSet.CoreV1().Environments(currentContextNS).Get(input.Context(), input.String(flagkey.EnvName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error finding environment")
|
||||
return fmt.Errorf("error finding environment: %w", err)
|
||||
}
|
||||
|
||||
env, err = updateExistingEnvironmentWithCmd(env, input)
|
||||
@@ -89,13 +90,13 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
specFile := fmt.Sprintf("env-%s.yaml", m.Name)
|
||||
err = spec.SpecSave(*opts.env, specFile, true)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving environment spec")
|
||||
return fmt.Errorf("error saving environment spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
enew, err := opts.Client().FissionClientSet.CoreV1().Environments(opts.env.ObjectMeta.Namespace).Update(input.Context(), opts.env, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating environment")
|
||||
return fmt.Errorf("error updating environment: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("environment '%v' updated\n", enew.ObjectMeta.Name)
|
||||
@@ -151,7 +152,7 @@ func updateExistingEnvironmentWithCmd(env *fv1.Environment, input cli.Input) (*f
|
||||
mincpu := input.Int(flagkey.RuntimeMincpu)
|
||||
cpuRequest, err := resource.ParseQuantity(strconv.Itoa(mincpu) + "m")
|
||||
if err != nil {
|
||||
e = multierror.Append(e, errors.Wrap(err, "Failed to parse mincpu"))
|
||||
e = multierror.Append(e, fmt.Errorf("failed to parse mincpu: %w", err))
|
||||
}
|
||||
env.Spec.Resources.Requests[v1.ResourceCPU] = cpuRequest
|
||||
}
|
||||
@@ -160,7 +161,7 @@ func updateExistingEnvironmentWithCmd(env *fv1.Environment, input cli.Input) (*f
|
||||
maxcpu := input.Int(flagkey.RuntimeMaxcpu)
|
||||
cpuLimit, err := resource.ParseQuantity(strconv.Itoa(maxcpu) + "m")
|
||||
if err != nil {
|
||||
e = multierror.Append(e, errors.Wrap(err, "Failed to parse maxcpu"))
|
||||
e = multierror.Append(e, fmt.Errorf("Failed to parse maxcpu: %w", err))
|
||||
}
|
||||
env.Spec.Resources.Limits[v1.ResourceCPU] = cpuLimit
|
||||
}
|
||||
@@ -169,7 +170,7 @@ func updateExistingEnvironmentWithCmd(env *fv1.Environment, input cli.Input) (*f
|
||||
minmem := input.Int(flagkey.RuntimeMinmemory)
|
||||
memRequest, err := resource.ParseQuantity(strconv.Itoa(minmem) + "Mi")
|
||||
if err != nil {
|
||||
e = multierror.Append(e, errors.Wrap(err, "Failed to parse minmemory"))
|
||||
e = multierror.Append(e, fmt.Errorf("Failed to parse minmemory: %w", err))
|
||||
}
|
||||
env.Spec.Resources.Requests[v1.ResourceMemory] = memRequest
|
||||
}
|
||||
@@ -178,7 +179,7 @@ func updateExistingEnvironmentWithCmd(env *fv1.Environment, input cli.Input) (*f
|
||||
maxmem := input.Int(flagkey.RuntimeMaxmemory)
|
||||
memLimit, err := resource.ParseQuantity(strconv.Itoa(maxmem) + "Mi")
|
||||
if err != nil {
|
||||
e = multierror.Append(e, errors.Wrap(err, "Failed to parse maxmemory"))
|
||||
e = multierror.Append(e, fmt.Errorf("Failed to parse maxmemory: %w", err))
|
||||
}
|
||||
env.Spec.Resources.Limits[v1.ResourceMemory] = memLimit
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@ limitations under the License.
|
||||
package function
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
asv2 "k8s.io/api/autoscaling/v2"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
@@ -67,7 +67,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
userProvidedNS, fnNamespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error retrieving namespace information")
|
||||
return fmt.Errorf("error retrieving namespace information: %w", err)
|
||||
}
|
||||
|
||||
// user wants a spec, create a yaml file with package and function
|
||||
@@ -93,7 +93,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
fnTimeout := input.Int(flagkey.FnExecutionTimeout)
|
||||
if fnTimeout <= 0 {
|
||||
return errors.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
|
||||
return fmt.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
|
||||
}
|
||||
|
||||
fnIdleTimeout := input.Int(flagkey.FnIdleTimeout)
|
||||
@@ -119,7 +119,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
cfgMapNames := input.StringSlice(flagkey.FnCfgMap)
|
||||
|
||||
if input.String(flagkey.FnExecutorType) == string(fv1.ExecutorTypeContainer) {
|
||||
return errors.Errorf("this command does not support creating function of executor type container. Check `fission function run-container --help`")
|
||||
return fmt.Errorf("this command does not support creating function of executor type container. Check `fission function run-container --help`")
|
||||
}
|
||||
|
||||
invokeStrategy, err := getInvokeStrategy(input, nil)
|
||||
@@ -141,7 +141,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
fr, err := spec.ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%s'", specDir))
|
||||
return fmt.Errorf("error reading spec in '%s': %w", specDir, err)
|
||||
}
|
||||
|
||||
obj := fr.SpecExists(&fv1.Package{ // In case of spec I might or might not have the `fnNamespace`, how will I get pkg objectMeta here.
|
||||
@@ -151,7 +151,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
},
|
||||
}, true, false)
|
||||
if obj == nil {
|
||||
return errors.Errorf("please create package %s spec file with namespace %s before referencing it", pkgName, userProvidedNS)
|
||||
return fmt.Errorf("please create package %s spec file with namespace %s before referencing it", pkgName, userProvidedNS)
|
||||
}
|
||||
|
||||
pkg = obj.(*fv1.Package)
|
||||
@@ -160,7 +160,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
// use existing package
|
||||
pkg, err = opts.Client().FissionClientSet.CoreV1().Packages(fnNamespace).Get(input.Context(), pkgName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("read package in '%s' in Namespace: %s. Package needs to be present in the same namespace as function", pkgName, fnNamespace))
|
||||
return fmt.Errorf("read package in '%s' in Namespace: %s. Package needs to be present in the same namespace as function: %w", pkgName, fnNamespace, err)
|
||||
}
|
||||
pkgMetadata = &pkg.ObjectMeta
|
||||
}
|
||||
@@ -180,7 +180,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
fr, err := spec.ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%s'", specDir))
|
||||
return fmt.Errorf("error reading spec in '%s': %w", specDir, err)
|
||||
}
|
||||
exists, err := fr.ExistsInSpecs(fv1.Environment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -201,7 +201,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
if e, ok := err.(ferror.Error); ok && e.Code == ferror.ErrorNotFound {
|
||||
console.Warn(fmt.Sprintf("Environment \"%s\" does not exist. Please create the environment before executing the function. \nFor example: `fission env create --name %s --envns %s --image <image>`\n", envName, envName, fnNamespace))
|
||||
} else {
|
||||
return errors.Wrap(err, "error retrieving environment information")
|
||||
return fmt.Errorf("error retrieving environment information: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,7 +228,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
pkgMetadata, err = _package.CreatePackage(input, opts.Client(), pkgName, fnNamespace, envName,
|
||||
srcArchiveFiles, deployArchiveFiles, buildcmd, specDir, opts.specFile, noZip, userProvidedNS)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating package")
|
||||
return fmt.Errorf("error creating package: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
if k8serrors.IsNotFound(err) {
|
||||
console.Warn(fmt.Sprintf("Secret %s not found in Namespace: %s. Secret needs to be present in the same namespace as function", secretName, fnNamespace))
|
||||
} else {
|
||||
return errors.Wrapf(err, "error checking secret %s", secretName)
|
||||
return fmt.Errorf("error checking secret %s: %w", secretName, err)
|
||||
}
|
||||
}
|
||||
newSecret := fv1.SecretReference{
|
||||
@@ -274,7 +274,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
if k8serrors.IsNotFound(err) {
|
||||
console.Warn(fmt.Sprintf("ConfigMap %s not found in Namespace: %s. ConfigMap needs to be present in the same namespace as function", cfgMapName, fnNamespace))
|
||||
} else {
|
||||
return errors.Wrapf(err, "error checking configmap %s", cfgMapName)
|
||||
return fmt.Errorf("error checking configmap %s: %w", cfgMapName, err)
|
||||
}
|
||||
}
|
||||
newCfgMap := fv1.ConfigMapReference{
|
||||
@@ -368,14 +368,14 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
if input.Bool(flagkey.SpecSave) {
|
||||
err := spec.SpecSave(*opts.function, opts.specFile, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving function spec")
|
||||
return fmt.Errorf("error saving function spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().Functions(opts.function.ObjectMeta.Namespace).Create(input.Context(), opts.function, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating function")
|
||||
return fmt.Errorf("error creating function: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("function '%s' created\n", opts.function.ObjectMeta.Name)
|
||||
@@ -420,7 +420,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
}
|
||||
_, err = opts.Client().FissionClientSet.CoreV1().HTTPTriggers(opts.function.ObjectMeta.Namespace).Create(input.Context(), ht, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating HTTP trigger")
|
||||
return fmt.Errorf("error creating HTTP trigger: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("route created: %s %s -> %s\n", methods, triggerUrl, opts.function.ObjectMeta.Name)
|
||||
@@ -490,7 +490,7 @@ func getExecutorType(input cli.Input) (executorType fv1.ExecutorType, err error)
|
||||
case string(fv1.ExecutorTypeContainer):
|
||||
executorType = fv1.ExecutorTypeContainer
|
||||
default:
|
||||
err = errors.Errorf("executor type must be one of '%v', '%v' or '%v'", fv1.ExecutorTypePoolmgr, fv1.ExecutorTypeNewdeploy, fv1.ExecutorTypeContainer)
|
||||
err = fmt.Errorf("executor type must be one of '%v', '%v' or '%v'", fv1.ExecutorTypePoolmgr, fv1.ExecutorTypeNewdeploy, fv1.ExecutorTypeContainer)
|
||||
}
|
||||
return executorType, err
|
||||
}
|
||||
@@ -501,7 +501,7 @@ func getExecutionStrategy(fnExecutor fv1.ExecutorType, input cli.Input) (strateg
|
||||
if input.IsSet(flagkey.FnSpecializationTimeout) {
|
||||
specializationTimeout = input.Int(flagkey.FnSpecializationTimeout)
|
||||
if specializationTimeout < fv1.DefaultSpecializationTimeOut {
|
||||
return nil, errors.Errorf("%v must be greater than or equal to 120 seconds", flagkey.FnSpecializationTimeout)
|
||||
return nil, fmt.Errorf("%v must be greater than or equal to 120 seconds", flagkey.FnSpecializationTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,7 +529,7 @@ func getExecutionStrategy(fnExecutor fv1.ExecutorType, input cli.Input) (strateg
|
||||
if input.IsSet(flagkey.ReplicasMaxscale) {
|
||||
maxScale = input.Int(flagkey.ReplicasMaxscale)
|
||||
if maxScale <= 0 {
|
||||
return nil, errors.Errorf("%v must be greater than 0", flagkey.ReplicasMaxscale)
|
||||
return nil, fmt.Errorf("%v must be greater than 0", flagkey.ReplicasMaxscale)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -573,7 +573,7 @@ func updateExecutionStrategy(input cli.Input, existingExecutionStrategy *fv1.Exe
|
||||
case string(fv1.ExecutorTypeContainer):
|
||||
fnExecutor = fv1.ExecutorTypeContainer
|
||||
default:
|
||||
return nil, errors.Errorf("executor type must be one of '%v', %v or '%v'", fv1.ExecutorTypePoolmgr, fv1.ExecutorTypeNewdeploy, fv1.ExecutorTypeContainer)
|
||||
return nil, fmt.Errorf("executor type must be one of '%v', %v or '%v'", fv1.ExecutorTypePoolmgr, fv1.ExecutorTypeNewdeploy, fv1.ExecutorTypeContainer)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,7 +582,7 @@ func updateExecutionStrategy(input cli.Input, existingExecutionStrategy *fv1.Exe
|
||||
if input.IsSet(flagkey.FnSpecializationTimeout) {
|
||||
specializationTimeout = input.Int(flagkey.FnSpecializationTimeout)
|
||||
if specializationTimeout < fv1.DefaultSpecializationTimeOut {
|
||||
return nil, errors.Errorf("%v must be greater than or equal to 120 seconds", flagkey.FnSpecializationTimeout)
|
||||
return nil, fmt.Errorf("%v must be greater than or equal to 120 seconds", flagkey.FnSpecializationTimeout)
|
||||
}
|
||||
} else {
|
||||
if specializationTimeout < fv1.DefaultSpecializationTimeOut {
|
||||
@@ -618,7 +618,7 @@ func updateExecutionStrategy(input cli.Input, existingExecutionStrategy *fv1.Exe
|
||||
if input.IsSet(flagkey.ReplicasMaxscale) {
|
||||
maxScale = input.Int(flagkey.ReplicasMaxscale)
|
||||
if maxScale <= 0 {
|
||||
return nil, errors.Errorf("%v must be greater than 0", flagkey.ReplicasMaxscale)
|
||||
return nil, fmt.Errorf("%v must be greater than 0", flagkey.ReplicasMaxscale)
|
||||
}
|
||||
} else {
|
||||
if maxScale <= 0 {
|
||||
@@ -655,7 +655,7 @@ func updateExecutionStrategy(input cli.Input, existingExecutionStrategy *fv1.Exe
|
||||
func getTargetCPU(input cli.Input) (int, error) {
|
||||
targetCPU := input.Int(flagkey.RuntimeTargetcpu)
|
||||
if targetCPU <= 0 || targetCPU > 100 {
|
||||
return 0, errors.Errorf("%v must be a value between 1 - 100", flagkey.RuntimeTargetcpu)
|
||||
return 0, fmt.Errorf("%v must be a value between 1 - 100", flagkey.RuntimeTargetcpu)
|
||||
}
|
||||
return targetCPU, nil
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package function
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -40,7 +39,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
m := &metav1.ObjectMeta{
|
||||
Name: input.String(flagkey.FnName),
|
||||
@@ -52,7 +51,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) error {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, fmt.Sprintf("delete function '%s'", m.Name))
|
||||
return fmt.Errorf("delete function '%s': %w", m.Name, err)
|
||||
}
|
||||
|
||||
fmt.Printf("function '%s' deleted\n", m.Name)
|
||||
|
||||
@@ -17,9 +17,9 @@ limitations under the License.
|
||||
package function
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -38,16 +38,16 @@ func Get(input cli.Input) error {
|
||||
func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in get function ")
|
||||
return fmt.Errorf("error in get function : %w", err)
|
||||
}
|
||||
fn, err := opts.Client().FissionClientSet.CoreV1().Functions(namespace).Get(input.Context(), input.String(flagkey.FnName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function")
|
||||
return fmt.Errorf("error getting function: %w", err)
|
||||
}
|
||||
|
||||
pkg, err := opts.Client().FissionClientSet.CoreV1().Packages(fn.Spec.Package.PackageRef.Namespace).Get(input.Context(), fn.Spec.Package.PackageRef.Name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting package")
|
||||
return fmt.Errorf("error getting package: %w", err)
|
||||
}
|
||||
|
||||
os.Stdout.Write(pkg.Spec.Deployment.Literal)
|
||||
|
||||
@@ -19,7 +19,6 @@ package function
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -38,12 +37,12 @@ func GetMeta(input cli.Input) error {
|
||||
func (opts *GetMetaSubCommand) do(input cli.Input) error {
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in getting meta function ")
|
||||
return fmt.Errorf("error in getting meta function : %w", err)
|
||||
}
|
||||
|
||||
fn, err := opts.Client().FissionClientSet.CoreV1().Functions(namespace).Get(input.Context(), input.String(flagkey.FnName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function")
|
||||
return fmt.Errorf("error getting function: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Name: %v\n", fn.ObjectMeta.Name)
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -41,7 +40,7 @@ func List(input cli.Input) error {
|
||||
func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in listing function ")
|
||||
return fmt.Errorf("error in listing function : %w", err)
|
||||
}
|
||||
|
||||
if input.Bool(flagkey.AllNamespaces) {
|
||||
@@ -50,7 +49,7 @@ func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
fns, err := opts.Client().FissionClientSet.CoreV1().Functions(namespace).List(input.Context(), metav1.ListOptions{})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing functions")
|
||||
return fmt.Errorf("error listing functions: %w", err)
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
@@ -19,11 +19,11 @@ package function
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -44,7 +44,7 @@ func Log(input cli.Input) error {
|
||||
func (opts *LogSubCommand) do(input cli.Input) error {
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in logs for function ")
|
||||
return fmt.Errorf("error in logs for function : %w", err)
|
||||
}
|
||||
|
||||
dbType := input.String(flagkey.FnLogDBType)
|
||||
@@ -60,7 +60,7 @@ func (opts *LogSubCommand) do(input cli.Input) error {
|
||||
|
||||
f, err := opts.Client().FissionClientSet.CoreV1().Functions(namespace).Get(input.Context(), input.String(flagkey.FnName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function")
|
||||
return fmt.Errorf("error getting function: %w", err)
|
||||
}
|
||||
|
||||
logDBOptions := logdb.LogDBOptions{
|
||||
@@ -70,7 +70,7 @@ func (opts *LogSubCommand) do(input cli.Input) error {
|
||||
// request the controller to establish a proxy server to the database.
|
||||
logDB, err := logdb.GetLogDB(dbType, input.Context(), logDBOptions)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get log from %s", dbType)
|
||||
return fmt.Errorf("failed to get log from %s: %w", dbType, err)
|
||||
}
|
||||
|
||||
requestChan := make(chan struct{})
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
|
||||
@@ -45,12 +44,12 @@ func (opts *ListPodsSubCommand) do(input cli.Input) error {
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in finding pod for function ")
|
||||
return fmt.Errorf("error in finding pod for function : %w", err)
|
||||
}
|
||||
// validate function
|
||||
_, err = opts.Client().FissionClientSet.CoreV1().Functions(namespace).Get(input.Context(), input.String(flagkey.FnName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function")
|
||||
return fmt.Errorf("error getting function: %w", err)
|
||||
}
|
||||
|
||||
selector := map[string]string{
|
||||
@@ -64,7 +63,7 @@ func (opts *ListPodsSubCommand) do(input cli.Input) error {
|
||||
LabelSelector: labels.Set(selector).AsSelector().String(),
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing environments")
|
||||
return fmt.Errorf("error listing environments: %w", err)
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
|
||||
|
||||
@@ -20,7 +20,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -57,7 +58,7 @@ func (opts *RunContainerSubCommand) complete(input cli.Input) error {
|
||||
|
||||
_, fnNamespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in running container for function ")
|
||||
return fmt.Errorf("error in running container for function : %w", err)
|
||||
}
|
||||
|
||||
// user wants a spec, create a yaml file with package and function
|
||||
@@ -80,7 +81,7 @@ func (opts *RunContainerSubCommand) complete(input cli.Input) error {
|
||||
|
||||
fnTimeout := input.Int(flagkey.FnExecutionTimeout)
|
||||
if fnTimeout <= 0 {
|
||||
return errors.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
|
||||
return fmt.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
|
||||
}
|
||||
|
||||
fnIdleTimeout := input.Int(flagkey.FnIdleTimeout)
|
||||
@@ -132,7 +133,7 @@ func (opts *RunContainerSubCommand) complete(input cli.Input) error {
|
||||
if kerrors.IsNotFound(err) {
|
||||
console.Warn(fmt.Sprintf("Secret %s not found in Namespace: %s. Secret needs to be present in the same namespace as function", secretName, fnNamespace))
|
||||
} else {
|
||||
return errors.Wrapf(err, "error checking secret %s", secretName)
|
||||
return fmt.Errorf("error checking secret %s: %w", secretName, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,7 +157,7 @@ func (opts *RunContainerSubCommand) complete(input cli.Input) error {
|
||||
if kerrors.IsNotFound(err) {
|
||||
console.Warn(fmt.Sprintf("ConfigMap %s not found in Namespace: %s. ConfigMap needs to be present in the same namespace as function", cfgMapName, fnNamespace))
|
||||
} else {
|
||||
return errors.Wrapf(err, "error checking configmap %s", cfgMapName)
|
||||
return fmt.Errorf("error checking configmap %s: %w", cfgMapName, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,14 +229,14 @@ func (opts *RunContainerSubCommand) run(input cli.Input) error {
|
||||
if input.Bool(flagkey.SpecSave) {
|
||||
err := spec.SpecSave(*opts.function, opts.specFile, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving function spec")
|
||||
return fmt.Errorf("error saving function spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().Functions(opts.function.ObjectMeta.Namespace).Create(input.Context(), opts.function, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating function")
|
||||
return fmt.Errorf("error creating function: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("function '%v' created\n", opts.function.ObjectMeta.Name)
|
||||
|
||||
@@ -27,7 +27,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
"go.opentelemetry.io/otel"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -53,12 +54,12 @@ func (opts *TestSubCommand) do(input cli.Input) error {
|
||||
fnName := input.String(flagkey.FnName)
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in testing function ")
|
||||
return fmt.Errorf("error in testing function : %w", err)
|
||||
}
|
||||
|
||||
function, err := opts.Client().FissionClientSet.CoreV1().Functions(namespace).Get(input.Context(), fnName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("read function '%s'", fnName))
|
||||
return fmt.Errorf("read function '%s': %w", fnName, err)
|
||||
}
|
||||
|
||||
m := &metav1.ObjectMeta{
|
||||
@@ -68,7 +69,7 @@ func (opts *TestSubCommand) do(input cli.Input) error {
|
||||
|
||||
routerURL, err := util.GetRouterURL(input.Context(), opts.Client())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting router URL")
|
||||
return fmt.Errorf("error getting router URL: %w", err)
|
||||
}
|
||||
fnURI := util.UrlForFunction(m.Name, m.Namespace)
|
||||
if input.IsSet(flagkey.FnSubPath) {
|
||||
@@ -146,7 +147,7 @@ func (opts *TestSubCommand) do(input cli.Input) error {
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading response from function")
|
||||
return fmt.Errorf("error reading response from function: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode < 400 {
|
||||
@@ -186,7 +187,7 @@ func doHTTPRequest(ctx context.Context, url string, headers []string, method, bo
|
||||
|
||||
req, err := http.NewRequest(method, url, strings.NewReader(body))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating HTTP request")
|
||||
return nil, fmt.Errorf("error creating HTTP request: %w", err)
|
||||
}
|
||||
|
||||
accesstoken, ok := os.LookupEnv(util.FISSION_AUTH_TOKEN)
|
||||
@@ -213,7 +214,7 @@ func doHTTPRequest(ctx context.Context, url string, headers []string, method, bo
|
||||
hc := &http.Client{Transport: otelhttp.NewTransport(http.DefaultTransport)}
|
||||
resp, err := hc.Do(req.WithContext(ctx))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error executing HTTP request")
|
||||
return nil, fmt.Errorf("error executing HTTP request: %w", err)
|
||||
}
|
||||
|
||||
if console.Verbosity >= 2 {
|
||||
|
||||
@@ -19,7 +19,6 @@ package function
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -55,7 +54,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
fnName := input.String(flagkey.FnName)
|
||||
_, fnNamespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in updating function ")
|
||||
return fmt.Errorf("error in updating function : %w", err)
|
||||
}
|
||||
if input.Bool(flagkey.SpecSave) {
|
||||
opts.specFile = fmt.Sprintf("function-%s.yaml", fnName)
|
||||
@@ -63,7 +62,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
function, err := opts.Client().FissionClientSet.CoreV1().Functions(fnNamespace).Get(input.Context(), input.String(flagkey.FnName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("read function '%v'", fnName))
|
||||
return fmt.Errorf("read function '%v': %w", fnName, err)
|
||||
}
|
||||
|
||||
envName := input.String(flagkey.FnEnvironmentName)
|
||||
@@ -135,7 +134,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
if input.IsSet(flagkey.FnExecutionTimeout) {
|
||||
fnTimeout := input.Int(flagkey.FnExecutionTimeout)
|
||||
if fnTimeout <= 0 {
|
||||
return errors.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
|
||||
return fmt.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
|
||||
}
|
||||
function.Spec.FunctionTimeout = fnTimeout
|
||||
}
|
||||
@@ -184,23 +183,23 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
pkg, err := opts.Client().FissionClientSet.CoreV1().Packages(fnNamespace).Get(input.Context(), pkgName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("read package '%v.%v'. Pkg should be present in the same ns as the function", pkgName, fnNamespace))
|
||||
return fmt.Errorf("read package '%v.%v'. Pkg should be present in the same ns as the function: %w", pkgName, fnNamespace, err)
|
||||
}
|
||||
|
||||
forceUpdate := input.Bool(flagkey.PkgForce)
|
||||
|
||||
fnList, err := _package.GetFunctionsByPackage(input.Context(), opts.Client(), pkg.ObjectMeta.Name, pkg.ObjectMeta.Namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function list")
|
||||
return fmt.Errorf("error getting function list: %w", err)
|
||||
}
|
||||
|
||||
if !forceUpdate && len(fnList) > 1 {
|
||||
return errors.Errorf("Package is used by multiple functions, use --%v to force update", flagkey.PkgForce)
|
||||
return fmt.Errorf("package is used by multiple functions, use --%v to force update", flagkey.PkgForce)
|
||||
}
|
||||
|
||||
newPkgMeta, err := _package.UpdatePackage(input, opts.Client(), opts.specFile, pkg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error updating package '%v'", pkgName))
|
||||
return fmt.Errorf("error updating package '%v': %w", pkgName, err)
|
||||
}
|
||||
|
||||
// the package resource version of function has been changed,
|
||||
@@ -217,7 +216,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
err = _package.UpdateFunctionPackageResourceVersion(input.Context(), opts.Client(), newPkgMeta, fns...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating function package reference resource version")
|
||||
return fmt.Errorf("error updating function package reference resource version: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,13 +254,13 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
}
|
||||
err = spec.SpecSave(*opts.function, opts.specFile, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving function spec")
|
||||
return fmt.Errorf("error saving function spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().Functions(opts.function.Namespace).Update(input.Context(), opts.function, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating function")
|
||||
return fmt.Errorf("error updating function: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Function '%v' updated\n", opts.function.ObjectMeta.Name)
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
apiv1 "k8s.io/api/core/v1"
|
||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -55,13 +54,13 @@ func (opts *UpdateContainerSubCommand) complete(input cli.Input) error {
|
||||
|
||||
_, fnNamespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in updating container for function ")
|
||||
return fmt.Errorf("error in updating container for function : %w", err)
|
||||
}
|
||||
|
||||
function, err := opts.Client().FissionClientSet.CoreV1().Functions(fnNamespace).Get(input.Context(), input.String(flagkey.FnName), metav1.GetOptions{})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("read function '%v'", fnName))
|
||||
return fmt.Errorf("read function '%v': %w", fnName, err)
|
||||
}
|
||||
if fv1.ExecutorTypeContainer != function.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType {
|
||||
return fmt.Errorf("executor type for function is not %s", fv1.ExecutorTypeContainer)
|
||||
@@ -122,7 +121,7 @@ func (opts *UpdateContainerSubCommand) complete(input cli.Input) error {
|
||||
if input.IsSet(flagkey.FnExecutionTimeout) {
|
||||
fnTimeout := input.Int(flagkey.FnExecutionTimeout)
|
||||
if fnTimeout <= 0 {
|
||||
return errors.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
|
||||
return fmt.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
|
||||
}
|
||||
function.Spec.FunctionTimeout = fnTimeout
|
||||
}
|
||||
@@ -146,7 +145,7 @@ func (opts *UpdateContainerSubCommand) complete(input cli.Input) error {
|
||||
function.Spec.Resources = *resReqs
|
||||
|
||||
if len(function.Spec.PodSpec.Containers) > 1 {
|
||||
return errors.Errorf("function %s has more than one container, only one container is supported", fnName)
|
||||
return fmt.Errorf("function %s has more than one container, only one container is supported", fnName)
|
||||
}
|
||||
container := &function.Spec.PodSpec.Containers[0]
|
||||
if imageName != "" {
|
||||
@@ -154,7 +153,7 @@ func (opts *UpdateContainerSubCommand) complete(input cli.Input) error {
|
||||
}
|
||||
if port != 0 {
|
||||
if len(container.Ports) > 1 {
|
||||
return errors.Errorf("function %s has more than one port, only one port is supported", fnName)
|
||||
return fmt.Errorf("function %s has more than one port, only one port is supported", fnName)
|
||||
}
|
||||
container.Ports = []apiv1.ContainerPort{
|
||||
{
|
||||
@@ -186,7 +185,7 @@ func (opts *UpdateContainerSubCommand) complete(input cli.Input) error {
|
||||
func (opts *UpdateContainerSubCommand) run(input cli.Input) error {
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().Functions(opts.function.Namespace).Update(input.Context(), opts.function, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating function")
|
||||
return fmt.Errorf("error updating function: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -22,7 +22,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -75,7 +76,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
userProvidedNS, fnNamespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
triggerUrl := input.String(flagkey.HtUrl)
|
||||
@@ -125,7 +126,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
specIgnore := util.GetSpecIgnore(input)
|
||||
fr, err := spec.ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%v'", specDir))
|
||||
return fmt.Errorf("error reading spec in '%v': %w", specDir, err)
|
||||
}
|
||||
for _, fn := range functionList {
|
||||
exists, err := fr.ExistsInSpecs(fv1.Function{
|
||||
@@ -167,7 +168,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
input.StringSlice(flagkey.HtIngressAnnotation), input.String(flagkey.HtIngressRule),
|
||||
input.String(flagkey.HtIngressTLS), fallbackURL, nil)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error parsing ingress configuration")
|
||||
return fmt.Errorf("error parsing ingress configuration: %w", err)
|
||||
}
|
||||
|
||||
opts.trigger = &fv1.HTTPTrigger{
|
||||
@@ -198,7 +199,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
specFile := fmt.Sprintf("route-%v.yaml", opts.trigger.ObjectMeta.Name)
|
||||
err := spec.SpecSave(*opts.trigger, specFile, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving HTTP trigger spec")
|
||||
return fmt.Errorf("error saving HTTP trigger spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -206,12 +207,12 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
// Ensure we don't have a duplicate HTTP route defined (same URL and method)
|
||||
err := util.CheckHTTPTriggerDuplicates(input.Context(), opts.Client(), opts.trigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error while creating HTTP Trigger")
|
||||
return fmt.Errorf("Error while creating HTTP Trigger: %w", err)
|
||||
}
|
||||
|
||||
_, err = opts.Client().FissionClientSet.CoreV1().HTTPTriggers(opts.trigger.Namespace).Create(input.Context(), opts.trigger, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "create HTTP trigger")
|
||||
return fmt.Errorf("create HTTP trigger: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' created\n", opts.trigger.ObjectMeta.Name)
|
||||
|
||||
@@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -53,14 +52,14 @@ func (opts *DeleteSubCommand) complete(input cli.Input) (err error) {
|
||||
opts.triggerName = input.String(flagkey.HtName)
|
||||
opts.functionName = input.String(flagkey.HtFnName)
|
||||
if len(opts.triggerName) == 0 && len(opts.functionName) == 0 {
|
||||
return errors.Errorf("need --%v or --%v", flagkey.HtName, flagkey.HtFnName)
|
||||
return fmt.Errorf("need --%v or --%v", flagkey.HtName, flagkey.HtFnName)
|
||||
} else if len(opts.triggerName) > 0 && len(opts.functionName) > 0 {
|
||||
return errors.Errorf("need either of --%v or --%v and not both arguments", flagkey.HtName, flagkey.HtFnName)
|
||||
return fmt.Errorf("need either of --%v or --%v and not both arguments", flagkey.HtName, flagkey.HtFnName)
|
||||
}
|
||||
|
||||
_, opts.namespace, err = opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -68,7 +67,7 @@ func (opts *DeleteSubCommand) complete(input cli.Input) (err error) {
|
||||
func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
triggers, err := opts.Client().FissionClientSet.CoreV1().HTTPTriggers(opts.namespace).List(input.Context(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting HTTP trigger list")
|
||||
return fmt.Errorf("error getting HTTP trigger list: %w", err)
|
||||
}
|
||||
|
||||
var triggersToDelete []string
|
||||
@@ -99,7 +98,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(errs.ErrorOrNil(), "error deleting trigger(s)")
|
||||
return fmt.Errorf("error deleting trigger(s): %w", errs.ErrorOrNil())
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -46,12 +45,12 @@ func (opts *GetSubCommand) do(input cli.Input) error {
|
||||
func (opts *GetSubCommand) run(input cli.Input) (err error) {
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
ht, err := opts.Client().FissionClientSet.CoreV1().HTTPTriggers(namespace).Get(input.Context(), input.String(flagkey.HtName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting http trigger")
|
||||
return fmt.Errorf("error getting http trigger: %w", err)
|
||||
}
|
||||
|
||||
printHtSummary([]fv1.HTTPTrigger{*ht})
|
||||
|
||||
@@ -17,7 +17,8 @@ limitations under the License.
|
||||
package httptrigger
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -42,7 +43,7 @@ func (opts *ListSubCommand) run(input cli.Input) (err error) {
|
||||
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
if input.Bool(flagkey.AllNamespaces) {
|
||||
@@ -51,7 +52,7 @@ func (opts *ListSubCommand) run(input cli.Input) (err error) {
|
||||
hts, err := opts.Client().FissionClientSet.CoreV1().HTTPTriggers(namespace).List(input.Context(), v1.ListOptions{})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing HTTP triggers")
|
||||
return fmt.Errorf("error listing HTTP triggers: %w", err)
|
||||
}
|
||||
|
||||
filterFunctionName := input.String(flagkey.HtFnName)
|
||||
|
||||
@@ -20,7 +20,8 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -54,12 +55,12 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
|
||||
|
||||
_, triggerNamespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
ht, err := opts.Client().FissionClientSet.CoreV1().HTTPTriggers(triggerNamespace).Get(input.Context(), htName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting HTTP trigger")
|
||||
return fmt.Errorf("error getting HTTP trigger: %w", err)
|
||||
}
|
||||
|
||||
triggerUrl := input.String(flagkey.HtUrl)
|
||||
@@ -113,7 +114,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
|
||||
// set function reference
|
||||
functionRef, err := setHtFunctionRef(functionList, functionWeightsList)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error setting function weight")
|
||||
return fmt.Errorf("error setting function weight: %w", err)
|
||||
}
|
||||
|
||||
ht.Spec.FunctionReference = *functionRef
|
||||
@@ -138,7 +139,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
|
||||
input.StringSlice(flagkey.HtIngressAnnotation), input.String(flagkey.HtIngressRule),
|
||||
input.String(flagkey.HtIngressTLS), fallbackURL, &ht.Spec.IngressConfig)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error parsing ingress configuration")
|
||||
return fmt.Errorf("error parsing ingress configuration: %w", err)
|
||||
}
|
||||
ht.Spec.IngressConfig = *ingress
|
||||
}
|
||||
@@ -157,18 +158,18 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
specFile := fmt.Sprintf("route-%s.yaml", opts.trigger.ObjectMeta.Name)
|
||||
err = spec.SpecSave(*opts.trigger, specFile, true)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving HTTP trigger spec")
|
||||
return fmt.Errorf("error saving HTTP trigger spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
err := util.CheckHTTPTriggerDuplicates(input.Context(), opts.Client(), opts.trigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Error while creating HTTP Trigger")
|
||||
return fmt.Errorf("Error while creating HTTP Trigger: %w", err)
|
||||
}
|
||||
|
||||
_, err = opts.Client().FissionClientSet.CoreV1().HTTPTriggers(opts.trigger.ObjectMeta.Namespace).Update(input.Context(), opts.trigger, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating the HTTP trigger")
|
||||
return fmt.Errorf("error updating the HTTP trigger: %w", err)
|
||||
}
|
||||
fmt.Printf("trigger '%v' updated\n", opts.trigger.ObjectMeta.Name)
|
||||
return nil
|
||||
|
||||
@@ -19,7 +19,6 @@ package kubewatch
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -59,7 +58,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.KwNamespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in listing function ")
|
||||
return fmt.Errorf("error in listing function : %w", err)
|
||||
}
|
||||
|
||||
objType := input.String(flagkey.KwObjType)
|
||||
@@ -69,7 +68,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
specIgnore := util.GetSpecIgnore(input)
|
||||
fr, err := spec.ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%v'", specDir))
|
||||
return fmt.Errorf("error reading spec in '%v': %w", specDir, err)
|
||||
}
|
||||
|
||||
exists, err := fr.ExistsInSpecs(fv1.Function{
|
||||
@@ -117,14 +116,14 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
specFile := fmt.Sprintf("kubewatch-%v.yaml", opts.watcher.ObjectMeta.Name)
|
||||
err := spec.SpecSave(*opts.watcher, specFile, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving kubewatch spec")
|
||||
return fmt.Errorf("error saving kubewatch spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().KubernetesWatchTriggers(opts.watcher.ObjectMeta.Namespace).Create(input.Context(), opts.watcher, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating kubewatch")
|
||||
return fmt.Errorf("error creating kubewatch: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' created\n", opts.watcher.ObjectMeta.Name)
|
||||
|
||||
@@ -19,7 +19,6 @@ package kubewatch
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -50,7 +49,7 @@ func (opts *DeleteSubCommand) complete(input cli.Input) (err error) {
|
||||
opts.name = input.String(flagkey.KwName)
|
||||
_, opts.namespace, err = opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting kubewatch")
|
||||
return fmt.Errorf("error in deleting kubewatch: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -61,7 +60,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && util.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting kubewatch")
|
||||
return fmt.Errorf("error deleting kubewatch: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' deleted\n", opts.name)
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
v1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -50,7 +49,7 @@ func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
func (opts *ListSubCommand) complete(input cli.Input) (err error) {
|
||||
_, opts.namespace, err = opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing kubewatchers")
|
||||
return fmt.Errorf("error listing kubewatchers: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -63,7 +62,7 @@ func (opts *ListSubCommand) run(input cli.Input) (err error) {
|
||||
ws, err = opts.Client().FissionClientSet.CoreV1().KubernetesWatchTriggers(opts.namespace).List(input.Context(), metav1.ListOptions{})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing kubewatchers")
|
||||
return fmt.Errorf("error listing kubewatchers: %w", err)
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
@@ -19,7 +19,8 @@ package mqtrigger
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -60,7 +61,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
|
||||
userProvidedNS, fnNamespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
mqtKind := input.String(flagkey.MqtKind)
|
||||
@@ -130,7 +131,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
|
||||
specIgnore := util.GetSpecIgnore(input)
|
||||
fr, err := spec.ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%v'", specDir))
|
||||
return fmt.Errorf("error reading spec in '%v': %w", specDir, err)
|
||||
}
|
||||
|
||||
exists, err := fr.ExistsInSpecs(fv1.Function{
|
||||
@@ -201,14 +202,14 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
specFile := fmt.Sprintf("mqtrigger-%v.yaml", opts.trigger.ObjectMeta.Name)
|
||||
err := spec.SpecSave(*opts.trigger, specFile, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving message queue trigger spec")
|
||||
return fmt.Errorf("error saving message queue trigger spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().MessageQueueTriggers(opts.trigger.ObjectMeta.Namespace).Create(input.Context(), opts.trigger, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "create message queue trigger")
|
||||
return fmt.Errorf("create message queue trigger: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%s' created\n", opts.trigger.ObjectMeta.Name)
|
||||
@@ -218,7 +219,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
func checkMQTopicAvailability(mqType fv1.MessageQueueType, mqtKind string, topics ...string) error {
|
||||
for _, t := range topics {
|
||||
if len(t) > 0 && !validator.IsValidTopic((string)(mqType), t, mqtKind) {
|
||||
return errors.Errorf("invalid topic for %s: %s", mqType, t)
|
||||
return fmt.Errorf("invalid topic for %s: %s", mqType, t)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -19,7 +19,6 @@ package mqtrigger
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -49,7 +48,7 @@ func (opts *DeleteSubCommand) complete(input cli.Input) (err error) {
|
||||
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
opts.metadata = &metav1.ObjectMeta{
|
||||
@@ -65,7 +64,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && kerrors.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting message queue trigger")
|
||||
return fmt.Errorf("error deleting message queue trigger: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' deleted\n", opts.metadata.Name)
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -49,7 +48,7 @@ func (opts *ListSubCommand) do(input cli.Input) error {
|
||||
func (opts *ListSubCommand) complete(input cli.Input) (err error) {
|
||||
_, opts.namespace, err = opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -62,7 +61,7 @@ func (opts *ListSubCommand) run(input cli.Input) (err error) {
|
||||
mqts, err := opts.Client().FissionClientSet.CoreV1().MessageQueueTriggers(opts.namespace).List(input.Context(), metav1.ListOptions{})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error listing message queue triggers")
|
||||
return fmt.Errorf("error listing message queue triggers: %w", err)
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
@@ -19,7 +19,8 @@ package mqtrigger
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -51,12 +52,12 @@ func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
func (opts *UpdateSubCommand) complete(input cli.Input) (err error) {
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
mqt, err := opts.Client().FissionClientSet.CoreV1().MessageQueueTriggers(namespace).Get(input.Context(), input.String(flagkey.MqtName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting message queue trigger")
|
||||
return fmt.Errorf("error getting message queue trigger: %w", err)
|
||||
}
|
||||
|
||||
topic := input.String(flagkey.MqtTopic)
|
||||
@@ -158,13 +159,13 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
specFile := fmt.Sprintf("mqtrigger-%s.yaml", opts.trigger.ObjectMeta.Name)
|
||||
err = spec.SpecSave(*opts.trigger, specFile, true)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving message queue trigger spec")
|
||||
return fmt.Errorf("error saving message queue trigger spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().MessageQueueTriggers(opts.trigger.ObjectMeta.Namespace).Update(input.Context(), opts.trigger, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating message queue trigger")
|
||||
return fmt.Errorf("error updating message queue trigger: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("message queue trigger '%v' updated\n", opts.trigger.ObjectMeta.Name)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -56,7 +55,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
pkgName := input.String(flagkey.PkgName)
|
||||
if len(pkgName) == 0 {
|
||||
if input.Bool(flagkey.SpecSave) && len(input.String(flagkey.PkgName)) == 0 {
|
||||
return errors.Errorf("--%v is necessary when creating spec file", flagkey.PkgName)
|
||||
return fmt.Errorf("--%v is necessary when creating spec file", flagkey.PkgName)
|
||||
} else {
|
||||
console.Warn(fmt.Sprintf("--%v will be soon marked as required flag, see 'help' for details", flagkey.HtName))
|
||||
}
|
||||
@@ -83,7 +82,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
}
|
||||
|
||||
if len(srcArchiveFiles) == 0 && len(deployArchiveFiles) == 0 {
|
||||
return errors.Errorf("need --%v or --%v or --%v argument", flagkey.PkgCode, flagkey.PkgSrcArchive, flagkey.PkgDeployArchive)
|
||||
return fmt.Errorf("need --%v or --%v or --%v argument", flagkey.PkgCode, flagkey.PkgSrcArchive, flagkey.PkgDeployArchive)
|
||||
}
|
||||
|
||||
var specDir, specFile string
|
||||
@@ -91,14 +90,14 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
if input.Bool(flagkey.SpecSave) {
|
||||
// since package CRD created using --spec, not validate by k8s. So we need to validate it and make sure package name is not more than 63 characters.
|
||||
if len(pkgName) > 63 {
|
||||
return errors.Errorf("error creating package: package name %v, must be no more than 63 characters", pkgName)
|
||||
return fmt.Errorf("error creating package: package name %v, must be no more than 63 characters", pkgName)
|
||||
}
|
||||
|
||||
specDir = util.GetSpecDir(input)
|
||||
specIgnore := util.GetSpecIgnore(input)
|
||||
fr, err := spec.ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%v'", specDir))
|
||||
return fmt.Errorf("error reading spec in '%v': %w", specDir, err)
|
||||
}
|
||||
exists, err := fr.ExistsInSpecs(fv1.Environment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -155,7 +154,7 @@ func CreatePackage(input cli.Input, client cmd.Client, pkgName string, pkgNamesp
|
||||
}
|
||||
deployment, err := CreateArchive(client, input, deployArchiveFiles, noZip, insecure, deployChecksum, specDir, specFile)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating deploy archive")
|
||||
return nil, fmt.Errorf("error creating deploy archive: %w", err)
|
||||
}
|
||||
pkgSpec.Deployment = *deployment
|
||||
if len(pkgName) == 0 {
|
||||
@@ -165,7 +164,7 @@ func CreatePackage(input cli.Input, client cmd.Client, pkgName string, pkgNamesp
|
||||
if len(srcArchiveFiles) > 0 {
|
||||
source, err := CreateArchive(client, input, srcArchiveFiles, false, insecure, srcChecksum, specDir, specFile)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating source archive")
|
||||
return nil, fmt.Errorf("error creating source archive: %w", err)
|
||||
}
|
||||
pkgSpec.Source = *source
|
||||
pkgStatus = fv1.BuildStatusPending // set package build status to pending
|
||||
@@ -202,7 +201,7 @@ func CreatePackage(input cli.Input, client cmd.Client, pkgName string, pkgNamesp
|
||||
// if a package with the same spec exists, don't create a new spec file
|
||||
fr, err := spec.ReadSpecs(util.GetSpecDir(input), util.GetSpecIgnore(input), false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error reading specs")
|
||||
return nil, fmt.Errorf("error reading specs: %w", err)
|
||||
}
|
||||
|
||||
obj := fr.SpecExists(pkg, true, true)
|
||||
@@ -214,7 +213,7 @@ func CreatePackage(input cli.Input, client cmd.Client, pkgName string, pkgNamesp
|
||||
|
||||
err = spec.SpecSave(*pkg, specFile, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error saving package spec")
|
||||
return nil, fmt.Errorf("error saving package spec: %w", err)
|
||||
}
|
||||
return &pkg.ObjectMeta, nil
|
||||
} else {
|
||||
@@ -222,7 +221,7 @@ func CreatePackage(input cli.Input, client cmd.Client, pkgName string, pkgNamesp
|
||||
|
||||
pkgMetadata, err := client.FissionClientSet.CoreV1().Packages(pkgNamespace).Create(input.Context(), pkg, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating package")
|
||||
return nil, fmt.Errorf("error creating package: %w", err)
|
||||
}
|
||||
fmt.Printf("Package '%v' created\n", pkgMetadata.GetName())
|
||||
return &pkgMetadata.ObjectMeta, nil
|
||||
|
||||
@@ -20,7 +20,8 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -61,7 +62,7 @@ func (opts *DeleteSubCommand) complete(input cli.Input) (err error) {
|
||||
opts.force = input.Bool(flagkey.PkgForce)
|
||||
|
||||
if len(opts.name) == 0 && !opts.deleteOrphans {
|
||||
return errors.Errorf("need --%v or --%v flag", flagkey.PkgName, flagkey.PkgOrphan)
|
||||
return fmt.Errorf("need --%v or --%v flag", flagkey.PkgName, flagkey.PkgOrphan)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -74,7 +75,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && kerrors.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "find package")
|
||||
return fmt.Errorf("find package: %w", err)
|
||||
}
|
||||
|
||||
fnList, err := GetFunctionsByPackage(input.Context(), opts.Client(), opts.name, opts.namespace)
|
||||
@@ -96,7 +97,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error {
|
||||
if opts.deleteOrphans {
|
||||
err := deleteOrphanPkgs(input.Context(), opts.Client(), opts.namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "deleting orphan packages")
|
||||
return fmt.Errorf("deleting orphan packages: %w", err)
|
||||
}
|
||||
fmt.Println("Orphan packages deleted")
|
||||
}
|
||||
@@ -114,7 +115,7 @@ func deleteOrphanPkgs(ctx context.Context, client cmd.Client, pkgNamespace strin
|
||||
for _, pkg := range pkgList.Items {
|
||||
fnList, err := GetFunctionsByPackage(ctx, client, pkg.ObjectMeta.Name, pkgNamespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("get functions sharing package %s", pkg.ObjectMeta.Name))
|
||||
return fmt.Errorf("get functions sharing package %v: %w", pkg.ObjectMeta.Name, err)
|
||||
}
|
||||
if len(fnList) == 0 {
|
||||
err = deletePackage(ctx, client, pkg.ObjectMeta.Name, pkgNamespace)
|
||||
|
||||
@@ -18,10 +18,10 @@ package _package
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -88,7 +88,7 @@ func (opts *GetSubCommand) run(input cli.Input) error {
|
||||
|
||||
readCloser, err := pkgutil.DownloadStrorageURL(input.Context(), opts.Client(), archive.URL)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error downloading from storage service url: %s", archive.URL)
|
||||
return fmt.Errorf("error downloading from storage service url: %s: %w", archive.URL, err)
|
||||
}
|
||||
|
||||
defer readCloser.Close()
|
||||
|
||||
@@ -17,9 +17,9 @@ limitations under the License.
|
||||
package _package
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -60,7 +60,7 @@ func (opts *InfoSubCommand) complete(input cli.Input) (err error) {
|
||||
func (opts *InfoSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.Client().FissionClientSet.CoreV1().Packages(opts.namespace).Get(input.Context(), opts.name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error finding package %s", opts.name)
|
||||
return fmt.Errorf("error finding package %s: %w", opts.name, err)
|
||||
}
|
||||
|
||||
pkgutil.PrintPackageSummary(os.Stdout, pkg)
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -87,7 +86,7 @@ func (opts *ListSubCommand) run(input cli.Input) (err error) {
|
||||
if opts.listOrphans {
|
||||
fnList, err := GetFunctionsByPackage(input.Context(), opts.Client(), pkg.ObjectMeta.Name, pkg.ObjectMeta.Namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("get functions sharing package %s", pkg.ObjectMeta.Name))
|
||||
return fmt.Errorf("get functions sharing package %v: %w", pkg.ObjectMeta.Name, err)
|
||||
}
|
||||
if len(fnList) > 0 {
|
||||
show = false
|
||||
|
||||
@@ -24,9 +24,10 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/dchest/uniuri"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -54,7 +55,7 @@ func CreateArchive(client cmd.Client, input cli.Input, includeFiles []string, no
|
||||
if len(specFile) > 0 {
|
||||
rootDir, err = filepath.Abs(specDir + "/..")
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error getting root directory of spec directory")
|
||||
return nil, fmt.Errorf("error getting root directory of spec directory: %w", err)
|
||||
}
|
||||
}
|
||||
errs := utils.MultiErrorWithFormat()
|
||||
@@ -75,24 +76,24 @@ func CreateArchive(client cmd.Client, input cli.Input, includeFiles []string, no
|
||||
// Get files from inputs as number of files decide next steps
|
||||
absPath, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
errs = multierror.Append(errs, errors.Wrapf(err, "error converting path to the absolute path \"%v\"", path))
|
||||
errs = multierror.Append(errs, fmt.Errorf("error converting path to the absolute path \"%v\": %w", path, err))
|
||||
continue
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(absPath, rootDir) {
|
||||
errs = multierror.Append(errs, errors.Errorf("The files (%v) should be put under the same parent directory (%v) of spec directory; otherwise, the archive will be empty when applying spec files", path, rootDir))
|
||||
errs = multierror.Append(errs, fmt.Errorf("The files (%v) should be put under the same parent directory (%v) of spec directory; otherwise, the archive will be empty when applying spec files", path, rootDir))
|
||||
continue
|
||||
}
|
||||
|
||||
path := filepath.Join(rootDir, path)
|
||||
files, err := utils.FindAllGlobs(path)
|
||||
if err != nil {
|
||||
errs = multierror.Append(errs, errors.Wrap(err, "error finding all globs"))
|
||||
errs = multierror.Append(errs, fmt.Errorf("error finding all globs: %w", err))
|
||||
continue
|
||||
}
|
||||
|
||||
if len(files) == 0 {
|
||||
errs = multierror.Append(errs, errors.Errorf("Error finding any files with path \"%v\"", path))
|
||||
errs = multierror.Append(errs, fmt.Errorf("Error finding any files with path \"%v\"", path))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,12 +128,12 @@ func CreateArchive(client cmd.Client, input cli.Input, includeFiles []string, no
|
||||
file := filepath.Join(tmpDir, uuid.NewString())
|
||||
err = utils.DownloadUrl(input.Context(), http.DefaultClient, fileURL, file)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error downloading file from the given URL")
|
||||
return nil, fmt.Errorf("error downloading file from the given URL: %w", err)
|
||||
}
|
||||
|
||||
csum, err = utils.GetFileChecksum(file)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error generating file SHA256 checksum")
|
||||
return nil, fmt.Errorf("error generating file SHA256 checksum: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +161,7 @@ func CreateArchive(client cmd.Client, input cli.Input, includeFiles []string, no
|
||||
specIgnore := util.GetSpecIgnore(input)
|
||||
fr, err := spec.ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error reading specs")
|
||||
return nil, fmt.Errorf("error reading specs: %w", err)
|
||||
}
|
||||
|
||||
obj := fr.SpecExists(aus, true, true)
|
||||
@@ -172,7 +173,7 @@ func CreateArchive(client cmd.Client, input cli.Input, includeFiles []string, no
|
||||
// save the uploadspec
|
||||
err := spec.SpecSave(*aus, specFile, false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error saving archive spec")
|
||||
return nil, fmt.Errorf("error saving archive spec: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -208,14 +209,14 @@ func makeArchiveFile(ctx context.Context, archiveNameHint string, archiveInput [
|
||||
// Get files from inputs as number of files decide next steps
|
||||
files, err := utils.FindAllGlobs(archiveInput...)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "error finding all globs")
|
||||
return "", fmt.Errorf("error finding all globs: %w", err)
|
||||
}
|
||||
|
||||
// We have one file; if it's a zip file, no need to archive it
|
||||
if len(files) == 1 {
|
||||
// make sure it exists
|
||||
if _, err := os.Stat(files[0]); err != nil {
|
||||
return "", errors.Wrapf(err, "open input file %v", files[0])
|
||||
return "", fmt.Errorf("open input file %v: %w", files[0], err)
|
||||
}
|
||||
|
||||
// if it's an existing zip file OR we're not supposed to zip it, don't do anything
|
||||
@@ -227,12 +228,12 @@ func makeArchiveFile(ctx context.Context, archiveNameHint string, archiveInput [
|
||||
// For anything else, create a new archive
|
||||
tmpDir, err := utils.GetTempDir()
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "error create temporary archive directory")
|
||||
return "", fmt.Errorf("error create temporary archive directory: %w", err)
|
||||
}
|
||||
|
||||
archivePath, err := utils.MakeZipArchiveWithGlobs(ctx, filepath.Join(tmpDir, archiveFileName), archiveInput...)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "create archive file")
|
||||
return "", fmt.Errorf("create archive file: %w", err)
|
||||
}
|
||||
|
||||
return archivePath, nil
|
||||
|
||||
@@ -19,7 +19,6 @@ package _package
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -58,17 +57,17 @@ func (opts *RebuildSubCommand) complete(input cli.Input) (err error) {
|
||||
func (opts *RebuildSubCommand) run(input cli.Input) error {
|
||||
pkg, err := opts.Client().FissionClientSet.CoreV1().Packages(opts.namespace).Get(input.Context(), opts.name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "package %s not found", opts.name)
|
||||
return fmt.Errorf("package %s not found: %w", opts.name, err)
|
||||
}
|
||||
|
||||
if pkg.Status.BuildStatus != fv1.BuildStatusFailed {
|
||||
return errors.New(fmt.Sprintf("Package %v is not in %v state.",
|
||||
pkg.ObjectMeta.Name, fv1.BuildStatusFailed))
|
||||
return fmt.Errorf("Package %v is not in %v state.",
|
||||
pkg.ObjectMeta.Name, fv1.BuildStatusFailed)
|
||||
}
|
||||
|
||||
_, err = updatePackageStatus(input.Context(), opts.Client(), pkg, fv1.BuildStatusPending)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "update package status")
|
||||
return fmt.Errorf("update package status: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Retrying build for pkg %v. Use \"fission pkg info --name %v\" to view status.\n", pkg.ObjectMeta.Name, pkg.ObjectMeta.Name)
|
||||
|
||||
@@ -21,8 +21,9 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -66,29 +67,29 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
pkgName := input.String(flagkey.PkgName)
|
||||
pkg, err := opts.Client().FissionClientSet.CoreV1().Packages(opts.pkgNamespace).Get(input.Context(), opts.pkgName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting package")
|
||||
return fmt.Errorf("error getting package: %w", err)
|
||||
}
|
||||
|
||||
forceUpdate := input.Bool(flagkey.PkgForce)
|
||||
|
||||
fnList, err := GetFunctionsByPackage(input.Context(), opts.Client(), pkg.ObjectMeta.Name, pkg.ObjectMeta.Namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting function list")
|
||||
return fmt.Errorf("error getting function list: %w", err)
|
||||
}
|
||||
|
||||
if !forceUpdate && len(fnList) > 1 {
|
||||
return errors.Errorf("package is used by multiple functions, use --%v to force update", flagkey.PkgForce)
|
||||
return fmt.Errorf("package is used by multiple functions, use --%v to force update", flagkey.PkgForce)
|
||||
}
|
||||
specFile := fmt.Sprintf("package-%s.yaml", pkgName)
|
||||
newPkgMeta, err := UpdatePackage(input, opts.Client(), specFile, pkg)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating package")
|
||||
return fmt.Errorf("error updating package: %w", err)
|
||||
}
|
||||
|
||||
if pkg.ObjectMeta.ResourceVersion != newPkgMeta.ResourceVersion {
|
||||
err = UpdateFunctionPackageResourceVersion(input.Context(), opts.Client(), newPkgMeta, fnList...)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating function package reference resource version")
|
||||
return fmt.Errorf("error updating function package reference resource version: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +131,7 @@ func UpdatePackage(input cli.Input, client cmd.Client, specFile string, pkg *fv1
|
||||
if input.IsSet(flagkey.PkgSrcArchive) {
|
||||
srcArchive, err := CreateArchive(client, input, srcArchiveFiles, noZip, insecure, srcChecksum, "", "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating source archive")
|
||||
return nil, fmt.Errorf("error creating source archive: %w", err)
|
||||
}
|
||||
pkg.Spec.Source = *srcArchive
|
||||
needToRebuild = true
|
||||
@@ -146,7 +147,7 @@ func UpdatePackage(input cli.Input, client cmd.Client, specFile string, pkg *fv1
|
||||
if input.IsSet(flagkey.PkgDeployArchive) || input.IsSet(flagkey.PkgCode) {
|
||||
deployArchive, err := CreateArchive(client, input, deployArchiveFiles, noZip, insecure, deployChecksum, "", "")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating deploy archive")
|
||||
return nil, fmt.Errorf("error creating deploy archive: %w", err)
|
||||
}
|
||||
pkg.Spec.Deployment = *deployArchive
|
||||
// Users may update the env, envNS and deploy archive at the same time,
|
||||
@@ -178,7 +179,7 @@ func UpdatePackage(input cli.Input, client cmd.Client, specFile string, pkg *fv1
|
||||
// if a package with the same spec exists, don't create a new spec file
|
||||
fr, err := spec.ReadSpecs(util.GetSpecDir(input), util.GetSpecIgnore(input), false)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error reading specs")
|
||||
return nil, fmt.Errorf("error reading specs: %w", err)
|
||||
}
|
||||
|
||||
obj := fr.SpecExists(pkg, true, true)
|
||||
@@ -190,14 +191,14 @@ func UpdatePackage(input cli.Input, client cmd.Client, specFile string, pkg *fv1
|
||||
|
||||
err = spec.SpecSave(*pkg, specFile, true)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error saving package spec")
|
||||
return nil, fmt.Errorf("error saving package spec: %w", err)
|
||||
}
|
||||
return &pkg.ObjectMeta, nil
|
||||
}
|
||||
|
||||
newPkgMeta, err := client.FissionClientSet.CoreV1().Packages(pkg.ObjectMeta.Namespace).Update(input.Context(), pkg, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "update package")
|
||||
return nil, fmt.Errorf("update package: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Package '%v' updated\n", newPkgMeta.GetName())
|
||||
@@ -213,7 +214,7 @@ func UpdateFunctionPackageResourceVersion(ctx context.Context, client cmd.Client
|
||||
fn.Spec.Package.PackageRef.ResourceVersion = pkgMeta.ResourceVersion
|
||||
_, err := client.FissionClientSet.CoreV1().Functions(fn.ObjectMeta.Namespace).Update(ctx, &fn, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
errs = multierror.Append(errs, errors.Wrapf(err, "error updating package resource version of function '%v'", fn.ObjectMeta.Name))
|
||||
errs = multierror.Append(errs, fmt.Errorf("error updating package resource version of function '%v': %w", fn.ObjectMeta.Name, err))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@ import (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
@@ -53,19 +51,19 @@ func UploadArchiveFile(ctx context.Context, client cmd.Client, fileName string)
|
||||
} else {
|
||||
storagesvcURL, err := util.GetStorageURL(ctx, client)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error getting fission storage service URL")
|
||||
return nil, fmt.Errorf("error getting fission storage service URL: %w", err)
|
||||
}
|
||||
|
||||
storageClient := storageSvcClient.MakeClient(storagesvcURL.String())
|
||||
// TODO add a progress bar
|
||||
id, err := storageClient.Upload(ctx, fileName, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error uploading to fission storage service")
|
||||
return nil, fmt.Errorf("error uploading to fission storage service: %w", err)
|
||||
}
|
||||
|
||||
archiveURL, err := getArchiveURL(ctx, client, id, storagesvcURL)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not get URL of archive")
|
||||
return nil, fmt.Errorf("could not get URL of archive: %w", err)
|
||||
}
|
||||
|
||||
archive.Type = fv1.ArchiveTypeUrl
|
||||
@@ -73,7 +71,7 @@ func UploadArchiveFile(ctx context.Context, client cmd.Client, fileName string)
|
||||
|
||||
csum, err := utils.GetFileChecksum(fileName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "calculate checksum for file %v", fileName)
|
||||
return nil, fmt.Errorf("calculate checksum for file %v: %w", fileName, err)
|
||||
}
|
||||
|
||||
archive.Checksum = *csum
|
||||
@@ -121,7 +119,7 @@ func getArchiveURL(ctx context.Context, client cmd.Client, archiveID string, ser
|
||||
func GetContents(filePath string) ([]byte, error) {
|
||||
code, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "error reading %v", filePath)
|
||||
return nil, fmt.Errorf("error reading %v: %w", filePath, err)
|
||||
}
|
||||
return code, nil
|
||||
}
|
||||
@@ -131,13 +129,13 @@ func GetContents(filePath string) ([]byte, error) {
|
||||
func DownloadToTempFile(fileUrl string) (string, error) {
|
||||
reader, err := DownloadURL(fileUrl)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "error downloading from url: %v", fileUrl)
|
||||
return "", fmt.Errorf("error downloading from url: %v: %w", fileUrl, err)
|
||||
}
|
||||
defer reader.Close()
|
||||
|
||||
tmpDir, err := utils.GetTempDir()
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "error creating temp directory %v", tmpDir)
|
||||
return "", fmt.Errorf("error creating temp directory %v: %w", tmpDir, err)
|
||||
}
|
||||
|
||||
tmpFilename := uuid.NewString()
|
||||
@@ -145,7 +143,7 @@ func DownloadToTempFile(fileUrl string) (string, error) {
|
||||
|
||||
err = WriteArchiveToFile(destination, reader)
|
||||
if err != nil {
|
||||
return "", errors.Wrapf(err, "error writing archive to file %v", destination)
|
||||
return "", fmt.Errorf("error writing archive to file %v: %w", destination, err)
|
||||
}
|
||||
|
||||
return destination, nil
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
|
||||
@@ -145,14 +144,14 @@ func (opts *ApplySubCommand) run(input cli.Input) error {
|
||||
var err error
|
||||
watcher, err = fsnotify.NewWatcher()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating file watcher")
|
||||
return fmt.Errorf("error creating file watcher: %w", err)
|
||||
}
|
||||
|
||||
// add watches
|
||||
rootDir := filepath.Clean(specDir + "/..")
|
||||
err = filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error scanning project files")
|
||||
return fmt.Errorf("error scanning project files: %w", err)
|
||||
}
|
||||
|
||||
if ignoreFile(path) {
|
||||
@@ -161,12 +160,12 @@ func (opts *ApplySubCommand) run(input cli.Input) error {
|
||||
|
||||
err = watcher.Add(path)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error watching path %v", path))
|
||||
return fmt.Errorf("error watching path %v: %w", path, err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error scanning files to watch")
|
||||
return fmt.Errorf("error scanning files to watch: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,19 +173,19 @@ func (opts *ApplySubCommand) run(input cli.Input) error {
|
||||
// read all specs
|
||||
fr, err := ReadSpecs(specDir, specIgnore, applyCommitLabel)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading specs")
|
||||
return fmt.Errorf("error reading specs: %w", err)
|
||||
}
|
||||
|
||||
if validateSpecs {
|
||||
err = validateForApply(input, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "abort applying resources")
|
||||
return fmt.Errorf("abort applying resources: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
err = opts.insertNamespace(input, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error inserting namespace")
|
||||
return fmt.Errorf("error inserting namespace: %w", err)
|
||||
}
|
||||
|
||||
err = warnIfDirtyWorkTree(filepath.Clean(specDir + "/.."))
|
||||
@@ -197,7 +196,7 @@ func (opts *ApplySubCommand) run(input cli.Input) error {
|
||||
// make changes to the cluster based on the specs
|
||||
pkgMetas, as, err := applyResources(input, opts.Client(), specDir, fr, deleteResources, input.Bool(flagkey.SpecAllowConflicts))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error applying specs")
|
||||
return fmt.Errorf("error applying specs: %w", err)
|
||||
}
|
||||
printApplyStatus(as)
|
||||
|
||||
@@ -239,7 +238,7 @@ func (opts *ApplySubCommand) run(input cli.Input) error {
|
||||
|
||||
err = waitForFileWatcherToSettleDown(watcher)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error watching files")
|
||||
return fmt.Errorf("error watching files: %w", err)
|
||||
}
|
||||
break waitloop
|
||||
|
||||
@@ -247,7 +246,7 @@ func (opts *ApplySubCommand) run(input cli.Input) error {
|
||||
pkgWatchCancel()
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error watching files")
|
||||
return fmt.Errorf("error watching files: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -408,7 +407,7 @@ func applyArchives(input cli.Input, fclient cmd.Client, specDir string, fr *Fiss
|
||||
if strings.HasPrefix(ar.URL, ARCHIVE_URL_PREFIX) {
|
||||
availableAr, ok := archiveFiles[ar.URL]
|
||||
if !ok {
|
||||
return errors.Errorf("unknown archive name %v", strings.TrimPrefix(ar.URL, ARCHIVE_URL_PREFIX))
|
||||
return fmt.Errorf("unknown archive name %v", strings.TrimPrefix(ar.URL, ARCHIVE_URL_PREFIX))
|
||||
}
|
||||
ar.Type = availableAr.Type
|
||||
ar.Literal = availableAr.Literal
|
||||
@@ -433,13 +432,13 @@ func applyResources(input cli.Input, fclient cmd.Client, specDir string, fr *Fis
|
||||
|
||||
_, ras, err := applyEnvironments(input.Context(), fclient, fr, delete, specAllowConflicts)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "environment apply failed")
|
||||
return nil, nil, fmt.Errorf("environment apply failed: %w", err)
|
||||
}
|
||||
applyStatus["environment"] = *ras
|
||||
|
||||
pkgMeta, ras, err := applyPackages(input.Context(), fclient, fr, delete, specAllowConflicts)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "package apply failed")
|
||||
return nil, nil, fmt.Errorf("package apply failed: %w", err)
|
||||
}
|
||||
applyStatus["package"] = *ras
|
||||
|
||||
@@ -460,7 +459,7 @@ func applyResources(input cli.Input, fclient cmd.Client, specDir string, fr *Fis
|
||||
// spec. It may exist outside the spec, but we're going to treat
|
||||
// that as an error, so that we encourage self-contained specs.
|
||||
// Is there a good use case for non-self contained specs?
|
||||
return nil, nil, errors.Errorf("function %v/%v references package %v/%v, which doesn't exist in the specs",
|
||||
return nil, nil, fmt.Errorf("function %v/%v references package %v/%v, which doesn't exist in the specs",
|
||||
f.ObjectMeta.Namespace, f.ObjectMeta.Name, f.Spec.Package.PackageRef.Namespace, f.Spec.Package.PackageRef.Name)
|
||||
}
|
||||
fr.Functions[i].Spec.Package.PackageRef.ResourceVersion = m.ResourceVersion
|
||||
@@ -468,31 +467,31 @@ func applyResources(input cli.Input, fclient cmd.Client, specDir string, fr *Fis
|
||||
|
||||
_, ras, err = applyFunctions(input.Context(), fclient, fr, delete, specAllowConflicts)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "function apply failed")
|
||||
return nil, nil, fmt.Errorf("function apply failed: %w", err)
|
||||
}
|
||||
applyStatus["function"] = *ras
|
||||
|
||||
_, ras, err = applyHTTPTriggers(input.Context(), fclient, fr, delete, specAllowConflicts)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "HTTPTrigger apply failed")
|
||||
return nil, nil, fmt.Errorf("HTTPTrigger apply failed: %w", err)
|
||||
}
|
||||
applyStatus["HTTPTrigger"] = *ras
|
||||
|
||||
_, ras, err = applyKubernetesWatchTriggers(input.Context(), fclient, fr, delete, specAllowConflicts)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "KubernetesWatchTrigger apply failed")
|
||||
return nil, nil, fmt.Errorf("KubernetesWatchTrigger apply failed: %w", err)
|
||||
}
|
||||
applyStatus["KubernetesWatchTrigger"] = *ras
|
||||
|
||||
_, ras, err = applyTimeTriggers(input.Context(), fclient, fr, delete, specAllowConflicts)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "TimeTrigger apply failed")
|
||||
return nil, nil, fmt.Errorf("TimeTrigger apply failed: %w", err)
|
||||
}
|
||||
applyStatus["TimeTrigger"] = *ras
|
||||
|
||||
_, ras, err = applyMessageQueueTriggers(input.Context(), fclient, fr, delete, specAllowConflicts)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "MessageQueueTrigger apply failed")
|
||||
return nil, nil, fmt.Errorf("MessageQueueTrigger apply failed: %w", err)
|
||||
}
|
||||
applyStatus["MessageQueueTrigger"] = *ras
|
||||
|
||||
@@ -526,14 +525,14 @@ func localArchiveFromSpec(ctx context.Context, specDir string, aus *spectypes.Ar
|
||||
console.Verbose(2, "try to find globs in path '%v'", absGlob)
|
||||
fs, err := utils.FindAllGlobs(absGlob)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "Invalid glob in archive %v: %v", aus.Name, relativeGlob)
|
||||
return nil, fmt.Errorf("Invalid glob in archive %v: %v: %w", aus.Name, relativeGlob, err)
|
||||
}
|
||||
files = append(files, fs...)
|
||||
}
|
||||
}
|
||||
|
||||
if len(files) == 0 {
|
||||
return nil, errors.Errorf("archive '%v' is empty", aus.Name)
|
||||
return nil, fmt.Errorf("archive '%v' is empty", aus.Name)
|
||||
}
|
||||
|
||||
// if it's just one file, use its path directly
|
||||
@@ -585,7 +584,7 @@ func localArchiveFromSpec(ctx context.Context, specDir string, aus *spectypes.Ar
|
||||
// checksum
|
||||
csum, err := utils.GetFileChecksum(archiveFileName)
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("failed to calculate archive checksum for %v (%v): %v", aus.Name, archiveFileName, err)
|
||||
return nil, fmt.Errorf("failed to calculate archive checksum for %v (%v): %v", aus.Name, archiveFileName, err)
|
||||
}
|
||||
|
||||
// archive object
|
||||
@@ -626,7 +625,7 @@ func waitForPackageBuild(ctx context.Context, fclient cmd.Client, pkg *fv1.Packa
|
||||
return pkg, nil
|
||||
}
|
||||
if time.Since(start) > 5*time.Minute {
|
||||
return nil, errors.Errorf("package %v has been building for a while, giving up on waiting for it", pkg.ObjectMeta.Name)
|
||||
return nil, fmt.Errorf("package %v has been building for a while, giving up on waiting for it", pkg.ObjectMeta.Name)
|
||||
}
|
||||
|
||||
// TODO watch instead
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
|
||||
@@ -55,13 +54,13 @@ func (opts *DestroySubCommand) run(input cli.Input) error {
|
||||
// read everything
|
||||
fr, err := ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading specs")
|
||||
return fmt.Errorf("error reading specs: %w", err)
|
||||
}
|
||||
|
||||
if !input.Bool(flagkey.ForceDelete) {
|
||||
err = opts.insertNSToResource(input, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error adding namespace")
|
||||
return fmt.Errorf("error adding namespace: %w", err)
|
||||
}
|
||||
} else {
|
||||
// if force delete set to true we fetch all resources with our deployment ID and delete them
|
||||
@@ -72,14 +71,14 @@ func (opts *DestroySubCommand) run(input cli.Input) error {
|
||||
// "apply" the empty state
|
||||
err = forceDeleteResources(input.Context(), opts.Client(), &emptyFr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error deleting resources")
|
||||
return fmt.Errorf("error deleting resources: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
forceDelete := input.Bool(flagkey.ForceDelete)
|
||||
err = deleteResources(input.Context(), opts.Client(), fr, forceDelete)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error deleting resources")
|
||||
return fmt.Errorf("error deleting resources: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -91,37 +90,37 @@ func forceDeleteResources(ctx context.Context, fclient cmd.Client, fr *FissionRe
|
||||
|
||||
_, _, err = applyHTTPTriggers(ctx, fclient, fr, true, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "HTTPTrigger delete failed")
|
||||
return fmt.Errorf("HTTPTrigger delete failed: %w", err)
|
||||
}
|
||||
|
||||
_, _, err = applyKubernetesWatchTriggers(ctx, fclient, fr, true, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "KubernetesWatchTrigger delete failed")
|
||||
return fmt.Errorf("KubernetesWatchTrigger delete failed: %w", err)
|
||||
}
|
||||
|
||||
_, _, err = applyTimeTriggers(ctx, fclient, fr, true, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "TimeTrigger delete failed")
|
||||
return fmt.Errorf("TimeTrigger delete failed: %w", err)
|
||||
}
|
||||
|
||||
_, _, err = applyMessageQueueTriggers(ctx, fclient, fr, true, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "MessageQueueTrigger delete failed")
|
||||
return fmt.Errorf("MessageQueueTrigger delete failed: %w", err)
|
||||
}
|
||||
|
||||
_, _, err = applyFunctions(ctx, fclient, fr, true, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "function delete failed")
|
||||
return fmt.Errorf("function delete failed: %w", err)
|
||||
}
|
||||
|
||||
_, _, err = applyPackages(ctx, fclient, fr, true, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "package delete failed")
|
||||
return fmt.Errorf("package delete failed: %w", err)
|
||||
}
|
||||
|
||||
_, _, err = applyEnvironments(ctx, fclient, fr, true, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "environment delete failed")
|
||||
return fmt.Errorf("environment delete failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -183,37 +182,37 @@ func deleteResources(ctx context.Context, fclient cmd.Client, fr *FissionResourc
|
||||
|
||||
err = destroyHTTPTriggers(ctx, fclient, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "HTTPTrigger delete failed")
|
||||
return fmt.Errorf("HTTPTrigger delete failed: %w", err)
|
||||
}
|
||||
|
||||
err = destroyKubernetesWatchTriggers(ctx, fclient, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "KubernetesWatchTrigger delete failed")
|
||||
return fmt.Errorf("KubernetesWatchTrigger delete failed: %w", err)
|
||||
}
|
||||
|
||||
err = destroyTimeTriggers(ctx, fclient, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "TimeTrigger delete failed")
|
||||
return fmt.Errorf("TimeTrigger delete failed: %w", err)
|
||||
}
|
||||
|
||||
err = destroyMessageQueueTriggers(ctx, fclient, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "MessageQueueTrigger delete failed")
|
||||
return fmt.Errorf("MessageQueueTrigger delete failed: %w", err)
|
||||
}
|
||||
|
||||
err = destroyFunctions(ctx, fclient, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "function delete failed")
|
||||
return fmt.Errorf("function delete failed: %w", err)
|
||||
}
|
||||
|
||||
err = destroyPackages(ctx, fclient, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "package delete failed")
|
||||
return fmt.Errorf("package delete failed: %w", err)
|
||||
}
|
||||
|
||||
err = destroyEnvironments(ctx, fclient, fr)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "environment delete failed")
|
||||
return fmt.Errorf("environment delete failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -58,7 +57,7 @@ func (opts *InitSubCommand) complete(input cli.Input) error {
|
||||
// come up with a name using the current dir
|
||||
dir, err := filepath.Abs(".")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting current working directory")
|
||||
return fmt.Errorf("error getting current working directory: %w", err)
|
||||
}
|
||||
basename := filepath.Base(dir)
|
||||
name = util.KubifyName(basename)
|
||||
@@ -73,7 +72,7 @@ func (opts *InitSubCommand) complete(input cli.Input) error {
|
||||
fmt.Printf("Creating fission spec directory '%v'\n", specDir)
|
||||
err := os.MkdirAll(specDir, 0755)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "create spec directory '%v'", specDir)
|
||||
return fmt.Errorf("create spec directory '%v': %w", specDir, err)
|
||||
}
|
||||
|
||||
// Write the deployment config
|
||||
@@ -101,7 +100,7 @@ func (opts *InitSubCommand) run(input cli.Input) error {
|
||||
config := filepath.Join(specDir, "fission-deployment-config.yaml")
|
||||
|
||||
if _, err := os.Stat(config); err == nil {
|
||||
return errors.Errorf("Spec DeploymentConfig already exists in directory '%v'", specDir)
|
||||
return fmt.Errorf("Spec DeploymentConfig already exists in directory '%v'", specDir)
|
||||
}
|
||||
|
||||
// Add a bit of documentation to the spec dir here
|
||||
@@ -112,7 +111,7 @@ func (opts *InitSubCommand) run(input cli.Input) error {
|
||||
|
||||
err = writeDeploymentConfig(config, opts.deployConfig)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error writing deployment config")
|
||||
return fmt.Errorf("error writing deployment config: %w", err)
|
||||
}
|
||||
|
||||
// Other possible things to do here:
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -56,7 +55,7 @@ func (opts *ListSubCommand) run(input cli.Input) error {
|
||||
specIgnore := util.GetSpecIgnore(input)
|
||||
fr, err := ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading specs")
|
||||
return fmt.Errorf("error reading specs: %w", err)
|
||||
}
|
||||
deployID = fr.DeploymentConfig.UID
|
||||
}
|
||||
@@ -83,7 +82,7 @@ func (opts *ListSubCommand) getResource(input cli.Input, namespace string, deplo
|
||||
|
||||
allfn, err = getAllFunctions(input.Context(), opts.Client(), namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error getting Functions from %s namespaces", printNS))
|
||||
return fmt.Errorf("error getting Functions from %s namespaces: %w", printNS, err)
|
||||
}
|
||||
specfns := getAppliedFunctions(allfn, deployID)
|
||||
ShowFunctions(specfns)
|
||||
@@ -91,7 +90,7 @@ func (opts *ListSubCommand) getResource(input cli.Input, namespace string, deplo
|
||||
var allenvs []fv1.Environment
|
||||
allenvs, err = getAllEnvironments(input.Context(), opts.Client(), namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error getting Environments from %s namespaces", printNS))
|
||||
return fmt.Errorf("error getting Environments from %s namespaces: %w", printNS, err)
|
||||
}
|
||||
specenvs := getAppliedEnvironments(allenvs, deployID)
|
||||
ShowEnvironments(specenvs)
|
||||
@@ -99,7 +98,7 @@ func (opts *ListSubCommand) getResource(input cli.Input, namespace string, deplo
|
||||
var pkglists []fv1.Package
|
||||
pkglists, err = getAllPackages(input.Context(), opts.Client(), namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error getting Packages from %s namespaces", printNS))
|
||||
return fmt.Errorf("error getting Packages from %s namespaces: %w", printNS, err)
|
||||
}
|
||||
specPkgs := getAppliedPackages(pkglists, deployID)
|
||||
ShowPackages(specPkgs)
|
||||
@@ -107,7 +106,7 @@ func (opts *ListSubCommand) getResource(input cli.Input, namespace string, deplo
|
||||
var canaryCfgs []fv1.CanaryConfig
|
||||
canaryCfgs, err = getAllCanaryConfigs(input.Context(), opts.Client(), namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error getting Canary Config from %s namespaces", printNS))
|
||||
return fmt.Errorf("error getting Canary Config from %s namespaces: %w", printNS, err)
|
||||
}
|
||||
specCanaryCfgs := getAppliedCanaryConfigs(canaryCfgs, deployID)
|
||||
ShowCanaryConfigs(specCanaryCfgs)
|
||||
@@ -115,7 +114,7 @@ func (opts *ListSubCommand) getResource(input cli.Input, namespace string, deplo
|
||||
var hts []fv1.HTTPTrigger
|
||||
hts, err = getAllHTTPTriggers(input.Context(), opts.Client(), namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error getting HTTP Triggers from %s namespaces", printNS))
|
||||
return fmt.Errorf("error getting HTTP Triggers from %s namespaces: %w", printNS, err)
|
||||
}
|
||||
specHTTPTriggers := getAppliedHTTPTriggers(hts, deployID)
|
||||
ShowHTTPTriggers(specHTTPTriggers)
|
||||
@@ -123,7 +122,7 @@ func (opts *ListSubCommand) getResource(input cli.Input, namespace string, deplo
|
||||
var mqts []fv1.MessageQueueTrigger
|
||||
mqts, err = getAllMessageQueueTriggers(input.Context(), opts.Client(), input.String(flagkey.MqtMQType), namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error getting MessageQueue Triggers from %s namespaces", printNS))
|
||||
return fmt.Errorf("error getting MessageQueue Triggers from %s namespaces: %w", printNS, err)
|
||||
}
|
||||
specMessageQueueTriggers := getAppliedMessageQueueTriggers(mqts, deployID)
|
||||
ShowMQTriggers(specMessageQueueTriggers)
|
||||
@@ -131,7 +130,7 @@ func (opts *ListSubCommand) getResource(input cli.Input, namespace string, deplo
|
||||
var tts []fv1.TimeTrigger
|
||||
tts, err = getAllTimeTriggers(input.Context(), opts.Client(), namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error getting Time Triggers from %s namespaces", printNS))
|
||||
return fmt.Errorf("error getting Time Triggers from %s namespaces: %w", printNS, err)
|
||||
}
|
||||
specTimeTriggers := getAppliedTimeTriggers(tts, deployID)
|
||||
ShowTimeTriggers(specTimeTriggers)
|
||||
@@ -139,7 +138,7 @@ func (opts *ListSubCommand) getResource(input cli.Input, namespace string, deplo
|
||||
var kws []fv1.KubernetesWatchTrigger
|
||||
kws, err = getAllKubeWatchTriggers(input.Context(), opts.Client(), namespace)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error getting Kube Watchers from %s namespaces", printNS))
|
||||
return fmt.Errorf("error getting Kube Watchers from %s namespaces: %w", printNS, err)
|
||||
}
|
||||
specKubeWatchers := getSpecKubeWatchers(kws, deployID)
|
||||
ShowAppliedKubeWatchers(specKubeWatchers)
|
||||
@@ -424,7 +423,7 @@ func ShowAppliedKubeWatchers(ws []fv1.KubernetesWatchTrigger) {
|
||||
func getAllFunctions(ctx context.Context, client cmd.Client, namespace string) ([]fv1.Function, error) {
|
||||
fns, err := client.FissionClientSet.CoreV1().Functions(namespace).List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Unable to get Functions %v", err.Error())
|
||||
return nil, fmt.Errorf("Unable to get Functions %v", err.Error())
|
||||
}
|
||||
return fns.Items, nil
|
||||
}
|
||||
@@ -433,7 +432,7 @@ func getAllFunctions(ctx context.Context, client cmd.Client, namespace string) (
|
||||
func getAllEnvironments(ctx context.Context, client cmd.Client, namespace string) ([]fv1.Environment, error) {
|
||||
envs, err := client.FissionClientSet.CoreV1().Environments(namespace).List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Unable to get Environments %v", err.Error())
|
||||
return nil, fmt.Errorf("Unable to get Environments %v", err.Error())
|
||||
}
|
||||
return envs.Items, nil
|
||||
}
|
||||
@@ -442,7 +441,7 @@ func getAllEnvironments(ctx context.Context, client cmd.Client, namespace string
|
||||
func getAllPackages(ctx context.Context, client cmd.Client, namespace string) ([]fv1.Package, error) {
|
||||
pkgList, err := client.FissionClientSet.CoreV1().Packages(namespace).List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Unable to get Packages %v", err.Error())
|
||||
return nil, fmt.Errorf("Unable to get Packages %v", err.Error())
|
||||
}
|
||||
return pkgList.Items, nil
|
||||
}
|
||||
@@ -451,7 +450,7 @@ func getAllPackages(ctx context.Context, client cmd.Client, namespace string) ([
|
||||
func getAllCanaryConfigs(ctx context.Context, client cmd.Client, namespace string) ([]fv1.CanaryConfig, error) {
|
||||
canaryCfgs, err := client.FissionClientSet.CoreV1().CanaryConfigs(namespace).List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Unable to get Canary Configs %v", err.Error())
|
||||
return nil, fmt.Errorf("Unable to get Canary Configs %v", err.Error())
|
||||
}
|
||||
return canaryCfgs.Items, nil
|
||||
}
|
||||
@@ -460,7 +459,7 @@ func getAllCanaryConfigs(ctx context.Context, client cmd.Client, namespace strin
|
||||
func getAllHTTPTriggers(ctx context.Context, client cmd.Client, namespace string) ([]fv1.HTTPTrigger, error) {
|
||||
hts, err := client.FissionClientSet.CoreV1().HTTPTriggers(namespace).List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Unable to get HTTP Triggers %v", err.Error())
|
||||
return nil, fmt.Errorf("Unable to get HTTP Triggers %v", err.Error())
|
||||
}
|
||||
return hts.Items, nil
|
||||
}
|
||||
@@ -469,7 +468,7 @@ func getAllHTTPTriggers(ctx context.Context, client cmd.Client, namespace string
|
||||
func getAllMessageQueueTriggers(ctx context.Context, client cmd.Client, mqttype string, namespace string) ([]fv1.MessageQueueTrigger, error) {
|
||||
mqts, err := client.FissionClientSet.CoreV1().MessageQueueTriggers(namespace).List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Unable to get MessageQueue Triggers %v", err.Error())
|
||||
return nil, fmt.Errorf("Unable to get MessageQueue Triggers %v", err.Error())
|
||||
}
|
||||
return mqts.Items, nil
|
||||
}
|
||||
@@ -478,7 +477,7 @@ func getAllMessageQueueTriggers(ctx context.Context, client cmd.Client, mqttype
|
||||
func getAllTimeTriggers(ctx context.Context, client cmd.Client, namespace string) ([]fv1.TimeTrigger, error) {
|
||||
tts, err := client.FissionClientSet.CoreV1().TimeTriggers(namespace).List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Unable to get Time Triggers %v", err.Error())
|
||||
return nil, fmt.Errorf("Unable to get Time Triggers %v", err.Error())
|
||||
}
|
||||
return tts.Items, nil
|
||||
}
|
||||
@@ -487,7 +486,7 @@ func getAllTimeTriggers(ctx context.Context, client cmd.Client, namespace string
|
||||
func getAllKubeWatchTriggers(ctx context.Context, client cmd.Client, namespace string) ([]fv1.KubernetesWatchTrigger, error) {
|
||||
ws, err := client.FissionClientSet.CoreV1().KubernetesWatchTriggers(namespace).List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, errors.Errorf("Unable to get Kube Watchers %v", err.Error())
|
||||
return nil, fmt.Errorf("Unable to get Kube Watchers %v", err.Error())
|
||||
}
|
||||
return ws.Items, nil
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"strings"
|
||||
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
k8sCache "k8s.io/client-go/tools/cache"
|
||||
@@ -128,7 +127,7 @@ type (
|
||||
func save(data []byte, specDir string, specFile string, truncate bool) error {
|
||||
// verify
|
||||
if _, err := os.Stat(filepath.Join(specDir, "fission-deployment-config.yaml")); os.IsNotExist(err) {
|
||||
return errors.Wrap(err, "Couldn't find specs, run `fission spec init` first")
|
||||
return fmt.Errorf("Couldn't find specs, run `fission spec init` first: %w", err)
|
||||
}
|
||||
|
||||
filename := filepath.Join(specDir, specFile)
|
||||
@@ -136,7 +135,7 @@ func save(data []byte, specDir string, specFile string, truncate bool) error {
|
||||
newFile := false
|
||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||
if truncate {
|
||||
return errors.Errorf("spec file does not exists")
|
||||
return fmt.Errorf("spec file does not exists")
|
||||
}
|
||||
newFile = true
|
||||
}
|
||||
@@ -144,14 +143,14 @@ func save(data []byte, specDir string, specFile string, truncate bool) error {
|
||||
// open spec file to append or write
|
||||
f, err := os.OpenFile(filename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "couldn't create spec file")
|
||||
return fmt.Errorf("couldn't create spec file: %w", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
if truncate {
|
||||
err = f.Truncate(0)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "couldn't truncate the spec file")
|
||||
return fmt.Errorf("couldn't truncate the spec file: %w", err)
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -159,7 +158,7 @@ func save(data []byte, specDir string, specFile string, truncate bool) error {
|
||||
if !newFile {
|
||||
_, err = f.Write([]byte("\n---\n"))
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "couldn't write to spec file")
|
||||
return fmt.Errorf("couldn't write to spec file: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,7 +166,7 @@ func save(data []byte, specDir string, specFile string, truncate bool) error {
|
||||
// write our resource
|
||||
_, err = f.Write(data)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "couldn't write to spec file")
|
||||
return fmt.Errorf("couldn't write to spec file: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -183,7 +182,7 @@ func SpecSave(resource interface{}, specFile string, update bool) error {
|
||||
|
||||
fr, err := ReadSpecs(specDir, util.SPEC_IGNORE_FILE, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%v'", specDir))
|
||||
return fmt.Errorf("error reading spec in '%v': %w", specDir, err)
|
||||
}
|
||||
|
||||
exists, err := fr.ExistsInSpecs(resource)
|
||||
@@ -192,7 +191,7 @@ func SpecSave(resource interface{}, specFile string, update bool) error {
|
||||
}
|
||||
|
||||
if exists {
|
||||
return errors.Errorf("same name resource (%v) already exists in namespace (%v)", meta.Name, meta.Namespace)
|
||||
return fmt.Errorf("same name resource (%v) already exists in namespace (%v)", meta.Name, meta.Namespace)
|
||||
}
|
||||
|
||||
truncate := false
|
||||
@@ -277,11 +276,11 @@ func crdToYaml(resource interface{}) (metav1.ObjectMeta, string, []byte, error)
|
||||
kind = typedres.TypeMeta.Kind
|
||||
data, err = yaml.Marshal(typedres)
|
||||
default:
|
||||
err = errors.Errorf("unknown object type '%v'", typedres)
|
||||
err = fmt.Errorf("unknown object type '%v'", typedres)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return metav1.ObjectMeta{}, "", nil, errors.Wrap(err, "couldn't marshal YAML")
|
||||
return metav1.ObjectMeta{}, "", nil, fmt.Errorf("couldn't marshal YAML: %w", err)
|
||||
}
|
||||
|
||||
return meta, kind, data, nil
|
||||
@@ -559,7 +558,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var tm types.TypeMeta
|
||||
err := yaml.Unmarshal(b, &tm)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to decode yaml %v", string(b)))
|
||||
return fmt.Errorf("Failed to decode yaml %s: %w", string(b), err)
|
||||
}
|
||||
|
||||
switch tm.Kind {
|
||||
@@ -567,7 +566,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var v fv1.Package
|
||||
err = yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err)
|
||||
}
|
||||
m = &v.ObjectMeta
|
||||
applyCommitLabel(commitLabelVal, m)
|
||||
@@ -576,7 +575,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var v fv1.Function
|
||||
err = yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err)
|
||||
}
|
||||
m = &v.ObjectMeta
|
||||
applyCommitLabel(commitLabelVal, m)
|
||||
@@ -585,7 +584,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var v fv1.Environment
|
||||
err = yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err)
|
||||
}
|
||||
m = &v.ObjectMeta
|
||||
applyCommitLabel(commitLabelVal, m)
|
||||
@@ -594,7 +593,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var v fv1.HTTPTrigger
|
||||
err = yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err)
|
||||
}
|
||||
m = &v.ObjectMeta
|
||||
applyCommitLabel(commitLabelVal, m)
|
||||
@@ -603,7 +602,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var v fv1.KubernetesWatchTrigger
|
||||
err = yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err)
|
||||
}
|
||||
m = &v.ObjectMeta
|
||||
applyCommitLabel(commitLabelVal, m)
|
||||
@@ -612,7 +611,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var v fv1.TimeTrigger
|
||||
err = yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err)
|
||||
}
|
||||
m = &v.ObjectMeta
|
||||
applyCommitLabel(commitLabelVal, m)
|
||||
@@ -621,7 +620,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var v fv1.MessageQueueTrigger
|
||||
err = yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err)
|
||||
}
|
||||
m = &v.ObjectMeta
|
||||
applyCommitLabel(commitLabelVal, m)
|
||||
@@ -633,7 +632,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var v types.DeploymentConfig
|
||||
err = yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err)
|
||||
}
|
||||
|
||||
fr.DeploymentConfig = v
|
||||
@@ -641,7 +640,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st
|
||||
var v types.ArchiveUploadSpec
|
||||
err = yaml.Unmarshal(b, &v)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("Failed to parse %v in %v", tm.Kind, loc))
|
||||
return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err)
|
||||
}
|
||||
|
||||
m = &metav1.ObjectMeta{
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
@@ -71,7 +70,7 @@ func (opts *ValidateSubCommand) run(input cli.Input, fr *FissionResources) (err
|
||||
if fr == nil {
|
||||
fr, err = ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading specs")
|
||||
return fmt.Errorf("error reading specs: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,12 +82,12 @@ func (opts *ValidateSubCommand) run(input cli.Input, fr *FissionResources) (err
|
||||
// this does the rest of the checks, like dangling refs
|
||||
warnings, err = fr.Validate(input, opts.Client())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error validating specs")
|
||||
return fmt.Errorf("error validating specs: %w", err)
|
||||
}
|
||||
|
||||
err = resourceConflictCheck(input.Context(), opts.Client(), fr, input.Bool(flagkey.SpecAllowConflicts), "")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "name conflict error")
|
||||
return fmt.Errorf("name conflict error: %w", err)
|
||||
}
|
||||
|
||||
for _, warning := range warnings {
|
||||
@@ -110,7 +109,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc
|
||||
|
||||
fnList, err := getAllFunctions(ctx, c, namespace)
|
||||
if err != nil {
|
||||
return errors.Errorf("Unable to get Functions %v", err.Error())
|
||||
return fmt.Errorf("Unable to get Functions %v", err.Error())
|
||||
}
|
||||
for _, sObj := range fr.Functions {
|
||||
for _, cObj := range fnList {
|
||||
@@ -123,7 +122,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc
|
||||
|
||||
envList, err := getAllEnvironments(ctx, c, namespace)
|
||||
if err != nil {
|
||||
return errors.Errorf("Unable to get Environments %v", err.Error())
|
||||
return fmt.Errorf("Unable to get Environments %v", err.Error())
|
||||
}
|
||||
for _, sObj := range fr.Environments {
|
||||
for _, cObj := range envList {
|
||||
@@ -136,7 +135,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc
|
||||
|
||||
pkgList, err := getAllPackages(ctx, c, namespace)
|
||||
if err != nil {
|
||||
return errors.Errorf("Unable to get Packages %v", err.Error())
|
||||
return fmt.Errorf("Unable to get Packages %v", err.Error())
|
||||
}
|
||||
for _, sObj := range fr.Packages {
|
||||
for _, cObj := range pkgList {
|
||||
@@ -149,7 +148,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc
|
||||
|
||||
httptriggerList, err := getAllHTTPTriggers(ctx, c, namespace)
|
||||
if err != nil {
|
||||
return errors.Errorf("Unable to get HTTPTrigger %v", err.Error())
|
||||
return fmt.Errorf("Unable to get HTTPTrigger %v", err.Error())
|
||||
}
|
||||
for _, sObj := range fr.HttpTriggers {
|
||||
for _, cObj := range httptriggerList {
|
||||
@@ -162,7 +161,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc
|
||||
|
||||
mqtriggerList, err := getAllMessageQueueTriggers(ctx, c, "", namespace)
|
||||
if err != nil {
|
||||
return errors.Errorf("Unable to get Message Queue Trigger %v", err.Error())
|
||||
return fmt.Errorf("Unable to get Message Queue Trigger %v", err.Error())
|
||||
}
|
||||
for _, sObj := range fr.MessageQueueTriggers {
|
||||
for _, cObj := range mqtriggerList {
|
||||
@@ -175,7 +174,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc
|
||||
|
||||
timetriggerList, err := getAllTimeTriggers(ctx, c, namespace)
|
||||
if err != nil {
|
||||
return errors.Errorf("Unable to get Time Trigger %v", err.Error())
|
||||
return fmt.Errorf("Unable to get Time Trigger %v", err.Error())
|
||||
}
|
||||
for _, sObj := range fr.TimeTriggers {
|
||||
for _, cObj := range timetriggerList {
|
||||
@@ -188,7 +187,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc
|
||||
|
||||
kubewatchtriggerList, err := getAllKubeWatchTriggers(ctx, c, namespace)
|
||||
if err != nil {
|
||||
return errors.Errorf("Unable to get Kubernetes Watch Trigger %v", err.Error())
|
||||
return fmt.Errorf("Unable to get Kubernetes Watch Trigger %v", err.Error())
|
||||
}
|
||||
for _, sObj := range fr.KubernetesWatchTriggers {
|
||||
for _, cObj := range kubewatchtriggerList {
|
||||
@@ -226,7 +225,7 @@ func ReadSpecs(specDir, specIgnore string, applyCommitLabel bool) (*FissionResou
|
||||
|
||||
// make sure spec directory exists before continue
|
||||
if _, err := os.Stat(specDir); os.IsNotExist(err) {
|
||||
return nil, errors.Errorf("Spec directory %v doesn't exist. "+
|
||||
return nil, fmt.Errorf("Spec directory %v doesn't exist. "+
|
||||
"Please check directory path or run \"fission spec init\" to create it.", specDir)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"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"
|
||||
@@ -58,12 +56,12 @@ func (opts *DumpSubCommand) do(input cli.Input) error {
|
||||
panic(err)
|
||||
}
|
||||
} else if err != nil {
|
||||
panic(errors.Wrap(err, "Error checking dump directory status"))
|
||||
panic(fmt.Errorf("Error checking dump directory status: %w", err))
|
||||
}
|
||||
|
||||
outputDir, err = filepath.Abs(outputDir)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "Error creating dump directory for dumping files"))
|
||||
panic(fmt.Errorf("Error creating dump directory for dumping files: %w", err))
|
||||
}
|
||||
|
||||
k8sClient := opts.Client().KubernetesClient
|
||||
|
||||
@@ -23,7 +23,8 @@ import (
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
"github.com/fission/fission/pkg/utils/uuid"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -65,7 +66,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
|
||||
|
||||
userProvidedNS, fnNamespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
cronSpec := input.String(flagkey.TtCron)
|
||||
@@ -78,7 +79,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
|
||||
specIgnore := util.GetSpecIgnore(input)
|
||||
fr, err := spec.ReadSpecs(specDir, specIgnore, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%v'", specDir))
|
||||
return fmt.Errorf("error reading spec in '%v': %w", specDir, err)
|
||||
}
|
||||
|
||||
exists, err := fr.ExistsInSpecs(fv1.Function{
|
||||
@@ -135,14 +136,14 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
specFile := fmt.Sprintf("timetrigger-%v.yaml", opts.trigger.ObjectMeta.Name)
|
||||
err := spec.SpecSave(*opts.trigger, specFile, false)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving time trigger spec")
|
||||
return fmt.Errorf("error saving time trigger spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().TimeTriggers(opts.trigger.Namespace).Create(input.Context(), opts.trigger, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating Time trigger")
|
||||
return fmt.Errorf("error creating Time trigger: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' created\n", opts.trigger.ObjectMeta.Name)
|
||||
@@ -151,7 +152,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
|
||||
err = getCronNextNActivationTime(opts.trigger.Spec.Cron, t, 1)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error passing cron spec examination")
|
||||
return fmt.Errorf("error passing cron spec examination: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -19,7 +19,6 @@ package timetrigger
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
kerrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
@@ -40,7 +39,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) (err error) {
|
||||
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
err = opts.Client().FissionClientSet.CoreV1().TimeTriggers(namespace).Delete(input.Context(), input.String(flagkey.TtName), metav1.DeleteOptions{})
|
||||
@@ -48,7 +47,7 @@ func (opts *DeleteSubCommand) do(input cli.Input) (err error) {
|
||||
if input.Bool(flagkey.IgnoreNotFound) && kerrors.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrap(err, "error deleting trigger")
|
||||
return fmt.Errorf("error deleting trigger: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' deleted\n", input.String(flagkey.TtName))
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -40,7 +39,7 @@ func List(input cli.Input) error {
|
||||
func (opts *ListSubCommand) do(input cli.Input) (err error) {
|
||||
_, ttNs, err := opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
if input.Bool(flagkey.AllNamespaces) {
|
||||
@@ -49,7 +48,7 @@ func (opts *ListSubCommand) do(input cli.Input) (err error) {
|
||||
tts, err := opts.Client().FissionClientSet.CoreV1().TimeTriggers(ttNs).List(input.Context(), metav1.ListOptions{})
|
||||
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "list Time triggers")
|
||||
return fmt.Errorf("list Time triggers: %w", err)
|
||||
}
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
@@ -17,7 +17,9 @@ limitations under the License.
|
||||
package timetrigger
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"fmt"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
@@ -49,7 +51,7 @@ func (opts *ShowSubCommand) run(flaginput cli.Input) error {
|
||||
|
||||
err := getCronNextNActivationTime(cronSpec, t, round)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error passing cron spec examination")
|
||||
return fmt.Errorf("error passing cron spec examination: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -19,7 +19,8 @@ package timetrigger
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"errors"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
@@ -51,12 +52,12 @@ func (opts *UpdateSubCommand) do(input cli.Input) error {
|
||||
func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
_, namespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceTrigger)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error in deleting function ")
|
||||
return fmt.Errorf("error in deleting function : %w", err)
|
||||
}
|
||||
|
||||
tt, err := opts.Client().FissionClientSet.CoreV1().TimeTriggers(namespace).Get(input.Context(), input.String(flagkey.TtName), metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting time trigger")
|
||||
return fmt.Errorf("error getting time trigger: %w", err)
|
||||
}
|
||||
|
||||
updated := false
|
||||
@@ -105,13 +106,13 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
specFile := fmt.Sprintf("timetrigger-%s.yaml", opts.trigger.ObjectMeta.Name)
|
||||
err = spec.SpecSave(*opts.trigger, specFile, true)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error saving time trigger spec")
|
||||
return fmt.Errorf("error saving time trigger spec: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
_, err := opts.Client().FissionClientSet.CoreV1().TimeTriggers(opts.trigger.ObjectMeta.Namespace).Update(input.Context(), opts.trigger, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error updating Time trigger")
|
||||
return fmt.Errorf("error updating Time trigger: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("trigger '%v' updated\n", opts.trigger.ObjectMeta.Name)
|
||||
@@ -123,7 +124,7 @@ func (opts *UpdateSubCommand) run(input cli.Input) error {
|
||||
|
||||
err = getCronNextNActivationTime(opts.trigger.Spec.Cron, t, 1)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error passing cron spec examination")
|
||||
return fmt.Errorf("error passing cron spec examination: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -24,8 +24,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
"github.com/fission/fission/pkg/fission-cli/cmd"
|
||||
@@ -73,7 +71,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
}
|
||||
routerURL, err := util.GetRouterURL(input.Context(), opts.Client())
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting router URL")
|
||||
return fmt.Errorf("error getting router URL: %w", err)
|
||||
}
|
||||
authAuthenticatorUrl := routerURL.JoinPath(authURI)
|
||||
console.Verbose(2, "Auth URI: %s", authAuthenticatorUrl.String())
|
||||
@@ -86,7 +84,7 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
|
||||
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating token")
|
||||
return fmt.Errorf("error creating token: %w", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusCreated {
|
||||
|
||||
@@ -19,7 +19,6 @@ package version
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"sigs.k8s.io/yaml"
|
||||
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -39,7 +38,7 @@ func (opts *VersionSubCommand) do(input cli.Input) error {
|
||||
ver := util.GetVersion(input.Context(), input, opts.Client())
|
||||
bs, err := yaml.Marshal(ver)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error formatting versions")
|
||||
return fmt.Errorf("error formatting versions: %w", err)
|
||||
}
|
||||
fmt.Print(string(bs))
|
||||
return nil
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
"time"
|
||||
|
||||
influxdbClient "github.com/influxdata/influxdb/client/v2"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
@@ -153,12 +152,12 @@ func (influx InfluxDB) GetLogs(ctx context.Context, filter LogFilter, output *by
|
||||
msg := fmt.Sprintf("Timestamp: %s\nNamespace: %s\nFunction Name: %s\nFunction ID: %s\nPod: %s\nContainer: %s\nStream: %s\nLog: %s\n---\n",
|
||||
logEntry.Timestamp, logEntry.Namespace, logEntry.FuncName, logEntry.FuncUid, logEntry.Pod, logEntry.Container, logEntry.Stream, logEntry.Message)
|
||||
if _, err := output.WriteString(msg); err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
} else {
|
||||
msg := fmt.Sprintf("[%s] %s\n", logEntry.Timestamp, logEntry.Message)
|
||||
if _, err := output.WriteString(msg); err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,7 +172,7 @@ func (influx InfluxDB) query(ctx context.Context, query influxdbClient.Query) (*
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, influx.endpoint, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating request for log proxy")
|
||||
return nil, fmt.Errorf("error creating request for log proxy: %w", err)
|
||||
}
|
||||
req.SetBasicAuth(username, password)
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@@ -85,7 +84,7 @@ func GetFunctionPodLogs(ctx context.Context, client cmd.Client, logFilter LogFil
|
||||
}
|
||||
|
||||
if len(podList.Items) <= 0 {
|
||||
return errors.Errorf("no active pods found for function in namespace %s", podNs)
|
||||
return fmt.Errorf("no active pods found for function in namespace %s", podNs)
|
||||
}
|
||||
|
||||
pods := podList.Items
|
||||
@@ -94,7 +93,7 @@ func GetFunctionPodLogs(ctx context.Context, client cmd.Client, logFilter LogFil
|
||||
// get the pod with highest resource version
|
||||
err = streamContainerLog(ctx, client.KubernetesClient, &pod, logFilter, podLogs)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error getting container logs")
|
||||
return fmt.Errorf("error getting container logs: %w", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -108,7 +107,7 @@ func GetFunctionPodLogs(ctx context.Context, client cmd.Client, logFilter LogFil
|
||||
// get the pod with highest resource version
|
||||
err = streamContainerLog(ctx, client.KubernetesClient, &pods[0], logFilter, podLogs)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error getting container logs")
|
||||
return fmt.Errorf("error getting container logs: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +131,7 @@ func streamContainerLog(ctx context.Context, kubernetesClient kubernetes.Interfa
|
||||
|
||||
podLogs, err := podLogsReq.Stream(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error streaming pod log")
|
||||
return fmt.Errorf("error streaming pod log: %w", err)
|
||||
}
|
||||
|
||||
if logFilter.Details {
|
||||
@@ -140,13 +139,13 @@ func streamContainerLog(ctx context.Context, kubernetesClient kubernetes.Interfa
|
||||
msg := fmt.Sprintf("\n=== Function=%s Environment=%s Namespace=%s Pod=%s Container=%s Node=%s\n",
|
||||
fn.ObjectMeta.Name, fn.Spec.Environment.Name, pod.Namespace, pod.Name, container.Name, pod.Spec.NodeName)
|
||||
if _, err := output.WriteString(msg); err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
_, err = io.Copy(output, podLogs)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
|
||||
podLogs.Close()
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/tools/portforward"
|
||||
@@ -50,7 +49,7 @@ func SetupPortForward(ctx context.Context, client cmd.Client, namespace, labelSe
|
||||
|
||||
lcPort, err := utils.FindFreePort()
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "error finding unused port")
|
||||
return "", fmt.Errorf("error finding unused port: %w", err)
|
||||
}
|
||||
localPort := strconv.Itoa(lcPort)
|
||||
|
||||
@@ -118,9 +117,9 @@ func runPortForward(ctx context.Context, client cmd.Client, labelSelector string
|
||||
podList, err := client.KubernetesClient.CoreV1().Pods(ns).
|
||||
List(ctx, metav1.ListOptions{LabelSelector: labelSelector})
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrapf(err, "error getting pod for port-forwarding with label selector %v", labelSelector)
|
||||
return nil, nil, fmt.Errorf("error getting pod for port-forwarding with label selector %v: %w", labelSelector, err)
|
||||
} else if len(podList.Items) == 0 {
|
||||
return nil, nil, errors.Errorf("no available pod for port-forwarding with label selector %v", labelSelector)
|
||||
return nil, nil, fmt.Errorf("no available pod for port-forwarding with label selector %v", labelSelector)
|
||||
}
|
||||
|
||||
nsList := make([]string, 0)
|
||||
@@ -136,7 +135,7 @@ func runPortForward(ctx context.Context, client cmd.Client, labelSelector string
|
||||
namespaces[p.Namespace] = append(namespaces[p.Namespace], &p)
|
||||
}
|
||||
if len(nsList) > 1 {
|
||||
return nil, nil, errors.Errorf("Found %v fission installs, set FISSION_NAMESPACE to one of: %v",
|
||||
return nil, nil, fmt.Errorf("Found %v fission installs, set FISSION_NAMESPACE to one of: %v",
|
||||
len(namespaces), strings.Join(nsList, " "))
|
||||
}
|
||||
}
|
||||
@@ -146,7 +145,7 @@ func runPortForward(ctx context.Context, client cmd.Client, labelSelector string
|
||||
ns = nsList[0]
|
||||
pods, ok := namespaces[ns]
|
||||
if !ok {
|
||||
return nil, nil, errors.Errorf("Error finding fission install within the given namespace %v, please check FISSION_NAMESPACE is set properly", ns)
|
||||
return nil, nil, fmt.Errorf("Error finding fission install within the given namespace %v, please check FISSION_NAMESPACE is set properly", ns)
|
||||
}
|
||||
|
||||
var podName, podNameSpace string
|
||||
@@ -164,10 +163,10 @@ func runPortForward(ctx context.Context, client cmd.Client, labelSelector string
|
||||
svcs, err := client.KubernetesClient.CoreV1().Services(podNameSpace).
|
||||
List(ctx, metav1.ListOptions{LabelSelector: labelSelector})
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrapf(err, "Error getting %v service", labelSelector)
|
||||
return nil, nil, fmt.Errorf("Error getting %v service: %w", labelSelector, err)
|
||||
}
|
||||
if len(svcs.Items) == 0 {
|
||||
return nil, nil, errors.Errorf("Service %v not found", labelSelector)
|
||||
return nil, nil, fmt.Errorf("Service %v not found", labelSelector)
|
||||
}
|
||||
service := &svcs.Items[0]
|
||||
|
||||
@@ -192,7 +191,7 @@ func runPortForward(ctx context.Context, client cmd.Client, labelSelector string
|
||||
// actually start the port-forwarding process here
|
||||
transport, upgrader, err := spdy.RoundTripperFor(client.RestConfig)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Errorf("Failed to connect to Fission service on Kubernetes")
|
||||
return nil, nil, fmt.Errorf("Failed to connect to Fission service on Kubernetes")
|
||||
}
|
||||
dialer := spdy.NewDialer(upgrader, &http.Client{Transport: transport}, "POST", url)
|
||||
|
||||
@@ -202,7 +201,7 @@ func runPortForward(ctx context.Context, client cmd.Client, labelSelector string
|
||||
}
|
||||
fw, err := portforward.New(dialer, ports, stopChannel, readyChannel, outStream, os.Stderr)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "error creating port forwarder")
|
||||
return nil, nil, fmt.Errorf("error creating port forwarder: %w", err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
|
||||
@@ -32,8 +32,9 @@ import (
|
||||
|
||||
ignore "github.com/sabhiram/go-gitignore"
|
||||
|
||||
"errors"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -254,7 +255,7 @@ func GetResourceReqs(input cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res
|
||||
mincpu := input.Int(flagkey.RuntimeMincpu)
|
||||
cpuRequest, err := resource.ParseQuantity(strconv.Itoa(mincpu) + "m")
|
||||
if err != nil {
|
||||
e = multierror.Append(e, errors.Wrap(err, "Failed to parse mincpu"))
|
||||
e = multierror.Append(e, fmt.Errorf("Failed to parse mincpu: %w", err))
|
||||
}
|
||||
r.Requests[v1.ResourceCPU] = cpuRequest
|
||||
}
|
||||
@@ -263,7 +264,7 @@ func GetResourceReqs(input cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res
|
||||
minmem := input.Int(flagkey.RuntimeMinmemory)
|
||||
memRequest, err := resource.ParseQuantity(strconv.Itoa(minmem) + "Mi")
|
||||
if err != nil {
|
||||
e = multierror.Append(e, errors.Wrap(err, "Failed to parse minmemory"))
|
||||
e = multierror.Append(e, fmt.Errorf("Failed to parse minmemory: %w", err))
|
||||
}
|
||||
r.Requests[v1.ResourceMemory] = memRequest
|
||||
}
|
||||
@@ -272,7 +273,7 @@ func GetResourceReqs(input cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res
|
||||
maxcpu := input.Int(flagkey.RuntimeMaxcpu)
|
||||
cpuLimit, err := resource.ParseQuantity(strconv.Itoa(maxcpu) + "m")
|
||||
if err != nil {
|
||||
e = multierror.Append(e, errors.Wrap(err, "Failed to parse maxcpu"))
|
||||
e = multierror.Append(e, fmt.Errorf("Failed to parse maxcpu: %w", err))
|
||||
}
|
||||
r.Limits[v1.ResourceCPU] = cpuLimit
|
||||
}
|
||||
@@ -281,7 +282,7 @@ func GetResourceReqs(input cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res
|
||||
maxmem := input.Int(flagkey.RuntimeMaxmemory)
|
||||
memLimit, err := resource.ParseQuantity(strconv.Itoa(maxmem) + "Mi")
|
||||
if err != nil {
|
||||
e = multierror.Append(e, errors.Wrap(err, "Failed to parse maxmemory"))
|
||||
e = multierror.Append(e, fmt.Errorf("Failed to parse maxmemory: %w", err))
|
||||
}
|
||||
r.Limits[v1.ResourceMemory] = memLimit
|
||||
}
|
||||
@@ -340,7 +341,7 @@ func GetSpecIgnoreParser(specDir, specIgnore string) (ignore.IgnoreParser, error
|
||||
if _, err := os.Stat(specIgnorePath); errors.Is(err, os.ErrNotExist) {
|
||||
// return error if it's custom spec ignore file
|
||||
if specIgnore != SPEC_IGNORE_FILE {
|
||||
return nil, errors.Errorf("Spec ignore file '%s' doesn't exist. "+
|
||||
return nil, fmt.Errorf("Spec ignore file '%s' doesn't exist. "+
|
||||
"Please check the file path: '%s'", specIgnore, specIgnorePath)
|
||||
}
|
||||
return ignore.CompileIgnoreLines(), nil
|
||||
@@ -423,7 +424,7 @@ func ParseAnnotations(annotations []string) (map[string]string, error) {
|
||||
}
|
||||
}
|
||||
if invalidAnnotations != "" {
|
||||
return nil, errors.Errorf("invalid annotations: %s", invalidAnnotations)
|
||||
return nil, fmt.Errorf("invalid annotations: %s", invalidAnnotations)
|
||||
}
|
||||
return annotationMap, nil
|
||||
}
|
||||
@@ -523,7 +524,7 @@ func GetSvcName(ctx context.Context, kClient kubernetes.Interface, application s
|
||||
}
|
||||
|
||||
if len(services.Items) > 1 || len(services.Items) == 0 {
|
||||
return "", errors.Errorf("more than one service found for application=%s", application)
|
||||
return "", fmt.Errorf("more than one service found for application=%s", application)
|
||||
}
|
||||
service := services.Items[0]
|
||||
return service.Name + "." + service.Namespace, nil
|
||||
@@ -576,7 +577,7 @@ func FunctionPodLogs(ctx context.Context, fnName, ns string, client cmd.Client)
|
||||
// get the pod with highest resource version
|
||||
err = getContainerLog(ctx, client.KubernetesClient, f, &pods[0])
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error getting container logs")
|
||||
return fmt.Errorf("error getting container logs: %w", err)
|
||||
|
||||
}
|
||||
return err
|
||||
@@ -591,19 +592,19 @@ func getContainerLog(ctx context.Context, kubernetesClient kubernetes.Interface,
|
||||
|
||||
podLogs, err := podLogsReq.Stream(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error streaming pod log")
|
||||
return fmt.Errorf("error streaming pod log: %w", err)
|
||||
}
|
||||
|
||||
msg := fmt.Sprintf("\n%v\nFunction: %v\nEnvironment: %v\nNamespace: %v\nPod: %v\nContainer: %v\nNode: %v\n%v\n", seq,
|
||||
fn.ObjectMeta.Name, fn.Spec.Environment.Name, pod.Namespace, pod.Name, container.Name, pod.Spec.NodeName, seq)
|
||||
|
||||
if _, err := io.WriteString(os.Stdout, msg); err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
|
||||
_, err = io.Copy(os.Stdout, podLogs)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
|
||||
podLogs.Close()
|
||||
|
||||
Reference in New Issue
Block a user