diff --git a/.golangci.yml b/.golangci.yml index 40a28a983b..b6648a3ad5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -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' diff --git a/operator/api/v1alpha1/keptnappversion_types.go b/operator/api/v1alpha1/keptnappversion_types.go index 16da556e68..9aab380b5f 100644 --- a/operator/api/v1alpha1/keptnappversion_types.go +++ b/operator/api/v1alpha1/keptnappversion_types.go @@ -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! diff --git a/operator/controllers/common/evaluationhandler.go b/operator/controllers/common/evaluationhandler.go index 0d060d1fc9..6e881e3431 100644 --- a/operator/controllers/common/evaluationhandler.go +++ b/operator/controllers/common/evaluationhandler.go @@ -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" @@ -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 { diff --git a/operator/controllers/common/taskhandler.go b/operator/controllers/common/taskhandler.go index 4e022f94dd..de1315ba66 100644 --- a/operator/controllers/common/taskhandler.go +++ b/operator/controllers/common/taskhandler.go @@ -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" @@ -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 { diff --git a/operator/controllers/common/test_utils.go b/operator/controllers/common/test_utils.go index 755bfba3b5..d038c61cd3 100644 --- a/operator/controllers/common/test_utils.go +++ b/operator/controllers/common/test_utils.go @@ -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" diff --git a/operator/controllers/keptnapp/controller.go b/operator/controllers/keptnapp/controller.go index 0f2a85b740..a7b1317397 100644 --- a/operator/controllers/keptnapp/controller.go +++ b/operator/controllers/keptnapp/controller.go @@ -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" @@ -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 diff --git a/operator/controllers/keptnapp/controller_test.go b/operator/controllers/keptnapp/controller_test.go index e14fd9fe86..97b299afee 100644 --- a/operator/controllers/keptnapp/controller_test.go +++ b/operator/controllers/keptnapp/controller_test.go @@ -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" @@ -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 diff --git a/operator/controllers/keptnappversion/controller.go b/operator/controllers/keptnappversion/controller.go index 69c151be4d..7f2f2f0aa6 100644 --- a/operator/controllers/keptnappversion/controller.go +++ b/operator/controllers/keptnappversion/controller.go @@ -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 diff --git a/operator/controllers/keptnappversion/controller_test.go b/operator/controllers/keptnappversion/controller_test.go index 5f4f9e150f..2ce9e19007 100644 --- a/operator/controllers/keptnappversion/controller_test.go +++ b/operator/controllers/keptnappversion/controller_test.go @@ -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" @@ -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 diff --git a/operator/controllers/keptnappversion/reconcile_prepostdeployment.go b/operator/controllers/keptnappversion/reconcile_prepostdeployment.go index 7f74613063..cdfc9d72e2 100644 --- a/operator/controllers/keptnappversion/reconcile_prepostdeployment.go +++ b/operator/controllers/keptnappversion/reconcile_prepostdeployment.go @@ -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) { diff --git a/operator/controllers/keptnevaluation/controller.go b/operator/controllers/keptnevaluation/controller.go index cfb9df11e4..1ed6fadb3b 100644 --- a/operator/controllers/keptnevaluation/controller.go +++ b/operator/controllers/keptnevaluation/controller.go @@ -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" @@ -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 diff --git a/operator/controllers/keptntask/controller.go b/operator/controllers/keptntask/controller.go index b134c05ca7..d455075733 100644 --- a/operator/controllers/keptntask/controller.go +++ b/operator/controllers/keptntask/controller.go @@ -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" diff --git a/operator/controllers/keptntask/job_utils.go b/operator/controllers/keptntask/job_utils.go index a91b282f79..e6422d75d4 100644 --- a/operator/controllers/keptntask/job_utils.go +++ b/operator/controllers/keptntask/job_utils.go @@ -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" diff --git a/operator/controllers/keptntask/job_utils_test.go b/operator/controllers/keptntask/job_utils_test.go index 609fb53997..ded766559c 100644 --- a/operator/controllers/keptntask/job_utils_test.go +++ b/operator/controllers/keptntask/job_utils_test.go @@ -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" @@ -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) { diff --git a/operator/controllers/keptntaskdefinition/controller.go b/operator/controllers/keptntaskdefinition/controller.go index 71e7a666d5..a01b2c0763 100644 --- a/operator/controllers/keptntaskdefinition/controller.go +++ b/operator/controllers/keptntaskdefinition/controller.go @@ -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" ) diff --git a/operator/controllers/keptnworkload/controller.go b/operator/controllers/keptnworkload/controller.go index 528e5b4706..53c2b2784c 100644 --- a/operator/controllers/keptnworkload/controller.go +++ b/operator/controllers/keptnworkload/controller.go @@ -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 diff --git a/operator/controllers/keptnworkloadinstance/controller.go b/operator/controllers/keptnworkloadinstance/controller.go index e37eea1637..cb7525bcee 100644 --- a/operator/controllers/keptnworkloadinstance/controller.go +++ b/operator/controllers/keptnworkloadinstance/controller.go @@ -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 diff --git a/operator/controllers/keptnworkloadinstance/controller_test.go b/operator/controllers/keptnworkloadinstance/controller_test.go index d76946431b..248034e5d6 100644 --- a/operator/controllers/keptnworkloadinstance/controller_test.go +++ b/operator/controllers/keptnworkloadinstance/controller_test.go @@ -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" @@ -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) { diff --git a/operator/controllers/keptnworkloadinstance/reconcile_deploymentstate.go b/operator/controllers/keptnworkloadinstance/reconcile_deploymentstate.go index 2f411c0f99..4b248d0eb1 100644 --- a/operator/controllers/keptnworkloadinstance/reconcile_deploymentstate.go +++ b/operator/controllers/keptnworkloadinstance/reconcile_deploymentstate.go @@ -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" diff --git a/operator/main.go b/operator/main.go index a20711dae0..b81a8900f2 100644 --- a/operator/main.go +++ b/operator/main.go @@ -22,60 +22,46 @@ import ( "fmt" "log" "net/http" + "os" "time" "github.com/kelseyhightower/envconfig" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" - - "github.com/keptn/lifecycle-toolkit/operator/controllers/keptnappversion" - + lifecyclev1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1" "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common" - - "github.com/keptn/lifecycle-toolkit/operator/controllers/keptnworkload" - "github.com/keptn/lifecycle-toolkit/operator/controllers/keptnworkloadinstance" - - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promhttp" - + controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" "github.com/keptn/lifecycle-toolkit/operator/controllers/keptnapp" + "github.com/keptn/lifecycle-toolkit/operator/controllers/keptnappversion" "github.com/keptn/lifecycle-toolkit/operator/controllers/keptnevaluation" "github.com/keptn/lifecycle-toolkit/operator/controllers/keptntask" "github.com/keptn/lifecycle-toolkit/operator/controllers/keptntaskdefinition" - + "github.com/keptn/lifecycle-toolkit/operator/controllers/keptnworkload" + "github.com/keptn/lifecycle-toolkit/operator/controllers/keptnworkloadinstance" + "github.com/keptn/lifecycle-toolkit/operator/webhooks" + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promhttp" "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" - "go.opentelemetry.io/otel/propagation" - "go.opentelemetry.io/otel/sdk/resource" - "go.opentelemetry.io/otel/sdk/trace" - semconv "go.opentelemetry.io/otel/semconv/v1.4.0" - - controllercommon "github.com/keptn/lifecycle-toolkit/operator/controllers/common" - - "os" - "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" otelprom "go.opentelemetry.io/otel/exporters/prometheus" + "go.opentelemetry.io/otel/exporters/stdout/stdouttrace" "go.opentelemetry.io/otel/metric/instrument" "go.opentelemetry.io/otel/metric/unit" + "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/sdk/metric" - - "sigs.k8s.io/controller-runtime/pkg/webhook" - - // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) - // to ensure that exec-entrypoint and run can make use of them. - _ "k8s.io/client-go/plugin/pkg/client/auth" - + "go.opentelemetry.io/otel/sdk/resource" + "go.opentelemetry.io/otel/sdk/trace" + semconv "go.opentelemetry.io/otel/semconv/v1.4.0" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" + // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) + // to ensure that exec-entrypoint and run can make use of them. + _ "k8s.io/client-go/plugin/pkg/client/auth" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" - - lifecyclev1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1" - - "github.com/keptn/lifecycle-toolkit/operator/webhooks" + "sigs.k8s.io/controller-runtime/pkg/webhook" //+kubebuilder:scaffold:imports ) diff --git a/operator/test/component/appcontroller_test.go b/operator/test/component/appcontroller_test.go index 21c55cf42b..6136df066e 100644 --- a/operator/test/component/appcontroller_test.go +++ b/operator/test/component/appcontroller_test.go @@ -2,6 +2,7 @@ package component import ( "fmt" + klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1" "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common" keptncontroller "github.com/keptn/lifecycle-toolkit/operator/controllers/common" diff --git a/operator/test/component/load_test.go b/operator/test/component/load_test.go index d8b8b308aa..d3cc78f7d7 100644 --- a/operator/test/component/load_test.go +++ b/operator/test/component/load_test.go @@ -2,6 +2,11 @@ package component import ( "fmt" + "log" + "os" + "path" + "time" + klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1" keptncontroller "github.com/keptn/lifecycle-toolkit/operator/controllers/common" "github.com/keptn/lifecycle-toolkit/operator/controllers/keptnapp" @@ -10,10 +15,6 @@ import ( otelsdk "go.opentelemetry.io/otel/sdk/trace" sdktest "go.opentelemetry.io/otel/sdk/trace/tracetest" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "log" - "os" - "path" - "time" ) type Metric struct { diff --git a/operator/test/component/taskcontroller_test.go b/operator/test/component/taskcontroller_test.go index d1bf0c30a0..4e9e2467de 100644 --- a/operator/test/component/taskcontroller_test.go +++ b/operator/test/component/taskcontroller_test.go @@ -2,6 +2,8 @@ package component import ( "context" + "os" + klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1" keptncommon "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common" keptncontroller "github.com/keptn/lifecycle-toolkit/operator/controllers/common" @@ -14,7 +16,6 @@ import ( v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "os" ) var _ = Describe("KeptnTaskController", Ordered, func() { diff --git a/operator/test/e2e/suite_test.go b/operator/test/e2e/suite_test.go index eefc56f304..e58c2cedb6 100644 --- a/operator/test/e2e/suite_test.go +++ b/operator/test/e2e/suite_test.go @@ -19,6 +19,11 @@ package e2e import ( "context" "fmt" + "os" + "sync" + "testing" + "time" + klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1" . "github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2/types" @@ -26,14 +31,10 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" - "os" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sync" - "testing" - "time" //+kubebuilder:scaffold:imports ) diff --git a/operator/webhooks/pod_mutating_webhook.go b/operator/webhooks/pod_mutating_webhook.go index 6108793fa1..a404e0c384 100644 --- a/operator/webhooks/pod_mutating_webhook.go +++ b/operator/webhooks/pod_mutating_webhook.go @@ -4,12 +4,11 @@ import ( "context" "encoding/json" "fmt" + "hash/fnv" "net/http" "reflect" "strings" - appsv1 "k8s.io/api/apps/v1" - "github.com/go-logr/logr" klcv1alpha1 "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1" "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common" @@ -18,16 +17,14 @@ import ( "go.opentelemetry.io/otel/codes" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/trace" - "sigs.k8s.io/controller-runtime/pkg/log" - - "hash/fnv" - + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" ) diff --git a/operator/webhooks/pod_mutating_webhook_test.go b/operator/webhooks/pod_mutating_webhook_test.go index ed74b1004a..5ba78c9f39 100644 --- a/operator/webhooks/pod_mutating_webhook_test.go +++ b/operator/webhooks/pod_mutating_webhook_test.go @@ -2,6 +2,9 @@ package webhooks import ( "context" + "reflect" + "testing" + "github.com/go-logr/logr" "github.com/go-logr/logr/testr" "github.com/keptn/lifecycle-toolkit/operator/api/v1alpha1/common" @@ -14,10 +17,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" - "reflect" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" - "testing" ) func TestPodMutatingWebhook_getOwnerReference(t *testing.T) { diff --git a/scheduler/cmd/scheduler/main.go b/scheduler/cmd/scheduler/main.go index 2154649194..794e23e28e 100644 --- a/scheduler/cmd/scheduler/main.go +++ b/scheduler/cmd/scheduler/main.go @@ -25,22 +25,20 @@ import ( "time" "github.com/kelseyhightower/envconfig" - "go.opentelemetry.io/otel/exporters/otlp" - "go.opentelemetry.io/otel/exporters/otlp/otlpgrpc" - "google.golang.org/grpc" - "k8s.io/klog/v2" - "github.com/keptn/lifecycle-toolkit/scheduler/pkg/klcpermit" - "k8s.io/apimachinery/pkg/util/rand" - "k8s.io/component-base/cli" - "k8s.io/kubernetes/cmd/kube-scheduler/app" - "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/exporters/otlp" + "go.opentelemetry.io/otel/exporters/otlp/otlpgrpc" "go.opentelemetry.io/otel/exporters/stdout" "go.opentelemetry.io/otel/propagation" "go.opentelemetry.io/otel/sdk/resource" sdktrace "go.opentelemetry.io/otel/sdk/trace" "go.opentelemetry.io/otel/semconv" + "google.golang.org/grpc" + "k8s.io/apimachinery/pkg/util/rand" + "k8s.io/component-base/cli" + "k8s.io/klog/v2" + "k8s.io/kubernetes/cmd/kube-scheduler/app" ) var ( diff --git a/scheduler/pkg/klcpermit/workflow_manager.go b/scheduler/pkg/klcpermit/workflow_manager.go index 50095c75c5..05c50aa5d1 100644 --- a/scheduler/pkg/klcpermit/workflow_manager.go +++ b/scheduler/pkg/klcpermit/workflow_manager.go @@ -7,16 +7,15 @@ import ( "strings" "github.com/keptn/lifecycle-toolkit/scheduler/pkg/tracing" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/trace" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic" "k8s.io/klog/v2" - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/trace" ) var workloadInstanceResource = schema.GroupVersionResource{Group: "lifecycle.keptn.sh", Version: "v1alpha1", Resource: "keptnworkloadinstances"} diff --git a/scheduler/pkg/klcpermit/workflow_manager_test.go b/scheduler/pkg/klcpermit/workflow_manager_test.go index 1c028c0393..e113057afc 100644 --- a/scheduler/pkg/klcpermit/workflow_manager_test.go +++ b/scheduler/pkg/klcpermit/workflow_manager_test.go @@ -1,9 +1,10 @@ package klcpermit import ( + "testing" + corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "testing" ) func Test_getCRDName(t *testing.T) { diff --git a/scheduler/pkg/tracing/semconv.go b/scheduler/pkg/tracing/semconv.go index 0be5ffad6b..dd977e1923 100644 --- a/scheduler/pkg/tracing/semconv.go +++ b/scheduler/pkg/tracing/semconv.go @@ -2,6 +2,7 @@ package tracing import ( "context" + "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/trace" diff --git a/scheduler/test/e2e/fake/v1alpha1/keptnworkloadinstance_types.go b/scheduler/test/e2e/fake/v1alpha1/keptnworkloadinstance_types.go index a3b478142c..2a5fa26698 100644 --- a/scheduler/test/e2e/fake/v1alpha1/keptnworkloadinstance_types.go +++ b/scheduler/test/e2e/fake/v1alpha1/keptnworkloadinstance_types.go @@ -17,9 +17,9 @@ limitations under the License. package v1alpha1 import ( - "github.com/keptn/lifecycle-toolkit/scheduler/test/e2e/fake/v1alpha1/common" "time" + "github.com/keptn/lifecycle-toolkit/scheduler/test/e2e/fake/v1alpha1/common" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/scheduler/test/e2e/suite_test.go b/scheduler/test/e2e/suite_test.go index 54edbe5c6f..4bef536b40 100644 --- a/scheduler/test/e2e/suite_test.go +++ b/scheduler/test/e2e/suite_test.go @@ -19,6 +19,11 @@ package e2e import ( "context" "fmt" + "os" + "sync" + "testing" + "time" + testv1alpha1 "github.com/keptn/lifecycle-toolkit/scheduler/test/e2e/fake/v1alpha1" . "github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2/types" @@ -26,14 +31,10 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" kscheme "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" - "os" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - "sync" - "testing" - "time" //+kubebuilder:scaffold:imports )