Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: introduce gci linter for golangci-lint #461

Merged
12 changes: 9 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ run:
linters:
enable:
- gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification
# - dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
- gci # Gci controls golang package import order and makes it always deterministic.
# - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
# - containedctx # containedctx is a linter that detects struct contained context.Context field
# - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
# - gci # Gci controls golang package import order and makes it always deterministic.
# - dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
# - nilnil # Checks that there is no simultaneous return of nil error and an invalid value.
# - noctx # noctx finds sending http request without context.Context

issues:
exclude-rules:
- linters:
- gci
text: '//+kubebuilder'
3 changes: 1 addition & 2 deletions operator/api/v1alpha1/keptnappversion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ import (
"fmt"
"time"

"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand Down
3 changes: 1 addition & 2 deletions operator/controllers/common/evaluationhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/go-logr/logr"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
apicommon "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/propagation"
Expand All @@ -15,8 +16,6 @@ import (
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
)

type EvaluationHandler struct {
Expand Down
3 changes: 1 addition & 2 deletions operator/controllers/common/taskhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/go-logr/logr"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
apicommon "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
"go.opentelemetry.io/otel"
Expand All @@ -16,8 +17,6 @@ import (
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
)

type TaskHandler struct {
Expand Down
1 change: 1 addition & 0 deletions operator/controllers/common/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package common
import (
"context"
"fmt"

lfcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
keptncommon "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
"go.opentelemetry.io/otel/metric/instrument"
Expand Down
10 changes: 4 additions & 6 deletions operator/controllers/keptnapp/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@ import (
"context"
"fmt"

"github.com/go-logr/logr"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/controllers/common"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/predicate"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
Expand All @@ -33,12 +32,11 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/go-logr/logr"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
)

// KeptnAppReconciler reconciles a KeptnApp object
Expand Down
5 changes: 3 additions & 2 deletions operator/controllers/keptnapp/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package keptnapp

import (
"context"
"reflect"
"testing"

lfcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
keptncommon "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
utils "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
Expand All @@ -13,10 +16,8 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/record"
"reflect"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"testing"
)

// Example Unit test on help function
Expand Down
19 changes: 8 additions & 11 deletions operator/controllers/keptnappversion/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,22 @@ import (
"fmt"
"time"

controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"

"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/predicate"

"github.com/go-logr/logr"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

// KeptnAppVersionReconciler reconciles a KeptnAppVersion object
Expand Down
7 changes: 4 additions & 3 deletions operator/controllers/keptnappversion/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package keptnappversion
import (
"context"
"fmt"
"reflect"
"strings"
"testing"

lfcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
keptncommon "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
utils "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
Expand All @@ -13,12 +17,9 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/record"
"reflect"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"strings"
"testing"
)

type contextID string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"context"
"fmt"

controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"

klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
)

func (r *KeptnAppVersionReconciler) reconcilePrePostDeployment(ctx context.Context, appVersion *klcv1alpha1.KeptnAppVersion, checkType common.CheckType) (common.KeptnState, error) {
Expand Down
10 changes: 4 additions & 6 deletions operator/controllers/keptnevaluation/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ package keptnevaluation
import (
"context"
"fmt"
"time"

"math"
"net/http"
"strconv"
"time"

"github.com/go-logr/logr"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
promapi "github.com/prometheus/client_golang/api"
prometheus "github.com/prometheus/client_golang/api/prometheus/v1"
Expand All @@ -41,10 +43,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/predicate"

"github.com/go-logr/logr"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
)

// KeptnEvaluationReconciler reconciles a KeptnEvaluation object
Expand Down
1 change: 0 additions & 1 deletion operator/controllers/keptntask/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"time"

"github.com/go-logr/logr"

klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
Expand Down
3 changes: 1 addition & 2 deletions operator/controllers/keptntask/job_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (
"fmt"
"reflect"

"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"

"github.com/imdario/mergo"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
batchv1 "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down
3 changes: 2 additions & 1 deletion operator/controllers/keptntask/job_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package keptntask

import (
"context"
"testing"

klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
"github.com/stretchr/testify/require"
Expand All @@ -12,7 +14,6 @@ import (
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"testing"
)

func TestKeptnTaskReconciler_createJob(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions operator/controllers/keptntaskdefinition/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ import (
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/tools/record"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down
18 changes: 8 additions & 10 deletions operator/controllers/keptnworkload/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,23 @@ import (
"context"
"fmt"

"github.com/go-logr/logr"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/predicate"

"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
)

// KeptnWorkloadReconciler reconciles a KeptnWorkload object
Expand Down
18 changes: 8 additions & 10 deletions operator/controllers/keptnworkloadinstance/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,23 @@ import (
"fmt"
"time"

"github.com/go-logr/logr"
version "github.com/hashicorp/go-version"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/propagation"
"go.opentelemetry.io/otel/trace"

"github.com/go-logr/logr"
version "github.com/hashicorp/go-version"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)

// KeptnWorkloadInstanceReconciler reconciles a KeptnWorkloadInstance object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package keptnworkloadinstance
import (
"context"
"fmt"
"strings"
"testing"

"github.com/go-logr/logr"
klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
keptncommon "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
Expand All @@ -24,8 +27,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
k8sfake "sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"strings"
"testing"
)

func TestKeptnWorkloadInstanceReconciler_reconcileDeployment_FailedReplicaSet(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package keptnworkloadinstance

import (
"context"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"

klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1"
"github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common"
controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down
Loading