Skip to content

Commit

Permalink
fix linters
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Marcantonio <jmarcant@redhat.com>
  • Loading branch information
lennysgarage committed Jul 5, 2022
1 parent ba96762 commit 6049b48
Show file tree
Hide file tree
Showing 27 changed files with 152 additions and 371 deletions.
33 changes: 14 additions & 19 deletions common/config/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,61 +31,56 @@ linters:
enable-all: true
disable:
- bodyclose
- contextcheck
- cyclop
- depguard
- dupl
- forbidigo
- funlen
- errchkjson
- exhaustive
- exhaustruct
- exhaustivestruct
- funlen
- forcetypeassert
- gci
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo

- godot
- goerr113
- gofumpt
- golint
- gomnd
- gomoddirectives
- gosec
- ifshort
- ireturn
- ineffassign
- interfacer
- maintidx
- ireturn
- maintidx
- maligned
- nakedret
- nestif
- nilnil
- nlreturn
- noctx
- nonamedreturns
- nolintlint
- nonamedreturns
- paralleltest
- prealloc
- predeclared
- scopelint
- stylecheck
- tagliatelle
- tenv
- thelper
- testpackage
- unused
- typecheck
- thelper
- varnamelen
- wastedassign
- wrapcheck
- gosimple
- nilerr
- forcetypeassert
- cyclop
- errchkjson
- errorlint
- contextcheck
- forbidigo
- gocritic
- gomoddirectives
- staticcheck
fast: false

linters-settings:
Expand Down
4 changes: 2 additions & 2 deletions pkg/addonmanager/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *subscriptionAgent) Manifests(cluster *clusterv1.ManagedCluster, addon *

if err != nil {
return objects, fmt.Errorf(
"error while decoding YAML file %s. Err was: %s", file, err)
"error while decoding YAML file %s. Err was: %w", file, err)
}

objects = append(objects, obj)
Expand All @@ -97,7 +97,7 @@ func (s *subscriptionAgent) Manifests(cluster *clusterv1.ManagedCluster, addon *

if err != nil {
return objects, fmt.Errorf(
"error while decoding YAML object file %s. Err was: %s", agentDeploymentFile, err)
"error while decoding YAML object file %s. Err was: %w", agentDeploymentFile, err)
}

