From 23fdf2de0fea6d495765043dc38fc33e87e0d816 Mon Sep 17 00:00:00 2001 From: Sanket Sudake Date: Sun, 18 May 2025 22:27:45 +0530 Subject: [PATCH] Add staticcheck fixes (#3221) * Add staticcheck fixes Signed-off-by: Sanket Sudake * update golangci-lint version Signed-off-by: Sanket Sudake --------- Signed-off-by: Sanket Sudake --- .github/workflows/lint.yaml | 2 +- .golangci.yaml | 15 ++++ go.mod | 2 +- pkg/apis/core/v1/validation.go | 2 +- pkg/canaryconfigmgr/canaryConfigMgr.go | 4 +- pkg/executor/cms/cmscontroller.go | 2 +- pkg/executor/executor.go | 6 +- .../executortype/container/containermgr.go | 36 +++++----- .../executortype/newdeploy/newdeploymgr.go | 6 +- pkg/executor/executortype/poolmgr/gp.go | 4 +- pkg/executor/executortype/poolmgr/gpm.go | 2 +- pkg/executor/fscache/poolcache.go | 6 +- pkg/executor/util/util_test.go | 2 +- pkg/fetcher/fetcher.go | 6 +- pkg/fission-cli/cmd/client.go | 2 +- pkg/fission-cli/cmd/environment/delete.go | 4 +- pkg/fission-cli/cmd/environment/update.go | 12 ++-- pkg/fission-cli/cmd/function/create.go | 4 +- pkg/fission-cli/cmd/function/test.go | 2 +- pkg/fission-cli/cmd/httptrigger/create.go | 2 +- pkg/fission-cli/cmd/httptrigger/get.go | 2 +- pkg/fission-cli/cmd/httptrigger/update.go | 2 +- pkg/fission-cli/cmd/mqtrigger/create.go | 12 ++-- pkg/fission-cli/cmd/mqtrigger/update.go | 2 +- pkg/fission-cli/cmd/package/delete.go | 2 +- pkg/fission-cli/cmd/package/get.go | 2 - pkg/fission-cli/cmd/package/package.go | 4 +- pkg/fission-cli/cmd/package/rebuild.go | 4 +- pkg/fission-cli/cmd/spec/apply.go | 22 +++--- pkg/fission-cli/cmd/spec/destroy.go | 26 +++---- pkg/fission-cli/cmd/spec/init.go | 2 +- pkg/fission-cli/cmd/spec/list.go | 20 +++--- pkg/fission-cli/cmd/spec/spec.go | 69 +++++++++---------- pkg/fission-cli/cmd/spec/validate.go | 18 ++--- pkg/fission-cli/cmd/support/dump.go | 4 +- pkg/fission-cli/cmd/timetrigger/create.go | 4 +- pkg/fission-cli/cmd/timetrigger/list.go | 2 +- pkg/fission-cli/cmd/timetrigger/update.go | 2 +- pkg/fission-cli/console/log.go | 10 +-- pkg/fission-cli/util/portforward.go | 10 +-- pkg/fission-cli/util/util.go | 14 ++-- pkg/kubewatcher/kubewatcher.go | 23 +++---- pkg/mqtrigger/messageQueue/kafka/consumer.go | 4 +- pkg/mqtrigger/mqtmanager.go | 22 +++--- pkg/router/auth_test.go | 2 +- pkg/router/functionHandler.go | 8 +-- pkg/router/functionReferenceResolver.go | 2 +- pkg/router/ingress.go | 2 +- pkg/router/util/util.go | 6 +- pkg/router/util/util_test.go | 2 +- pkg/storagesvc/storagesvc.go | 4 +- pkg/storagesvc/stowClient.go | 6 +- pkg/throttler/throttler.go | 2 +- pkg/timer/timer.go | 2 +- pkg/utils/gitrepo/gitrepo.go | 7 +- pkg/webhook/function.go | 2 +- test/e2e/cli/cli_test.go | 4 +- tools/cmd-docs/main.go | 2 +- 58 files changed, 228 insertions(+), 226 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index af20924cd..21eb3a396 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -17,7 +17,7 @@ on: - go.sum env: - GOLANGCI_LINT_VERSION: v1.64.6 + GOLANGCI_LINT_VERSION: v2.1.6 GOLANGCI_LINT_TIMEOUT: 5m permissions: diff --git a/.golangci.yaml b/.golangci.yaml index 6d5d312f3..be25e6acc 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,10 +1,15 @@ version: "2" linters: enable: + - errcheck + - govet + - ineffassign - misspell - nakedret - promlinter - unconvert + - unused + - staticcheck settings: errcheck: exclude-functions: @@ -20,6 +25,16 @@ linters: - third_party$ - builtin$ - examples$ + rules: + - linters: + - staticcheck + text: "QF1008" + - linters: + - staticcheck + text: "QF1001" + - linters: + - staticcheck + text: "QF1003" formatters: enable: - gofmt diff --git a/go.mod b/go.mod index f3eb8633e..5572b0489 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/fission/fission -go 1.24.1 +go 1.24.3 require ( dario.cat/mergo v1.0.1 diff --git a/pkg/apis/core/v1/validation.go b/pkg/apis/core/v1/validation.go index 9ab7b5d63..9e9ccea3d 100644 --- a/pkg/apis/core/v1/validation.go +++ b/pkg/apis/core/v1/validation.go @@ -599,7 +599,7 @@ func (e *Environment) Validate() error { if e.Spec.Runtime.PodSpec != nil { for _, container := range e.Spec.Runtime.PodSpec.Containers { - if container.Command == nil && container.Image == e.Spec.Runtime.Image && container.Name != e.ObjectMeta.Name { + if container.Command == nil && container.Image == e.Spec.Runtime.Image && container.Name != e.Name { result = multierror.Append(result, errors.New("container with image same as runtime image in podspec, must have name same as environment name")) } } diff --git a/pkg/canaryconfigmgr/canaryConfigMgr.go b/pkg/canaryconfigmgr/canaryConfigMgr.go index 34c2870b7..fd5e06fdc 100644 --- a/pkg/canaryconfigmgr/canaryConfigMgr.go +++ b/pkg/canaryconfigmgr/canaryConfigMgr.go @@ -461,7 +461,7 @@ func (canaryCfgMgr *canaryConfigMgr) rollback(ctx context.Context, canaryConfig functionWeights[canaryConfig.Spec.NewFunction] = 0 functionWeights[canaryConfig.Spec.OldFunction] = 100 - err := canaryCfgMgr.updateHttpTriggerWithRetries(ctx, trigger.ObjectMeta.Name, trigger.ObjectMeta.Namespace, functionWeights) + err := canaryCfgMgr.updateHttpTriggerWithRetries(ctx, trigger.Name, trigger.ObjectMeta.Namespace, functionWeights) if err != nil { return err } @@ -494,7 +494,7 @@ func (canaryCfgMgr *canaryConfigMgr) rollForward(ctx context.Context, canaryConf zap.String("namespace", canaryConfig.ObjectMeta.Namespace), zap.Any("function_weights", functionWeights)) - err := canaryCfgMgr.updateHttpTriggerWithRetries(ctx, trigger.ObjectMeta.Name, trigger.ObjectMeta.Namespace, functionWeights) + err := canaryCfgMgr.updateHttpTriggerWithRetries(ctx, trigger.Name, trigger.ObjectMeta.Namespace, functionWeights) return doneProcessingCanaryConfig, err } diff --git a/pkg/executor/cms/cmscontroller.go b/pkg/executor/cms/cmscontroller.go index 1a41982e1..a9d74be68 100644 --- a/pkg/executor/cms/cmscontroller.go +++ b/pkg/executor/cms/cmscontroller.go @@ -72,7 +72,7 @@ func refreshPods(ctx context.Context, logger *zap.Logger, funcs []fv1.Function, if exists { err = et.RefreshFuncPods(ctx, logger, f) } else { - err = fmt.Errorf("Unknown executor type '%s'", f.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType) + err = fmt.Errorf("unknown executor type '%s'", f.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType) } if err != nil { diff --git a/pkg/executor/executor.go b/pkg/executor/executor.go index e9c00f0a4..eb58d15a5 100644 --- a/pkg/executor/executor.go +++ b/pkg/executor/executor.go @@ -232,7 +232,7 @@ func (executor *Executor) createServiceForFunction(ctx context.Context, fn *fv1. t := fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType e, ok := executor.executorTypes[t] if !ok { - return nil, fmt.Errorf("Unknown executor type '%s'", t) + return nil, fmt.Errorf("unknown executor type '%s'", t) } fsvc, fsvcErr := e.GetFuncSvc(ctx, fn) @@ -253,7 +253,7 @@ func (executor *Executor) getFunctionServiceFromCache(ctx context.Context, fn *f t := fn.Spec.InvokeStrategy.ExecutionStrategy.ExecutorType e, ok := executor.executorTypes[t] if !ok { - return nil, fmt.Errorf("Unknown executor type '%s'", t) + return nil, fmt.Errorf("unknown executor type '%s'", t) } return e.GetFuncSvcFromCache(ctx, fn) } @@ -282,7 +282,7 @@ func StartExecutor(ctx context.Context, clientGen crd.ClientGeneratorInterface, fetcherConfig, err := fetcherConfig.MakeFetcherConfig("/userfunc") if err != nil { - return fmt.Errorf("Error making fetcher config: %w", err) + return fmt.Errorf("error making fetcher config: %w", err) } executorInstanceID := strings.ToLower(uniuri.NewLen(8)) diff --git a/pkg/executor/executortype/container/containermgr.go b/pkg/executor/executortype/container/containermgr.go index 8195a0c21..943dd1460 100644 --- a/pkg/executor/executortype/container/containermgr.go +++ b/pkg/executor/executortype/container/containermgr.go @@ -436,27 +436,27 @@ func (caaf *Container) fnCreate(ctx context.Context, fn *fv1.Function) (*fscache { // obj.TypeMeta.Kind does not work hence this, needs investigation and a fix Kind: "deployment", - Name: depl.ObjectMeta.Name, - APIVersion: depl.TypeMeta.APIVersion, - Namespace: depl.ObjectMeta.Namespace, - ResourceVersion: depl.ObjectMeta.ResourceVersion, - UID: depl.ObjectMeta.UID, + Name: depl.Name, + APIVersion: depl.APIVersion, + Namespace: depl.Namespace, + ResourceVersion: depl.ResourceVersion, + UID: depl.UID, }, { Kind: "service", - Name: svc.ObjectMeta.Name, - APIVersion: svc.TypeMeta.APIVersion, - Namespace: svc.ObjectMeta.Namespace, - ResourceVersion: svc.ObjectMeta.ResourceVersion, - UID: svc.ObjectMeta.UID, + Name: svc.Name, + APIVersion: svc.APIVersion, + Namespace: svc.Namespace, + ResourceVersion: svc.ResourceVersion, + UID: svc.UID, }, { Kind: "horizontalpodautoscaler", - Name: hpa.ObjectMeta.Name, - APIVersion: hpa.TypeMeta.APIVersion, - Namespace: hpa.ObjectMeta.Namespace, - ResourceVersion: hpa.ObjectMeta.ResourceVersion, - UID: hpa.ObjectMeta.UID, + Name: hpa.Name, + APIVersion: hpa.APIVersion, + Namespace: hpa.Namespace, + ResourceVersion: hpa.ResourceVersion, + UID: hpa.UID, }, } @@ -471,18 +471,18 @@ func (caaf *Container) fnCreate(ctx context.Context, fn *fv1.Function) (*fscache _, err = caaf.fsCache.Add(*fsvc) if err != nil { caaf.logger.Error("error adding function to cache", zap.Error(err), zap.Any("function", fsvc.Function)) - metrics.ColdStartsError.WithLabelValues(fn.ObjectMeta.Name, fn.ObjectMeta.Namespace).Inc() + metrics.ColdStartsError.WithLabelValues(fn.Name, fn.Namespace).Inc() return fsvc, err } - metrics.ColdStarts.WithLabelValues(fn.ObjectMeta.Name, fn.ObjectMeta.Namespace).Inc() + metrics.ColdStarts.WithLabelValues(fn.Name, fn.Namespace).Inc() return fsvc, nil } func (caaf *Container) updateFunction(ctx context.Context, oldFn *fv1.Function, newFn *fv1.Function) error { - if oldFn.ObjectMeta.ResourceVersion == newFn.ObjectMeta.ResourceVersion { + if oldFn.ResourceVersion == newFn.ResourceVersion { return nil } diff --git a/pkg/executor/executortype/newdeploy/newdeploymgr.go b/pkg/executor/executortype/newdeploy/newdeploymgr.go index fe677c073..61167f4ca 100644 --- a/pkg/executor/executortype/newdeploy/newdeploymgr.go +++ b/pkg/executor/executortype/newdeploy/newdeploymgr.go @@ -482,7 +482,7 @@ func (deploy *NewDeploy) fnCreate(ctx context.Context, fn *fv1.Function) (*fscac // obj.TypeMeta.Kind does not work hence this, needs investigation and a fix Kind: "deployment", Name: depl.ObjectMeta.Name, - APIVersion: depl.TypeMeta.APIVersion, + APIVersion: depl.APIVersion, Namespace: depl.ObjectMeta.Namespace, ResourceVersion: depl.ObjectMeta.ResourceVersion, UID: depl.ObjectMeta.UID, @@ -490,7 +490,7 @@ func (deploy *NewDeploy) fnCreate(ctx context.Context, fn *fv1.Function) (*fscac { Kind: "service", Name: svc.ObjectMeta.Name, - APIVersion: svc.TypeMeta.APIVersion, + APIVersion: svc.APIVersion, Namespace: svc.ObjectMeta.Namespace, ResourceVersion: svc.ObjectMeta.ResourceVersion, UID: svc.ObjectMeta.UID, @@ -498,7 +498,7 @@ func (deploy *NewDeploy) fnCreate(ctx context.Context, fn *fv1.Function) (*fscac { Kind: "horizontalpodautoscaler", Name: hpa.ObjectMeta.Name, - APIVersion: hpa.TypeMeta.APIVersion, + APIVersion: hpa.APIVersion, Namespace: hpa.ObjectMeta.Namespace, ResourceVersion: hpa.ObjectMeta.ResourceVersion, UID: hpa.ObjectMeta.UID, diff --git a/pkg/executor/executortype/poolmgr/gp.go b/pkg/executor/executortype/poolmgr/gp.go index 7e6958239..214be8ff1 100644 --- a/pkg/executor/executortype/poolmgr/gp.go +++ b/pkg/executor/executortype/poolmgr/gp.go @@ -415,7 +415,7 @@ func (gp *GenericPool) specializePod(ctx context.Context, pod *apiv1.Pod, fn *fv // for fetcher we don't need to create a service, just talk to the pod directly podIP := pod.Status.PodIP if len(podIP) == 0 { - return fmt.Errorf("Pod %s in namespace %s has no IP", pod.ObjectMeta.Name, pod.ObjectMeta.Namespace) + return fmt.Errorf("pod %s in namespace %s has no IP", pod.ObjectMeta.Name, pod.ObjectMeta.Namespace) } for _, cm := range fn.Spec.ConfigMaps { _, err := gp.kubernetesClient.CoreV1().ConfigMaps(gp.fnNamespace).Get(ctx, cm.Name, metav1.GetOptions{}) @@ -601,7 +601,7 @@ func (gp *GenericPool) getFuncSvc(ctx context.Context, fn *fv1.Function) (*fscac { Kind: "pod", Name: pod.ObjectMeta.Name, - APIVersion: pod.TypeMeta.APIVersion, + APIVersion: pod.APIVersion, Namespace: pod.ObjectMeta.Namespace, ResourceVersion: pod.ObjectMeta.ResourceVersion, UID: pod.ObjectMeta.UID, diff --git a/pkg/executor/executortype/poolmgr/gpm.go b/pkg/executor/executortype/poolmgr/gpm.go index df1b2c685..8aafa8a4c 100644 --- a/pkg/executor/executortype/poolmgr/gpm.go +++ b/pkg/executor/executortype/poolmgr/gpm.go @@ -458,7 +458,7 @@ func (gpm *GenericPoolManager) AdoptExistingResources(ctx context.Context) { { Kind: "pod", Name: pod.Name, - APIVersion: pod.TypeMeta.APIVersion, + APIVersion: pod.APIVersion, Namespace: pod.ObjectMeta.Namespace, ResourceVersion: pod.ObjectMeta.ResourceVersion, UID: pod.ObjectMeta.UID, diff --git a/pkg/executor/fscache/poolcache.go b/pkg/executor/fscache/poolcache.go index 59244cfb6..a05fec5e4 100644 --- a/pkg/executor/fscache/poolcache.go +++ b/pkg/executor/fscache/poolcache.go @@ -306,7 +306,7 @@ func (c *PoolCache) service() { datawriter := bufio.NewWriter(req.dumpWriter) writefnSvcGrp := func(svcGrp *funcSvcGroup) error { - _, err := datawriter.WriteString(fmt.Sprintf("svc_waiting:%d\tqueue_len:%d", svcGrp.svcWaiting, svcGrp.queue.Len())) + _, err := fmt.Fprintf(datawriter, "svc_waiting:%d\tqueue_len:%d", svcGrp.svcWaiting, svcGrp.queue.Len()) if err != nil { return err } @@ -319,8 +319,8 @@ func (c *PoolCache) service() { } for addr, fnSvc := range svcGrp.svcs { - _, err := datawriter.WriteString(fmt.Sprintf("\tfunction_name:%s\tfn_svc_address:%s\tactive_req:%d\tcurrent_cpu_usage:%v\tcpu_limit:%v\n", - fnSvc.val.Function.Name, addr, fnSvc.activeRequests, fnSvc.currentCPUUsage, fnSvc.cpuLimit)) + _, err := fmt.Fprintf(datawriter, "\tfunction_name:%s\tfn_svc_address:%s\tactive_req:%d\tcurrent_cpu_usage:%v\tcpu_limit:%v\n", + fnSvc.val.Function.Name, addr, fnSvc.activeRequests, fnSvc.currentCPUUsage, fnSvc.cpuLimit) if err != nil { return err } diff --git a/pkg/executor/util/util_test.go b/pkg/executor/util/util_test.go index 825d027a0..06f486204 100644 --- a/pkg/executor/util/util_test.go +++ b/pkg/executor/util/util_test.go @@ -55,7 +55,7 @@ securityContext: } var permissionNum int64 = 10001 - var runAsNonRoot bool = true + var runAsNonRoot = true testSpecPatch := apiv1.PodSpec{ SecurityContext: &apiv1.PodSecurityContext{ diff --git a/pkg/fetcher/fetcher.go b/pkg/fetcher/fetcher.go index 8e6c31885..fe1b342e1 100644 --- a/pkg/fetcher/fetcher.go +++ b/pkg/fetcher/fetcher.go @@ -298,10 +298,10 @@ func (fetcher *Fetcher) Fetch(ctx context.Context, pkg *fv1.Package, req Functio if pkg.Status.BuildStatus != fv1.BuildStatusSucceeded && pkg.Status.BuildStatus != fv1.BuildStatusNone { e := fmt.Sprintf("cannot fetch deployment: package build status was not %q", fv1.BuildStatusSucceeded) logger.Error(e, - zap.String("package_name", pkg.ObjectMeta.Name), - zap.String("package_namespace", pkg.ObjectMeta.Namespace), + zap.String("package_name", pkg.Name), + zap.String("package_namespace", pkg.Namespace), zap.Any("package_build_status", pkg.Status.BuildStatus)) - return http.StatusInternalServerError, fmt.Errorf("%s: pkg %s.%s has a status of %s", e, pkg.ObjectMeta.Name, pkg.ObjectMeta.Namespace, pkg.Status.BuildStatus) + return http.StatusInternalServerError, fmt.Errorf("%s: pkg %s.%s has a status of %s", e, pkg.Name, pkg.Namespace, pkg.Status.BuildStatus) } archive = &pkg.Spec.Deployment } else { diff --git a/pkg/fission-cli/cmd/client.go b/pkg/fission-cli/cmd/client.go index a4ac8434d..7cdde98f4 100644 --- a/pkg/fission-cli/cmd/client.go +++ b/pkg/fission-cli/cmd/client.go @@ -75,7 +75,7 @@ func getLoadingRules() (loadingRules *clientcmd.ClientConfigLoadingRules, err er if _, err := os.Stat(kubeConfigPath); os.IsNotExist(err) { return nil, errors.New("couldn't find kubeconfig file. " + - "Set the KUBECONFIG environment variable to your kubeconfig's path.") + "Set the KUBECONFIG environment variable to your kubeconfig's path") } loadingRules.ExplicitPath = kubeConfigPath console.Verbose(2, "Using kubeconfig from %q", kubeConfigPath) diff --git a/pkg/fission-cli/cmd/environment/delete.go b/pkg/fission-cli/cmd/environment/delete.go index c9aa445b0..9b6576508 100644 --- a/pkg/fission-cli/cmd/environment/delete.go +++ b/pkg/fission-cli/cmd/environment/delete.go @@ -49,13 +49,13 @@ 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 fmt.Errorf("Error getting functions wrt environment.: %w", err) + return fmt.Errorf("error getting functions wrt environment: %w", err) } for _, fn := range fns.Items { if fn.Spec.Environment.Name == envName && fn.Spec.Environment.Namespace == currentContextNS { - return errors.New("Environment is used by at least one function.") + return errors.New("environment is used by at least one function") } } } diff --git a/pkg/fission-cli/cmd/environment/update.go b/pkg/fission-cli/cmd/environment/update.go index e4827035b..09998ffe6 100644 --- a/pkg/fission-cli/cmd/environment/update.go +++ b/pkg/fission-cli/cmd/environment/update.go @@ -99,7 +99,7 @@ func (opts *UpdateSubCommand) run(input cli.Input) error { return fmt.Errorf("error updating environment: %w", err) } - fmt.Printf("environment '%v' updated\n", enew.ObjectMeta.Name) + fmt.Printf("environment '%v' updated\n", enew.Name) return nil } @@ -161,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, fmt.Errorf("Failed to parse maxcpu: %w", err)) + e = multierror.Append(e, fmt.Errorf("failed to parse maxcpu: %w", err)) } env.Spec.Resources.Limits[v1.ResourceCPU] = cpuLimit } @@ -170,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, fmt.Errorf("Failed to parse minmemory: %w", err)) + e = multierror.Append(e, fmt.Errorf("failed to parse minmemory: %w", err)) } env.Spec.Resources.Requests[v1.ResourceMemory] = memRequest } @@ -179,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, fmt.Errorf("Failed to parse maxmemory: %w", err)) + e = multierror.Append(e, fmt.Errorf("failed to parse maxmemory: %w", err)) } env.Spec.Resources.Limits[v1.ResourceMemory] = memLimit } @@ -196,7 +196,7 @@ func updateExistingEnvironmentWithCmd(env *fv1.Environment, input cli.Input) (*f if limitCPU.IsZero() && !requestCPU.IsZero() { env.Spec.Resources.Limits[v1.ResourceCPU] = requestCPU } else if limitCPU.Cmp(requestCPU) < 0 { - e = multierror.Append(e, fmt.Errorf("MinCPU (%v) cannot be greater than MaxCPU (%v)", requestCPU.String(), limitCPU.String())) + e = multierror.Append(e, fmt.Errorf("minCPU (%v) cannot be greater than MaxCPU (%v)", requestCPU.String(), limitCPU.String())) } limitMem := env.Spec.Resources.Limits[v1.ResourceMemory] @@ -205,7 +205,7 @@ func updateExistingEnvironmentWithCmd(env *fv1.Environment, input cli.Input) (*f if limitMem.IsZero() && !requestMem.IsZero() { env.Spec.Resources.Limits[v1.ResourceMemory] = requestMem } else if limitMem.Cmp(requestMem) < 0 { - e = multierror.Append(e, fmt.Errorf("MinMemory (%v) cannot be greater than MaxMemory (%v)", requestMem.String(), limitMem.String())) + e = multierror.Append(e, fmt.Errorf("minMemory (%v) cannot be greater than MaxMemory (%v)", requestMem.String(), limitMem.String())) } if e.ErrorOrNil() != nil { diff --git a/pkg/fission-cli/cmd/function/create.go b/pkg/fission-cli/cmd/function/create.go index beaa44f17..57bb5691e 100644 --- a/pkg/fission-cli/cmd/function/create.go +++ b/pkg/fission-cli/cmd/function/create.go @@ -342,8 +342,8 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { // generatePackageName => will return package name by appending id in function name and will make sure that package name will never be more than length of 63 characters. func generatePackageName(fnName string, id string) string { var ( - lenFnName int = len(fnName) - lenId int = len(id) + lenFnName = len(fnName) + lenId = len(id) lastIndexOfChar int ) if lenFnName+lenId <= 62 { diff --git a/pkg/fission-cli/cmd/function/test.go b/pkg/fission-cli/cmd/function/test.go index 45dc5dc04..0c7ecec87 100644 --- a/pkg/fission-cli/cmd/function/test.go +++ b/pkg/fission-cli/cmd/function/test.go @@ -130,7 +130,7 @@ func (opts *TestSubCommand) do(input cli.Input) error { if len(methods) == 0 { return errors.New("HTTP method not mentioned") } else if len(methods) > 1 { - return errors.New("More than one HTTP method not supported") + return errors.New("more than one HTTP method not supported") } method, err := httptrigger.GetMethod(methods[0]) if err != nil { diff --git a/pkg/fission-cli/cmd/httptrigger/create.go b/pkg/fission-cli/cmd/httptrigger/create.go index 96b0b89bc..0be4a461c 100644 --- a/pkg/fission-cli/cmd/httptrigger/create.go +++ b/pkg/fission-cli/cmd/httptrigger/create.go @@ -207,7 +207,7 @@ 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 fmt.Errorf("Error while creating HTTP Trigger: %w", err) + 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{}) diff --git a/pkg/fission-cli/cmd/httptrigger/get.go b/pkg/fission-cli/cmd/httptrigger/get.go index 5d91fcad3..5d8baad70 100644 --- a/pkg/fission-cli/cmd/httptrigger/get.go +++ b/pkg/fission-cli/cmd/httptrigger/get.go @@ -94,7 +94,7 @@ func printHtSummary(triggers []fv1.HTTPTrigger) { methods = trigger.Spec.Methods } fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", - trigger.ObjectMeta.Name, methods, trigger.Spec.RelativeURL, function, trigger.Spec.CreateIngress, host, path, trigger.Spec.IngressConfig.TLS, ann, trigger.ObjectMeta.Namespace) + trigger.Name, methods, trigger.Spec.RelativeURL, function, trigger.Spec.CreateIngress, host, path, trigger.Spec.IngressConfig.TLS, ann, trigger.ObjectMeta.Namespace) } w.Flush() } diff --git a/pkg/fission-cli/cmd/httptrigger/update.go b/pkg/fission-cli/cmd/httptrigger/update.go index 643ea7c8c..3d056835d 100644 --- a/pkg/fission-cli/cmd/httptrigger/update.go +++ b/pkg/fission-cli/cmd/httptrigger/update.go @@ -164,7 +164,7 @@ func (opts *UpdateSubCommand) run(input cli.Input) error { } err := util.CheckHTTPTriggerDuplicates(input.Context(), opts.Client(), opts.trigger) if err != nil { - return fmt.Errorf("Error while creating HTTP Trigger: %w", err) + 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{}) diff --git a/pkg/fission-cli/cmd/mqtrigger/create.go b/pkg/fission-cli/cmd/mqtrigger/create.go index bde3d9743..c5116ebec 100644 --- a/pkg/fission-cli/cmd/mqtrigger/create.go +++ b/pkg/fission-cli/cmd/mqtrigger/create.go @@ -68,7 +68,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { mqType := (fv1.MessageQueueType)(input.String(flagkey.MqtMQType)) if !validator.IsValidMessageQueue((string)(mqType), mqtKind) { - return errors.New("Unsupported message queue type") + return errors.New("unsupported message queue type") } topic := input.String(flagkey.MqtTopic) @@ -87,7 +87,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { maxRetries := input.Int(flagkey.MqtMaxRetries) if maxRetries < 0 { - return errors.New("Maximum number of retries must be greater than or equal to 0") + return errors.New("maximum number of retries must be greater than or equal to 0") } contentType := input.String(flagkey.MqtMsgContentType) @@ -102,22 +102,22 @@ func (opts *CreateSubCommand) complete(input cli.Input) error { pollingInterval := int32(input.Int(flagkey.MqtPollingInterval)) if pollingInterval < 0 { - return errors.New("Polling interval must be greater than or equal to 0") + return errors.New("polling interval must be greater than or equal to 0") } cooldownPeriod := int32(input.Int(flagkey.MqtCooldownPeriod)) if cooldownPeriod < 0 { - return errors.New("CooldownPeriod interval is the period to wait after the last trigger reported active before scaling the deployment back to 0, it must be greater than or equal to 0") + return errors.New("cooldownPeriod interval is the period to wait after the last trigger reported active before scaling the deployment back to 0, it must be greater than or equal to 0") } minReplicaCount := int32(input.Int(flagkey.MqtMinReplicaCount)) if minReplicaCount < 0 { - return errors.New("MinReplicaCount must be greater than or equal to 0") + return errors.New("minReplicaCount must be greater than or equal to 0") } maxReplicaCount := int32(input.Int(flagkey.MqtMaxReplicaCount)) if maxReplicaCount < 0 { - return errors.New("MaxReplicaCount must be greater than or equal to 0") + return errors.New("maxReplicaCount must be greater than or equal to 0") } metadata := make(map[string]string) diff --git a/pkg/fission-cli/cmd/mqtrigger/update.go b/pkg/fission-cli/cmd/mqtrigger/update.go index 0fef4e65d..7faea4318 100644 --- a/pkg/fission-cli/cmd/mqtrigger/update.go +++ b/pkg/fission-cli/cmd/mqtrigger/update.go @@ -143,7 +143,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) (err error) { } if !updated { - return errors.New("Nothing changed, see 'help' for more details") + return errors.New("nothing changed, see 'help' for more details") } opts.trigger = mqt diff --git a/pkg/fission-cli/cmd/package/delete.go b/pkg/fission-cli/cmd/package/delete.go index 2c6b4408e..7b0bd2853 100644 --- a/pkg/fission-cli/cmd/package/delete.go +++ b/pkg/fission-cli/cmd/package/delete.go @@ -84,7 +84,7 @@ func (opts *DeleteSubCommand) run(input cli.Input) error { } if !opts.force && len(fnList) > 0 { - return errors.New("Package is used by at least one function, use -f to force delete") + return errors.New("package is used by at least one function, use -f to force delete") } err = deletePackage(input.Context(), opts.Client(), opts.name, opts.namespace) if err != nil { diff --git a/pkg/fission-cli/cmd/package/get.go b/pkg/fission-cli/cmd/package/get.go index 073b575af..3ca6a10ba 100644 --- a/pkg/fission-cli/cmd/package/get.go +++ b/pkg/fission-cli/cmd/package/get.go @@ -85,12 +85,10 @@ func (opts *GetSubCommand) run(input cli.Input) error { if archive.Type == fv1.ArchiveTypeLiteral { reader = bytes.NewReader(archive.Literal) } else if archive.Type == fv1.ArchiveTypeUrl { - readCloser, err := pkgutil.DownloadStrorageURL(input.Context(), opts.Client(), archive.URL) if err != nil { return fmt.Errorf("error downloading from storage service url: %s: %w", archive.URL, err) } - defer readCloser.Close() reader = readCloser } diff --git a/pkg/fission-cli/cmd/package/package.go b/pkg/fission-cli/cmd/package/package.go index e524ea634..ac549e0cf 100644 --- a/pkg/fission-cli/cmd/package/package.go +++ b/pkg/fission-cli/cmd/package/package.go @@ -81,7 +81,7 @@ func CreateArchive(client cmd.Client, input cli.Input, includeFiles []string, no } if !strings.HasPrefix(absPath, 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)) + 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 } @@ -93,7 +93,7 @@ func CreateArchive(client cmd.Client, input cli.Input, includeFiles []string, no } if len(files) == 0 { - errs = multierror.Append(errs, fmt.Errorf("Error finding any files with path \"%v\"", path)) + errs = multierror.Append(errs, fmt.Errorf("error finding any files with path \"%v\"", path)) } } diff --git a/pkg/fission-cli/cmd/package/rebuild.go b/pkg/fission-cli/cmd/package/rebuild.go index 56415f40c..0bf46dba0 100644 --- a/pkg/fission-cli/cmd/package/rebuild.go +++ b/pkg/fission-cli/cmd/package/rebuild.go @@ -61,7 +61,7 @@ func (opts *RebuildSubCommand) run(input cli.Input) error { } if pkg.Status.BuildStatus != fv1.BuildStatusFailed { - return fmt.Errorf("Package %v is not in %v state.", + return fmt.Errorf("package %v is not in %v state", pkg.ObjectMeta.Name, fv1.BuildStatusFailed) } @@ -70,7 +70,7 @@ func (opts *RebuildSubCommand) run(input cli.Input) error { 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) + fmt.Printf("Retrying build for pkg %v. Use \"fission pkg info --name %v\" to view status\n", pkg.ObjectMeta.Name, pkg.ObjectMeta.Name) return nil } diff --git a/pkg/fission-cli/cmd/spec/apply.go b/pkg/fission-cli/cmd/spec/apply.go index 661b57988..da91061a5 100644 --- a/pkg/fission-cli/cmd/spec/apply.go +++ b/pkg/fission-cli/cmd/spec/apply.go @@ -479,19 +479,19 @@ func applyResources(input cli.Input, fclient cmd.Client, specDir string, fr *Fis _, ras, err = applyKubernetesWatchTriggers(input.Context(), fclient, fr, delete, specAllowConflicts) if err != nil { - return nil, nil, fmt.Errorf("KubernetesWatchTrigger apply failed: %w", err) + 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, fmt.Errorf("TimeTrigger apply failed: %w", err) + 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, fmt.Errorf("MessageQueueTrigger apply failed: %w", err) + return nil, nil, fmt.Errorf("messageQueueTrigger apply failed: %w", err) } applyStatus["MessageQueueTrigger"] = *ras @@ -525,7 +525,7 @@ 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, fmt.Errorf("Invalid glob in archive %v: %v: %w", aus.Name, relativeGlob, err) + return nil, fmt.Errorf("invalid glob in archive %v: %v: %w", aus.Name, relativeGlob, err) } files = append(files, fs...) } @@ -747,7 +747,7 @@ func applyPackages(ctx context.Context, fclient cmd.Client, fr *FissionResources return nil, nil, err } ras.Deleted = append(ras.Deleted, &o.ObjectMeta) - fmt.Printf("Deleted %v %v\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %v %v\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } } } @@ -834,7 +834,7 @@ func applyFunctions(ctx context.Context, fclient cmd.Client, fr *FissionResource return nil, nil, err } ras.Deleted = append(ras.Deleted, &o.ObjectMeta) - fmt.Printf("Deleted %v %v\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %v %v\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } } } @@ -921,7 +921,7 @@ func applyEnvironments(ctx context.Context, fclient cmd.Client, fr *FissionResou return nil, nil, err } ras.Deleted = append(ras.Deleted, &o.ObjectMeta) - fmt.Printf("Deleted %v %v\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %v %v\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } } } @@ -1018,7 +1018,7 @@ func applyHTTPTriggers(ctx context.Context, fclient cmd.Client, fr *FissionResou return nil, nil, err } ras.Deleted = append(ras.Deleted, &o.ObjectMeta) - fmt.Printf("Deleted %v %v\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %v %v\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } } } @@ -1105,7 +1105,7 @@ func applyKubernetesWatchTriggers(ctx context.Context, fclient cmd.Client, fr *F return nil, nil, err } ras.Deleted = append(ras.Deleted, &o.ObjectMeta) - fmt.Printf("Deleted %v %v\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %v %v\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } } } @@ -1192,7 +1192,7 @@ func applyTimeTriggers(ctx context.Context, fclient cmd.Client, fr *FissionResou return nil, nil, err } ras.Deleted = append(ras.Deleted, &o.ObjectMeta) - fmt.Printf("Deleted %v %v\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %v %v\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } } } @@ -1279,7 +1279,7 @@ func applyMessageQueueTriggers(ctx context.Context, fclient cmd.Client, fr *Fiss return nil, nil, err } ras.Deleted = append(ras.Deleted, &o.ObjectMeta) - fmt.Printf("Deleted %v %v\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %v %v\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } } } diff --git a/pkg/fission-cli/cmd/spec/destroy.go b/pkg/fission-cli/cmd/spec/destroy.go index d3df1809c..009fae4a3 100644 --- a/pkg/fission-cli/cmd/spec/destroy.go +++ b/pkg/fission-cli/cmd/spec/destroy.go @@ -95,17 +95,17 @@ func forceDeleteResources(ctx context.Context, fclient cmd.Client, fr *FissionRe _, _, err = applyKubernetesWatchTriggers(ctx, fclient, fr, true, false) if err != nil { - return fmt.Errorf("KubernetesWatchTrigger delete failed: %w", err) + return fmt.Errorf("kubernetesWatchTrigger delete failed: %w", err) } _, _, err = applyTimeTriggers(ctx, fclient, fr, true, false) if err != nil { - return fmt.Errorf("TimeTrigger delete failed: %w", err) + return fmt.Errorf("timeTrigger delete failed: %w", err) } _, _, err = applyMessageQueueTriggers(ctx, fclient, fr, true, false) if err != nil { - return fmt.Errorf("MessageQueueTrigger delete failed: %w", err) + return fmt.Errorf("messageQueueTrigger delete failed: %w", err) } _, _, err = applyFunctions(ctx, fclient, fr, true, false) @@ -187,17 +187,17 @@ func deleteResources(ctx context.Context, fclient cmd.Client, fr *FissionResourc err = destroyKubernetesWatchTriggers(ctx, fclient, fr) if err != nil { - return fmt.Errorf("KubernetesWatchTrigger delete failed: %w", err) + return fmt.Errorf("kubernetesWatchTrigger delete failed: %w", err) } err = destroyTimeTriggers(ctx, fclient, fr) if err != nil { - return fmt.Errorf("TimeTrigger delete failed: %w", err) + return fmt.Errorf("timeTrigger delete failed: %w", err) } err = destroyMessageQueueTriggers(ctx, fclient, fr) if err != nil { - return fmt.Errorf("MessageQueueTrigger delete failed: %w", err) + return fmt.Errorf("messageQueueTrigger delete failed: %w", err) } err = destroyFunctions(ctx, fclient, fr) @@ -229,7 +229,7 @@ func destroyHTTPTriggers(ctx context.Context, fclient cmd.Client, fr *FissionRes } else if err != nil { return err } - fmt.Printf("Deleted %s %s\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %s %s\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } return nil } @@ -246,7 +246,7 @@ func destroyKubernetesWatchTriggers(ctx context.Context, fclient cmd.Client, fr } else if err != nil { return err } - fmt.Printf("Deleted %s %s\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %s %s\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } return nil @@ -264,7 +264,7 @@ func destroyTimeTriggers(ctx context.Context, fclient cmd.Client, fr *FissionRes } else if err != nil { return err } - fmt.Printf("Deleted %s %s\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %s %s\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } return nil @@ -282,7 +282,7 @@ func destroyMessageQueueTriggers(ctx context.Context, fclient cmd.Client, fr *Fi } else if err != nil { return err } - fmt.Printf("Deleted %s %s\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %s %s\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } return nil @@ -300,7 +300,7 @@ func destroyFunctions(ctx context.Context, fclient cmd.Client, fr *FissionResour } else if err != nil { return err } - fmt.Printf("Deleted %s %s\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %s %s\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } return nil @@ -318,7 +318,7 @@ func destroyPackages(ctx context.Context, fclient cmd.Client, fr *FissionResourc } else if err != nil { return err } - fmt.Printf("Deleted %s %s\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %s %s\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } return nil @@ -336,7 +336,7 @@ func destroyEnvironments(ctx context.Context, fclient cmd.Client, fr *FissionRes } else if err != nil { return err } - fmt.Printf("Deleted %s %s\n", o.TypeMeta.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) + fmt.Printf("Deleted %s %s\n", o.Kind, k8sCache.MetaObjectToName(&o.ObjectMeta).String()) } return nil diff --git a/pkg/fission-cli/cmd/spec/init.go b/pkg/fission-cli/cmd/spec/init.go index 7d41dddd6..686a50ceb 100644 --- a/pkg/fission-cli/cmd/spec/init.go +++ b/pkg/fission-cli/cmd/spec/init.go @@ -100,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 fmt.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 diff --git a/pkg/fission-cli/cmd/spec/list.go b/pkg/fission-cli/cmd/spec/list.go index 8c7ef2ce5..23ba41d0a 100644 --- a/pkg/fission-cli/cmd/spec/list.go +++ b/pkg/fission-cli/cmd/spec/list.go @@ -365,7 +365,7 @@ func ShowHTTPTriggers(hts []fv1.HTTPTrigger) { } fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\t%v\n", - trigger.ObjectMeta.Name, methods, trigger.Spec.RelativeURL, function, trigger.Spec.CreateIngress, host, path, trigger.Spec.IngressConfig.TLS, ann) + trigger.Name, methods, trigger.Spec.RelativeURL, function, trigger.Spec.CreateIngress, host, path, trigger.Spec.IngressConfig.TLS, ann) } fmt.Fprintf(w, "\n") w.Flush() @@ -396,7 +396,7 @@ func ShowTimeTriggers(tts []fv1.TimeTrigger) { for _, tt := range tts { fmt.Fprintf(w, "%v\t%v\t%v\n", - tt.ObjectMeta.Name, tt.Spec.Cron, tt.Spec.FunctionReference.Name) + tt.ObjectMeta.Name, tt.Spec.Cron, tt.Spec.Name) } fmt.Fprintf(w, "\n") w.Flush() @@ -423,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, fmt.Errorf("Unable to get Functions %v", err.Error()) + return nil, fmt.Errorf("unable to get Functions %v", err.Error()) } return fns.Items, nil } @@ -432,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, fmt.Errorf("Unable to get Environments %v", err.Error()) + return nil, fmt.Errorf("unable to get Environments %v", err.Error()) } return envs.Items, nil } @@ -441,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, fmt.Errorf("Unable to get Packages %v", err.Error()) + return nil, fmt.Errorf("unable to get Packages %v", err.Error()) } return pkgList.Items, nil } @@ -450,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, fmt.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 } @@ -459,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, fmt.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 } @@ -468,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, fmt.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 } @@ -477,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, fmt.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 } @@ -486,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, fmt.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 } diff --git a/pkg/fission-cli/cmd/spec/spec.go b/pkg/fission-cli/cmd/spec/spec.go index 65059bc48..38760cb47 100644 --- a/pkg/fission-cli/cmd/spec/spec.go +++ b/pkg/fission-cli/cmd/spec/spec.go @@ -127,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 fmt.Errorf("Couldn't find specs, run `fission spec init` first: %w", err) + return fmt.Errorf("couldn't find specs, run `fission spec init` first: %w", err) } filename := filepath.Join(specDir, specFile) @@ -194,10 +194,7 @@ func SpecSave(resource interface{}, specFile string, update bool) error { return fmt.Errorf("same name resource (%v) already exists in namespace (%v)", meta.Name, meta.Namespace) } - truncate := false - if update { - truncate = true - } + truncate := update err = save(data, specDir, specFile, truncate) if err != nil { return err @@ -234,46 +231,46 @@ func crdToYaml(resource interface{}) (metav1.ObjectMeta, string, []byte, error) kind = typedres.Kind data, err = yaml.Marshal(typedres) case fv1.Package: - typedres.TypeMeta.APIVersion = fv1.CRD_VERSION - typedres.TypeMeta.Kind = "Package" + typedres.APIVersion = fv1.CRD_VERSION + typedres.Kind = "Package" meta = typedres.ObjectMeta - kind = typedres.TypeMeta.Kind + kind = typedres.Kind data, err = yaml.Marshal(typedres) case fv1.Function: - typedres.TypeMeta.APIVersion = fv1.CRD_VERSION - typedres.TypeMeta.Kind = "Function" + typedres.APIVersion = fv1.CRD_VERSION + typedres.Kind = "Function" meta = typedres.ObjectMeta - kind = typedres.TypeMeta.Kind + kind = typedres.Kind data, err = yaml.Marshal(typedres) case fv1.Environment: - typedres.TypeMeta.APIVersion = fv1.CRD_VERSION - typedres.TypeMeta.Kind = "Environment" + typedres.APIVersion = fv1.CRD_VERSION + typedres.Kind = "Environment" meta = typedres.ObjectMeta - kind = typedres.TypeMeta.Kind + kind = typedres.Kind data, err = yaml.Marshal(typedres) case fv1.HTTPTrigger: - typedres.TypeMeta.APIVersion = fv1.CRD_VERSION - typedres.TypeMeta.Kind = "HTTPTrigger" + typedres.APIVersion = fv1.CRD_VERSION + typedres.Kind = "HTTPTrigger" meta = typedres.ObjectMeta - kind = typedres.TypeMeta.Kind + kind = typedres.Kind data, err = yaml.Marshal(typedres) case fv1.KubernetesWatchTrigger: - typedres.TypeMeta.APIVersion = fv1.CRD_VERSION - typedres.TypeMeta.Kind = "KubernetesWatchTrigger" + typedres.APIVersion = fv1.CRD_VERSION + typedres.Kind = "KubernetesWatchTrigger" meta = typedres.ObjectMeta - kind = typedres.TypeMeta.Kind + kind = typedres.Kind data, err = yaml.Marshal(typedres) case fv1.MessageQueueTrigger: - typedres.TypeMeta.APIVersion = fv1.CRD_VERSION - typedres.TypeMeta.Kind = "MessageQueueTrigger" + typedres.APIVersion = fv1.CRD_VERSION + typedres.Kind = "MessageQueueTrigger" meta = typedres.ObjectMeta - kind = typedres.TypeMeta.Kind + kind = typedres.Kind data, err = yaml.Marshal(typedres) case fv1.TimeTrigger: - typedres.TypeMeta.APIVersion = fv1.CRD_VERSION - typedres.TypeMeta.Kind = "TimeTrigger" + typedres.APIVersion = fv1.CRD_VERSION + typedres.Kind = "TimeTrigger" meta = typedres.ObjectMeta - kind = typedres.TypeMeta.Kind + kind = typedres.Kind data, err = yaml.Marshal(typedres) default: err = fmt.Errorf("unknown object type '%v'", typedres) @@ -558,7 +555,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var tm types.TypeMeta err := yaml.Unmarshal(b, &tm) if err != nil { - return fmt.Errorf("Failed to decode yaml %s: %w", string(b), err) + return fmt.Errorf("failed to decode yaml %s: %w", string(b), err) } switch tm.Kind { @@ -566,7 +563,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var v fv1.Package err = yaml.Unmarshal(b, &v) if err != nil { - return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err) + return fmt.Errorf("failed to parse %v in %v: %w", tm.Kind, loc, err) } m = &v.ObjectMeta applyCommitLabel(commitLabelVal, m) @@ -575,7 +572,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var v fv1.Function err = yaml.Unmarshal(b, &v) if err != nil { - return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err) + return fmt.Errorf("failed to parse %v in %v: %w", tm.Kind, loc, err) } m = &v.ObjectMeta applyCommitLabel(commitLabelVal, m) @@ -584,7 +581,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var v fv1.Environment err = yaml.Unmarshal(b, &v) if err != nil { - return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err) + return fmt.Errorf("failed to parse %v in %v: %w", tm.Kind, loc, err) } m = &v.ObjectMeta applyCommitLabel(commitLabelVal, m) @@ -593,7 +590,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var v fv1.HTTPTrigger err = yaml.Unmarshal(b, &v) if err != nil { - return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err) + return fmt.Errorf("failed to parse %v in %v: %w", tm.Kind, loc, err) } m = &v.ObjectMeta applyCommitLabel(commitLabelVal, m) @@ -602,7 +599,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var v fv1.KubernetesWatchTrigger err = yaml.Unmarshal(b, &v) if err != nil { - return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err) + return fmt.Errorf("failed to parse %v in %v: %w", tm.Kind, loc, err) } m = &v.ObjectMeta applyCommitLabel(commitLabelVal, m) @@ -611,7 +608,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var v fv1.TimeTrigger err = yaml.Unmarshal(b, &v) if err != nil { - return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err) + return fmt.Errorf("failed to parse %v in %v: %w", tm.Kind, loc, err) } m = &v.ObjectMeta applyCommitLabel(commitLabelVal, m) @@ -620,7 +617,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var v fv1.MessageQueueTrigger err = yaml.Unmarshal(b, &v) if err != nil { - return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err) + return fmt.Errorf("failed to parse %v in %v: %w", tm.Kind, loc, err) } m = &v.ObjectMeta applyCommitLabel(commitLabelVal, m) @@ -632,7 +629,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var v types.DeploymentConfig err = yaml.Unmarshal(b, &v) if err != nil { - return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err) + return fmt.Errorf("failed to parse %v in %v: %w", tm.Kind, loc, err) } fr.DeploymentConfig = v @@ -640,7 +637,7 @@ func (fr *FissionResources) ParseYaml(b []byte, loc *Location, commitLabelVal st var v types.ArchiveUploadSpec err = yaml.Unmarshal(b, &v) if err != nil { - return fmt.Errorf("Failed to parse %v in %v: %w", tm.Kind, loc, err) + return fmt.Errorf("failed to parse %v in %v: %w", tm.Kind, loc, err) } m = &metav1.ObjectMeta{ diff --git a/pkg/fission-cli/cmd/spec/validate.go b/pkg/fission-cli/cmd/spec/validate.go index eaf95b135..9f3670d4a 100644 --- a/pkg/fission-cli/cmd/spec/validate.go +++ b/pkg/fission-cli/cmd/spec/validate.go @@ -109,7 +109,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc fnList, err := getAllFunctions(ctx, c, namespace) if err != nil { - return fmt.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 { @@ -122,7 +122,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc envList, err := getAllEnvironments(ctx, c, namespace) if err != nil { - return fmt.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 { @@ -135,7 +135,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc pkgList, err := getAllPackages(ctx, c, namespace) if err != nil { - return fmt.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 { @@ -148,7 +148,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc httptriggerList, err := getAllHTTPTriggers(ctx, c, namespace) if err != nil { - return fmt.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 { @@ -161,7 +161,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc mqtriggerList, err := getAllMessageQueueTriggers(ctx, c, "", namespace) if err != nil { - return fmt.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 { @@ -174,7 +174,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc timetriggerList, err := getAllTimeTriggers(ctx, c, namespace) if err != nil { - return fmt.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 { @@ -187,7 +187,7 @@ func resourceConflictCheck(ctx context.Context, c cmd.Client, fr *FissionResourc kubewatchtriggerList, err := getAllKubeWatchTriggers(ctx, c, namespace) if err != nil { - return fmt.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 { @@ -225,8 +225,8 @@ 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, fmt.Errorf("Spec directory %v doesn't exist. "+ - "Please check directory path or run \"fission spec init\" to create it.", specDir) + return nil, fmt.Errorf("spec directory %v doesn't exist. "+ + "Please check directory path or run \"fission spec init\" to create it", specDir) } ignoreParser, err := util.GetSpecIgnoreParser(specDir, specIgnore) diff --git a/pkg/fission-cli/cmd/support/dump.go b/pkg/fission-cli/cmd/support/dump.go index 905558844..5b93c8e90 100644 --- a/pkg/fission-cli/cmd/support/dump.go +++ b/pkg/fission-cli/cmd/support/dump.go @@ -56,12 +56,12 @@ func (opts *DumpSubCommand) do(input cli.Input) error { panic(err) } } else if err != nil { - panic(fmt.Errorf("Error checking dump directory status: %w", err)) + panic(fmt.Errorf("error checking dump directory status: %w", err)) } outputDir, err = filepath.Abs(outputDir) if err != nil { - panic(fmt.Errorf("Error creating dump directory for dumping files: %w", err)) + panic(fmt.Errorf("error creating dump directory for dumping files: %w", err)) } k8sClient := opts.Client().KubernetesClient diff --git a/pkg/fission-cli/cmd/timetrigger/create.go b/pkg/fission-cli/cmd/timetrigger/create.go index 8eddbe417..76657540f 100644 --- a/pkg/fission-cli/cmd/timetrigger/create.go +++ b/pkg/fission-cli/cmd/timetrigger/create.go @@ -61,7 +61,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) { fnName := input.String(flagkey.TtFnName) if len(fnName) == 0 { - return errors.New("Need a function name to create a trigger, use --function") + return errors.New("need a function name to create a trigger, use --function") } userProvidedNS, fnNamespace, err := opts.GetResourceNamespace(input, flagkey.NamespaceFunction) @@ -71,7 +71,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) { cronSpec := input.String(flagkey.TtCron) if len(cronSpec) == 0 { - return errors.New("Need a cron spec like '30 * * * *', '@every 1h30m', or '@hourly'; use --cron") + return errors.New("need a cron spec like '30 * * * *', '@every 1h30m', or '@hourly'; use --cron") } if input.Bool(flagkey.SpecSave) { diff --git a/pkg/fission-cli/cmd/timetrigger/list.go b/pkg/fission-cli/cmd/timetrigger/list.go index d9d4fd07e..2740037a2 100644 --- a/pkg/fission-cli/cmd/timetrigger/list.go +++ b/pkg/fission-cli/cmd/timetrigger/list.go @@ -56,7 +56,7 @@ func (opts *ListSubCommand) do(input cli.Input) (err error) { fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n", "NAME", "CRON", "FUNCTION_NAME", "METHOD", "SUBPATH") for _, tt := range tts.Items { fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n", - tt.ObjectMeta.Name, tt.Spec.Cron, tt.Spec.FunctionReference.Name, tt.Spec.Method, tt.Spec.Subpath) + tt.ObjectMeta.Name, tt.Spec.Cron, tt.Spec.Name, tt.Spec.Method, tt.Spec.Subpath) } w.Flush() diff --git a/pkg/fission-cli/cmd/timetrigger/update.go b/pkg/fission-cli/cmd/timetrigger/update.go index ec8ce76c9..4da7952dc 100644 --- a/pkg/fission-cli/cmd/timetrigger/update.go +++ b/pkg/fission-cli/cmd/timetrigger/update.go @@ -74,7 +74,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error { if err != nil { console.Warn(err.Error()) } - tt.Spec.FunctionReference.Name = fnName + tt.Spec.Name = fnName updated = true } diff --git a/pkg/fission-cli/console/log.go b/pkg/fission-cli/console/log.go index d1c241d66..44bc623b2 100644 --- a/pkg/fission-cli/console/log.go +++ b/pkg/fission-cli/console/log.go @@ -30,24 +30,24 @@ var ( ) func Error(msg interface{}) { - os.Stderr.WriteString(fmt.Sprintf("%v: %v\n", color.RedString("Error"), trimNewline(msg))) + fmt.Fprintf(os.Stderr, "%v: %v\n", color.RedString("Error"), trimNewline(msg)) } func Errorf(format string, args ...interface{}) { msg := fmt.Sprintf(format, args...) - os.Stderr.WriteString(fmt.Sprintf("%v: %v\n", color.RedString("Error"), trimNewline(msg))) + fmt.Fprintf(os.Stderr, "%v: %v\n", color.RedString("Error"), trimNewline(msg)) } func Warn(msg interface{}) { - os.Stdout.WriteString(fmt.Sprintf("%v: %v\n", color.YellowString("Warning"), trimNewline(msg))) + fmt.Fprintf(os.Stdout, "%v: %v\n", color.YellowString("Warning"), trimNewline(msg)) } func Info(msg interface{}) { - os.Stdout.WriteString(fmt.Sprintf("%v\n", trimNewline(msg))) + fmt.Fprintf(os.Stdout, "%v\n", trimNewline(msg)) } func Infof(format string, args ...interface{}) { - os.Stdout.WriteString(fmt.Sprintf("%v\n", trimNewline(fmt.Sprintf(format, args...)))) + fmt.Fprintf(os.Stdout, "%v\n", trimNewline(fmt.Sprintf(format, args...))) } func Verbose(verbosityLevel int, format string, args ...interface{}) { diff --git a/pkg/fission-cli/util/portforward.go b/pkg/fission-cli/util/portforward.go index 67ca81342..224c479a0 100644 --- a/pkg/fission-cli/util/portforward.go +++ b/pkg/fission-cli/util/portforward.go @@ -135,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, fmt.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, " ")) } } @@ -145,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, fmt.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 @@ -163,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, fmt.Errorf("Error getting %v service: %w", labelSelector, err) + return nil, nil, fmt.Errorf("error getting %v service: %w", labelSelector, err) } if len(svcs.Items) == 0 { - return nil, nil, fmt.Errorf("Service %v not found", labelSelector) + return nil, nil, fmt.Errorf("service %v not found", labelSelector) } service := &svcs.Items[0] @@ -191,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, fmt.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) diff --git a/pkg/fission-cli/util/util.go b/pkg/fission-cli/util/util.go index 4b485ab02..d48dde17a 100644 --- a/pkg/fission-cli/util/util.go +++ b/pkg/fission-cli/util/util.go @@ -255,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, fmt.Errorf("Failed to parse mincpu: %w", err)) + e = multierror.Append(e, fmt.Errorf("failed to parse mincpu: %w", err)) } r.Requests[v1.ResourceCPU] = cpuRequest } @@ -264,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, fmt.Errorf("Failed to parse minmemory: %w", err)) + e = multierror.Append(e, fmt.Errorf("failed to parse minmemory: %w", err)) } r.Requests[v1.ResourceMemory] = memRequest } @@ -273,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, fmt.Errorf("Failed to parse maxcpu: %w", err)) + e = multierror.Append(e, fmt.Errorf("failed to parse maxcpu: %w", err)) } r.Limits[v1.ResourceCPU] = cpuLimit } @@ -282,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, fmt.Errorf("Failed to parse maxmemory: %w", err)) + e = multierror.Append(e, fmt.Errorf("failed to parse maxmemory: %w", err)) } r.Limits[v1.ResourceMemory] = memLimit } @@ -293,7 +293,7 @@ func GetResourceReqs(input cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res if limitCPU.IsZero() && !requestCPU.IsZero() { r.Limits[v1.ResourceCPU] = requestCPU } else if limitCPU.Cmp(requestCPU) < 0 { - e = multierror.Append(e, fmt.Errorf("MinCPU (%v) cannot be greater than MaxCPU (%v)", requestCPU.String(), limitCPU.String())) + e = multierror.Append(e, fmt.Errorf("minCPU (%v) cannot be greater than MaxCPU (%v)", requestCPU.String(), limitCPU.String())) } limitMem := r.Limits[v1.ResourceMemory] @@ -302,7 +302,7 @@ func GetResourceReqs(input cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res if limitMem.IsZero() && !requestMem.IsZero() { r.Limits[v1.ResourceMemory] = requestMem } else if limitMem.Cmp(requestMem) < 0 { - e = multierror.Append(e, fmt.Errorf("MinMemory (%v) cannot be greater than MaxMemory (%v)", requestMem.String(), limitMem.String())) + e = multierror.Append(e, fmt.Errorf("minMemory (%v) cannot be greater than MaxMemory (%v)", requestMem.String(), limitMem.String())) } if e.ErrorOrNil() != nil { @@ -341,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, fmt.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 diff --git a/pkg/kubewatcher/kubewatcher.go b/pkg/kubewatcher/kubewatcher.go index ef55f9e4c..2c3c74ab8 100644 --- a/pkg/kubewatcher/kubewatcher.go +++ b/pkg/kubewatcher/kubewatcher.go @@ -123,23 +123,23 @@ func createKubernetesWatch(ctx context.Context, kubeClient kubernetes.Interface, } func (kw *KubeWatcher) addWatch(ctx context.Context, w *fv1.KubernetesWatchTrigger) error { - kw.logger.Info("adding watch", zap.String("name", w.ObjectMeta.Name), zap.Any("function", w.Spec.FunctionReference)) + kw.logger.Info("adding watch", zap.String("name", w.Name), zap.Any("function", w.Spec.FunctionReference)) ws, err := MakeWatchSubscription(ctx, kw.logger.Named("watchsubscription"), w, kw.kubernetesClient, kw.publisher) if err != nil { return err } - kw.watches[w.ObjectMeta.UID] = *ws + kw.watches[w.UID] = *ws return nil } func (kw *KubeWatcher) removeWatch(w *fv1.KubernetesWatchTrigger) error { - kw.logger.Info("removing watch", zap.String("name", w.ObjectMeta.Name), zap.Any("function", w.Spec.FunctionReference)) - ws, ok := kw.watches[w.ObjectMeta.UID] + kw.logger.Info("removing watch", zap.String("name", w.Name), zap.Any("function", w.Spec.FunctionReference)) + ws, ok := kw.watches[w.UID] if !ok { return ferror.MakeError(ferror.ErrorNotFound, fmt.Sprintf("watch doesn't exist: %v", w.ObjectMeta)) } - delete(kw.watches, w.ObjectMeta.UID) + delete(kw.watches, w.UID) ws.stop() return nil } @@ -198,14 +198,11 @@ func getResourceVersion(obj runtime.Object) (string, error) { func (ws *watchSubscription) eventDispatchLoop(ctx context.Context) { ws.logger.Info("listening to watch", zap.String("name", ws.watch.ObjectMeta.Name)) - for { - // check watchSubscription is stopped or not before waiting for event - // comes from the kubeWatch.ResultChan(). This fix the edge case that - // new kubewatch is created in the restartWatch() while the old kubewatch - // is being used in watchSubscription.stop(). - if ws.isStopped() { - break - } + // check watchSubscription is stopped or not before waiting for event + // comes from the kubeWatch.ResultChan(). This fix the edge case that + // new kubewatch is created in the restartWatch() while the old kubewatch + // is being used in watchSubscription.stop(). + for !ws.isStopped() { ev, more := <-ws.kubeWatch.ResultChan() if !more { if ws.isStopped() { diff --git a/pkg/mqtrigger/messageQueue/kafka/consumer.go b/pkg/mqtrigger/messageQueue/kafka/consumer.go index 7ebc2fc0e..abebb4728 100644 --- a/pkg/mqtrigger/messageQueue/kafka/consumer.go +++ b/pkg/mqtrigger/messageQueue/kafka/consumer.go @@ -75,7 +75,7 @@ func NewMqtConsumerGroupHandler(version sarama.KafkaVersion, // Setup implemented to satisfy the sarama.ConsumerGroupHandler interface func (ch MqtConsumerGroupHandler) Setup(session sarama.ConsumerGroupSession) error { - mqtrigger.SetTriggerStatus(ch.trigger.ObjectMeta.Name, ch.trigger.ObjectMeta.Namespace) + mqtrigger.SetTriggerStatus(ch.trigger.Name, ch.trigger.ObjectMeta.Namespace) mqtrigger.IncreaseInprocessCount() ch.logger.With( zap.String("trigger", ch.trigger.ObjectMeta.Name), @@ -91,7 +91,7 @@ func (ch MqtConsumerGroupHandler) Setup(session sarama.ConsumerGroupSession) err // Cleanup implemented to satisfy the sarama.ConsumerGroupHandler interface func (ch MqtConsumerGroupHandler) Cleanup(session sarama.ConsumerGroupSession) error { - mqtrigger.ResetTriggerStatus(ch.trigger.ObjectMeta.Name, ch.trigger.ObjectMeta.Namespace) + mqtrigger.ResetTriggerStatus(ch.trigger.Name, ch.trigger.ObjectMeta.Namespace) mqtrigger.DecreaseInprocessCount() ch.logger.With( zap.String("trigger", ch.trigger.ObjectMeta.Name), diff --git a/pkg/mqtrigger/mqtmanager.go b/pkg/mqtrigger/mqtmanager.go index a483767f7..0848fdbe4 100644 --- a/pkg/mqtrigger/mqtmanager.go +++ b/pkg/mqtrigger/mqtmanager.go @@ -224,25 +224,25 @@ func (mqt *MessageQueueTriggerManager) delTriggerSubscription(trigger *fv1.Messa func (mqt *MessageQueueTriggerManager) updateTrigger(trigger *fv1.MessageQueueTrigger) error { oldTriggerSubscription := mqt.getTriggerSubscription(trigger) if oldTriggerSubscription == nil { - mqt.logger.Info("Trigger subscrption does not exist", zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Info("Trigger subscrption does not exist", zap.String("trigger_name", trigger.Name)) return errors.New("trigger does not exist") } // unsubscribe the messagequeue err := mqt.messageQueue.Unsubscribe(oldTriggerSubscription.subscription) if err != nil { - mqt.logger.Warn("failed to unsubscribe from message queue trigger", zap.Error(err), zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Warn("failed to unsubscribe from message queue trigger", zap.Error(err), zap.String("trigger_name", trigger.Name)) return err } // subscribe using the updated message queue trigger sub, err := mqt.messageQueue.Subscribe(trigger) if err != nil { - mqt.logger.Warn("failed to re-subscribe to message queue trigger", zap.Error(err), zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Warn("failed to re-subscribe to message queue trigger", zap.Error(err), zap.String("trigger_name", trigger.Name)) return err } if sub == nil { - mqt.logger.Warn("subscription is nil", zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Warn("subscription is nil", zap.String("trigger_name", trigger.Name)) return nil } newTriggerSubscription := triggerSubscription{ @@ -253,17 +253,17 @@ func (mqt *MessageQueueTriggerManager) updateTrigger(trigger *fv1.MessageQueueTr // update our list err = mqt.updateTriggerSubscription(&newTriggerSubscription) if err != nil { - mqt.logger.Fatal("updating message queue trigger failed", zap.Error(err), zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Fatal("updating message queue trigger failed", zap.Error(err), zap.String("trigger_name", trigger.Name)) return err } - mqt.logger.Info("message queue trigger updated", zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Info("message queue trigger updated", zap.String("trigger_name", trigger.Name)) return nil } func (mqt *MessageQueueTriggerManager) RegisterTrigger(trigger *fv1.MessageQueueTrigger) error { isPresent := mqt.checkTriggerSubscription(trigger) if isPresent { - mqt.logger.Debug("updating message queue trigger", zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Debug("updating message queue trigger", zap.String("trigger_name", trigger.Name)) err := mqt.updateTrigger(trigger) if err != nil { mqt.logger.Error("error updating messagequeuetrigger", zap.Error(err)) @@ -275,11 +275,11 @@ func (mqt *MessageQueueTriggerManager) RegisterTrigger(trigger *fv1.MessageQueue // actually subscribe using the message queue client impl sub, err := mqt.messageQueue.Subscribe(trigger) if err != nil { - mqt.logger.Warn("failed to subscribe to message queue trigger", zap.Error(err), zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Warn("failed to subscribe to message queue trigger", zap.Error(err), zap.String("trigger_name", trigger.Name)) return err } if sub == nil { - mqt.logger.Warn("subscription is nil", zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Warn("subscription is nil", zap.String("trigger_name", trigger.Name)) return nil } triggerSub := triggerSubscription{ @@ -289,10 +289,10 @@ func (mqt *MessageQueueTriggerManager) RegisterTrigger(trigger *fv1.MessageQueue // add to our list err = mqt.addTrigger(&triggerSub) if err != nil { - mqt.logger.Fatal("adding message queue trigger failed", zap.Error(err), zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Fatal("adding message queue trigger failed", zap.Error(err), zap.String("trigger_name", trigger.Name)) return err } - mqt.logger.Info("message queue trigger created", zap.String("trigger_name", trigger.ObjectMeta.Name)) + mqt.logger.Info("message queue trigger created", zap.String("trigger_name", trigger.Name)) return nil } diff --git a/pkg/router/auth_test.go b/pkg/router/auth_test.go index 126ec6cc1..7be5b8e71 100644 --- a/pkg/router/auth_test.go +++ b/pkg/router/auth_test.go @@ -39,7 +39,7 @@ func GetRouterWithAuth() *mux.Router { w.WriteHeader(http.StatusOK) _, err := io.WriteString(w, "OK") if err != nil { - fmt.Println(fmt.Errorf("Error in writing string: %s", err)) + fmt.Println(fmt.Errorf("error in writing string: %s", err)) } } diff --git a/pkg/router/functionHandler.go b/pkg/router/functionHandler.go index 3c2b30d6e..78f479a1f 100644 --- a/pkg/router/functionHandler.go +++ b/pkg/router/functionHandler.go @@ -383,7 +383,7 @@ func (roundTripper *RetryingRoundTripper) RoundTrip(req *http.Request) (*http.Re executingTimeout = executingTimeout * time.Duration(roundTripper.funcHandler.tsRoundTripperParams.timeoutExponent) } - e := errors.New("Unable to get service url for connection") + e := errors.New("unable to get service url for connection") logger.Error(e.Error()) return nil, e } @@ -510,11 +510,7 @@ func findCeil(randomNumber int, wtDistrList []functionWeightDistribution) string low := 0 high := len(wtDistrList) - 1 - for { - if low >= high { - break - } - + for low < high { mid := low + high/2 if randomNumber >= wtDistrList[mid].sumPrefix { low = mid + 1 diff --git a/pkg/router/functionReferenceResolver.go b/pkg/router/functionReferenceResolver.go index 9cc4d4385..9a03e34e8 100644 --- a/pkg/router/functionReferenceResolver.go +++ b/pkg/router/functionReferenceResolver.go @@ -83,7 +83,7 @@ func makeFunctionReferenceResolver(logger *zap.Logger, funcInformer map[string]k func (frr *functionReferenceResolver) resolve(trigger fv1.HTTPTrigger) (*resolveResult, error) { nfr := namespacedTriggerReference{ namespace: trigger.ObjectMeta.Namespace, - triggerName: trigger.ObjectMeta.Name, + triggerName: trigger.Name, triggerResourceVersion: trigger.ObjectMeta.ResourceVersion, } diff --git a/pkg/router/ingress.go b/pkg/router/ingress.go index d4bb654da..e382fc280 100644 --- a/pkg/router/ingress.go +++ b/pkg/router/ingress.go @@ -56,7 +56,7 @@ func deleteIngress(ctx context.Context, logger *zap.Logger, trigger *fv1.HTTPTri return } - ingress, err := kubeClient.NetworkingV1().Ingresses(podNamespace).Get(ctx, trigger.ObjectMeta.Name, v1.GetOptions{}) + ingress, err := kubeClient.NetworkingV1().Ingresses(podNamespace).Get(ctx, trigger.Name, v1.GetOptions{}) if err != nil && !k8serrors.IsNotFound(err) { logger.Error("failed to get ingress when deleting trigger", zap.Error(err), zap.String("trigger", trigger.ObjectMeta.Name)) return diff --git a/pkg/router/util/util.go b/pkg/router/util/util.go index 3154999cb..22290bfe3 100644 --- a/pkg/router/util/util.go +++ b/pkg/router/util/util.go @@ -55,11 +55,11 @@ func GetIngressSpec(namespace string, trigger *fv1.HTTPTrigger) *v1.Ingress { } } - var pathType v1.PathType = v1.PathTypeImplementationSpecific + var pathType = v1.PathTypeImplementationSpecific ing := &v1.Ingress{ ObjectMeta: metav1.ObjectMeta{ Labels: GetDeployLabels(trigger), - Name: trigger.ObjectMeta.Name, + Name: trigger.Name, // The Ingress NS MUST be same as Router NS, check long discussion: // https://github.com/kubernetes/kubernetes/issues/17088 // We need to revisit this in future, once Kubernetes supports cross namespace ingress @@ -99,7 +99,7 @@ func GetIngressSpec(namespace string, trigger *fv1.HTTPTrigger) *v1.Ingress { func GetDeployLabels(trigger *fv1.HTTPTrigger) map[string]string { // TODO: support function weight return map[string]string{ - "triggerName": trigger.ObjectMeta.Name, + "triggerName": trigger.Name, "functionName": trigger.Spec.FunctionReference.Name, "triggerNamespace": trigger.ObjectMeta.Namespace, } diff --git a/pkg/router/util/util_test.go b/pkg/router/util/util_test.go index 185a6001f..1889a6c14 100644 --- a/pkg/router/util/util_test.go +++ b/pkg/router/util/util_test.go @@ -31,7 +31,7 @@ func TestGetIngressSpec(t *testing.T) { ingressNS string trigger *fv1.HTTPTrigger } - var pathType v1.PathType = v1.PathTypeImplementationSpecific + var pathType = v1.PathTypeImplementationSpecific tests := []struct { name string args args diff --git a/pkg/storagesvc/storagesvc.go b/pkg/storagesvc/storagesvc.go index 6a363d41f..69cec6f1c 100644 --- a/pkg/storagesvc/storagesvc.go +++ b/pkg/storagesvc/storagesvc.go @@ -293,7 +293,7 @@ func Start(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger * // create a storage client storageClient, err := MakeStowClient(logger, storage) if err != nil { - return fmt.Errorf("Error creating stowClient: %w", err) + return fmt.Errorf("error creating stowClient: %w", err) } // create http handlers @@ -315,7 +315,7 @@ func Start(ctx context.Context, clientGen crd.ClientGeneratorInterface, logger * } pruner, err := MakeArchivePruner(logger, clientGen, storageClient, time.Duration(pruneInterval)) if err != nil { - return fmt.Errorf("Error creating archivePruner: %w", err) + return fmt.Errorf("error creating archivePruner: %w", err) } mgr.Add(ctx, func(ctx context.Context) { pruner.Start(ctx, mgr) diff --git a/pkg/storagesvc/stowClient.go b/pkg/storagesvc/stowClient.go index 5e06b6cf7..598b88430 100644 --- a/pkg/storagesvc/stowClient.go +++ b/pkg/storagesvc/stowClient.go @@ -53,7 +53,7 @@ const ( // StorageTypeS3 is a constant to hold S3 storage type name literal StorageTypeS3 StorageType = "s3" // PaginationSize is a constant to hold no of pages - PaginationSize int = 10 + PaginationSize = 10 ) var ( @@ -96,7 +96,7 @@ func getOrCreateContainer(loc stow.Location, containerName string, cursor string con, err = getContainer(loc, containerName, stow.CursorStart) } if con == nil && err == nil { - err = fmt.Errorf("Storage container %s not found", containerName) + err = fmt.Errorf("storage container %s not found", containerName) } return con, err } @@ -105,7 +105,7 @@ func getOrCreateContainer(loc stow.Location, containerName string, cursor string func MakeStowClient(logger *zap.Logger, storage Storage) (*StowClient, error) { storageType := getStorageType(storage) if strings.Compare(storageType, "local") == 1 && strings.Compare(storageType, "s3") == 1 { - return nil, errors.New("Storage types other than 'local' and 's3' are not implemented") + return nil, errors.New("storage types other than 'local' and 's3' are not implemented") } config := &storageConfig{ diff --git a/pkg/throttler/throttler.go b/pkg/throttler/throttler.go index f0a3400cf..1eb24134e 100644 --- a/pkg/throttler/throttler.go +++ b/pkg/throttler/throttler.go @@ -83,7 +83,7 @@ func (l *actionLock) wait() error { case <-ch: return nil case <-time.After(l.timeExpiry): - return errors.New("Error waiting for actionLock to be released: Exceeded timeout") + return errors.New("error waiting for actionLock to be released: Exceeded timeout") } } diff --git a/pkg/timer/timer.go b/pkg/timer/timer.go index 56337bbdc..9e8dd624f 100644 --- a/pkg/timer/timer.go +++ b/pkg/timer/timer.go @@ -57,7 +57,7 @@ func MakeTimer(logger *zap.Logger, publisher publisher.Publisher) *Timer { } func (timer *Timer) newCron(t fv1.TimeTrigger) *cron.Cron { - target := utils.UrlForFunction(t.Spec.FunctionReference.Name, t.Namespace) + t.Spec.Subpath + target := utils.UrlForFunction(t.Spec.Name, t.Namespace) + t.Spec.Subpath c := cron.New( cron.WithParser( cron.NewParser( diff --git a/pkg/utils/gitrepo/gitrepo.go b/pkg/utils/gitrepo/gitrepo.go index fb4fde29e..8f17ad5f8 100644 --- a/pkg/utils/gitrepo/gitrepo.go +++ b/pkg/utils/gitrepo/gitrepo.go @@ -41,7 +41,7 @@ type GitRepo struct { // accordingly updates the fields of GitRepo struct and returns it func NewGitRepo(dirPath string) *GitRepo { - var g *GitRepo = &GitRepo{} + var g = &GitRepo{} var err error g.dirPath = dirPath @@ -102,12 +102,11 @@ The value of the `commit` label for different status of the file is as follows: func (g *GitRepo) GetFileCommitLabel(filePath string) (string, error) { if !g.setupDone { - return "", errors.New(`GitRepo is not setup. It has to be created by calling 'NewGitRepo' function, - then this function has to be called.`) + return "", errors.New(`gitrepo is not setup. It has to be created by calling 'NewGitRepo' function, then this function has to be called`) } if !g.isGitRepo { - return "", fmt.Errorf(`directory: %s doesn't belong to git repository.`, g.dirPath) + return "", fmt.Errorf(`directory: %s doesn't belong to git repository`, g.dirPath) } // filepath in the git repository diff --git a/pkg/webhook/function.go b/pkg/webhook/function.go index 691c76429..a03e3b3aa 100644 --- a/pkg/webhook/function.go +++ b/pkg/webhook/function.go @@ -86,7 +86,7 @@ func (r *Function) ValidateDelete(_ context.Context, _ runtime.Object) (admissio func (r *Function) validate(_ *v1.Function, new *v1.Function) error { for _, cnfMap := range new.Spec.ConfigMaps { if cnfMap.Namespace != new.Namespace { - err := fmt.Errorf("ConfigMap's [%s] and function's Namespace [%s] are different. ConfigMap needs to be present in the same namespace as function", cnfMap.Namespace, new.Namespace) + err := fmt.Errorf("configMap's [%s] and function's Namespace [%s] are different. ConfigMap needs to be present in the same namespace as function", cnfMap.Namespace, new.Namespace) return v1.AggregateValidationErrors("Function", err) } } diff --git a/test/e2e/cli/cli_test.go b/test/e2e/cli/cli_test.go index cc4a61bc6..c55d290d7 100644 --- a/test/e2e/cli/cli_test.go +++ b/test/e2e/cli/cli_test.go @@ -280,7 +280,7 @@ func TestFissionCLI(t *testing.T) { require.NoError(t, err) require.NotNil(t, tt) require.Equal(t, "test-tt", tt.Name) - require.Equal(t, "test-func", tt.Spec.FunctionReference.Name) + require.Equal(t, "test-func", tt.Spec.Name) require.Equal(t, "@every 1m", tt.Spec.Cron) require.Equal(t, "POST", tt.Spec.Method) require.Equal(t, "/", tt.Spec.Subpath) @@ -304,7 +304,7 @@ func TestFissionCLI(t *testing.T) { require.NoError(t, err) require.NotNil(t, tt) require.Equal(t, "test-tt", tt.Name) - require.Equal(t, "test-func", tt.Spec.FunctionReference.Name) + require.Equal(t, "test-func", tt.Spec.Name) require.Equal(t, "@every 2m", tt.Spec.Cron) require.Equal(t, "GET", tt.Spec.Method) require.Equal(t, "/api/v1/fetch", tt.Spec.Subpath) diff --git a/tools/cmd-docs/main.go b/tools/cmd-docs/main.go index 4e9d0028c..bcb17a721 100644 --- a/tools/cmd-docs/main.go +++ b/tools/cmd-docs/main.go @@ -27,7 +27,7 @@ var filePrepender = func(filename string) string { name := filepath.Base(filename) base := strings.TrimSuffix(name, path.Ext(name)) url := baseURL + strings.ToLower(base) + "/" - return fmt.Sprintf(fmTemplate, strings.Replace(base, "_", " ", -1), base, url) + return fmt.Sprintf(fmTemplate, strings.ReplaceAll(base, "_", " "), base, url) } var linkHandler = func(name string) string {