deployment := obj.(*appsv1.Deployment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package appsubsummary
import (
"context"
"log"
stdlog "log"
"os"
"path/filepath"
"sync"
Expand Down Expand Up @@ -55,7 +54,7 @@ func TestMain(m *testing.M) {

var err error
if cfg, err = t.Start(); err != nil {
stdlog.Fatal(err)
log.Fatal(err)
}

var c client.Client
Expand Down
96 changes: 0 additions & 96 deletions pkg/controller/mcmhub/deployable.go

This file was deleted.

17 changes: 8 additions & 9 deletions pkg/controller/mcmhub/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
ansiblejob "open-cluster-management.io/multicloud-operators-subscription/pkg/apis/apps/ansible/v1alpha1"
appv1 "open-cluster-management.io/multicloud-operators-subscription/pkg/apis/apps/v1"
subv1 "open-cluster-management.io/multicloud-operators-subscription/pkg/apis/apps/v1"
placementutils "open-cluster-management.io/multicloud-operators-subscription/pkg/placementrule/utils"
"open-cluster-management.io/multicloud-operators-subscription/pkg/utils"
Expand Down Expand Up @@ -76,9 +75,9 @@ type HookProcessor interface {
//also the procssed subscription(which should carry all the update status on
//the given reconciel), then WriteStatusToSubscription will append the hook
//status info and make a update to the cluster
AppendStatusToSubscription(*appv1.Subscription) appv1.SubscriptionStatus
AppendStatusToSubscription(*subv1.Subscription) subv1.SubscriptionStatus

AppendPreHookStatusToSubscription(*appv1.Subscription) appv1.SubscriptionStatus
AppendPreHookStatusToSubscription(*subv1.Subscription) subv1.SubscriptionStatus

GetLastAppliedInstance(types.NamespacedName) AppliedInstance
}
Expand Down Expand Up @@ -346,12 +345,12 @@ func getHookPath(subIns *subv1.Subscription) (string, string) {
annotations := subIns.GetAnnotations()

preHookPath, postHookPath := "", ""
if annotations[appv1.AnnotationGithubPath] != "" {
preHookPath = fmt.Sprintf("%v/prehook", annotations[appv1.AnnotationGithubPath])
postHookPath = fmt.Sprintf("%v/posthook", annotations[appv1.AnnotationGithubPath])
} else if annotations[appv1.AnnotationGitPath] != "" {
preHookPath = fmt.Sprintf("%v/prehook", annotations[appv1.AnnotationGitPath])
postHookPath = fmt.Sprintf("%v/posthook", annotations[appv1.AnnotationGitPath])
if annotations[subv1.AnnotationGithubPath] != "" {
preHookPath = fmt.Sprintf("%v/prehook", annotations[subv1.AnnotationGithubPath])
postHookPath = fmt.Sprintf("%v/posthook", annotations[subv1.AnnotationGithubPath])
} else if annotations[subv1.AnnotationGitPath] != "" {
preHookPath = fmt.Sprintf("%v/prehook", annotations[subv1.AnnotationGitPath])
postHookPath = fmt.Sprintf("%v/posthook", annotations[subv1.AnnotationGitPath])
}

return preHookPath, postHookPath
Expand Down
13 changes: 6 additions & 7 deletions pkg/controller/mcmhub/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"github.com/ghodss/yaml"
. "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -262,14 +261,14 @@ var _ = Describe("given a subscription pointing to a git path without hook folde
u := &subv1.Subscription{}

if err := k8sClt.Get(ctx, subKey, u); err != nil {
return fmt.Errorf("failed to get subscription %s, err: %s", subKey, err.Error())
return fmt.Errorf("failed to get subscription %s, err: %w", subKey, err)
}

fmt.Printf("subscription= %+v\n", u)

appsubReport := &appsubReportV1alpha1.SubscriptionReport{}
if err := k8sClt.Get(ctx, appsubReportKey, appsubReport); err != nil {
return fmt.Errorf("failed to get the appsub AppsubReport %s, err: %s", appsubReportKey, err.Error())
return fmt.Errorf("failed to get the appsub AppsubReport %s, err: %w", appsubReportKey, err)
}

fmt.Printf("AppsubReport= %+v\n", appsubReport)
Expand Down Expand Up @@ -302,7 +301,7 @@ var _ = Describe("given a subscription pointing to a git path,where pre hook fol

testManagedCluster := &spokeClusterV1.ManagedCluster{}
err := yaml.Unmarshal([]byte(testCluster), &testManagedCluster)
Expect(err).NotTo(gomega.HaveOccurred())
Expect(err).NotTo(HaveOccurred())

Expect(k8sClt.Create(ctx, testManagedCluster)).Should(Succeed())
Expect(k8sClt.Create(ctx, chnIns.DeepCopy())).Should(Succeed())
Expand Down Expand Up @@ -394,7 +393,7 @@ var _ = Describe("given a subscription pointing to a git path,where pre hook fol

testManagedCluster := &spokeClusterV1.ManagedCluster{}
err := yaml.Unmarshal([]byte(testCluster), &testManagedCluster)
Expect(err).NotTo(gomega.HaveOccurred())
Expect(err).NotTo(HaveOccurred())

Expect(k8sClt.Create(ctx, testManagedCluster)).Should(Succeed())
Expect(k8sClt.Create(ctx, chnIns.DeepCopy())).Should(Succeed())
Expand Down Expand Up @@ -556,7 +555,7 @@ var _ = Describe("given a subscription pointing to a git path,where post hook fo
testManagedCluster := &spokeClusterV1.ManagedCluster{}
err := yaml.Unmarshal([]byte(testCluster), &testManagedCluster)
Expect(err).NotTo(gomega.HaveOccurred())
Expect(err).NotTo(HaveOccurred())
Expect(k8sClt.Create(ctx, testManagedCluster)).Should(Succeed())
Expand Down Expand Up @@ -818,7 +817,7 @@ var _ = Describe("given a subscription pointing to a git path,where both pre and
testManagedCluster := &spokeClusterV1.ManagedCluster{}
err := yaml.Unmarshal([]byte(testCluster), &testManagedCluster)
Expect(err).NotTo(gomega.HaveOccurred())
Expect(err).NotTo(HaveOccurred())
Expect(k8sClt.Create(ctx, testManagedCluster)).Should(Succeed())
Expect(k8sClt.Create(ctx, testPath.chnIns.DeepCopy())).Should(Succeed())
Expand Down
Loading

0 comments on commit 6049b48

Please sign in to comment.