diff --git a/api/v1alpha1/iamrole_webhook.go b/api/v1alpha1/iamrole_webhook.go index 64c7a0d..77328a0 100644 --- a/api/v1alpha1/iamrole_webhook.go +++ b/api/v1alpha1/iamrole_webhook.go @@ -18,8 +18,6 @@ package v1alpha1 import ( "context" "fmt" - "github.com/keikoproj/iam-manager/internal/config" - "github.com/keikoproj/iam-manager/pkg/log" "strings" "github.com/keikoproj/iam-manager/pkg/k8s" @@ -31,6 +29,9 @@ import ( ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" "sigs.k8s.io/controller-runtime/pkg/webhook" + + "github.com/keikoproj/iam-manager/internal/config" + "github.com/keikoproj/iam-manager/pkg/log" ) const ( diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 19b98dd..50c8377 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/controllers/iamrole_controller.go b/controllers/iamrole_controller.go index ee7b310..661aa29 100644 --- a/controllers/iamrole_controller.go +++ b/controllers/iamrole_controller.go @@ -20,27 +20,28 @@ import ( "encoding/json" "errors" "fmt" + "math" + "strings" + "time" + "github.com/aws/aws-sdk-go/aws" - "github.com/keikoproj/iam-manager/internal/config" - "github.com/keikoproj/iam-manager/internal/utils" - "github.com/keikoproj/iam-manager/pkg/awsapi" - "github.com/keikoproj/iam-manager/pkg/k8s" - "github.com/keikoproj/iam-manager/pkg/log" - "github.com/keikoproj/iam-manager/pkg/validation" "github.com/pborman/uuid" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/tools/record" - "math" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" - "strings" - "time" iammanagerv1alpha1 "github.com/keikoproj/iam-manager/api/v1alpha1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/keikoproj/iam-manager/internal/config" + "github.com/keikoproj/iam-manager/internal/utils" + "github.com/keikoproj/iam-manager/pkg/awsapi" + "github.com/keikoproj/iam-manager/pkg/k8s" + "github.com/keikoproj/iam-manager/pkg/log" + "github.com/keikoproj/iam-manager/pkg/validation" ) const ( diff --git a/controllers/iamrole_controller_test.go b/controllers/iamrole_controller_test.go index 5744841..17fbb3a 100644 --- a/controllers/iamrole_controller_test.go +++ b/controllers/iamrole_controller_test.go @@ -1,11 +1,12 @@ package controllers_test import ( - iammanagerv1alpha1 "github.com/keikoproj/iam-manager/api/v1alpha1" - . "github.com/keikoproj/iam-manager/controllers" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "sigs.k8s.io/controller-runtime/pkg/event" + + iammanagerv1alpha1 "github.com/keikoproj/iam-manager/api/v1alpha1" + . "github.com/keikoproj/iam-manager/controllers" ) var _ = Describe("IamroleController", func() { diff --git a/internal/config/properties.go b/internal/config/properties.go index d06be9a..08fc586 100644 --- a/internal/config/properties.go +++ b/internal/config/properties.go @@ -3,14 +3,16 @@ package config import ( "context" "fmt" - "github.com/keikoproj/iam-manager/pkg/awsapi" - "github.com/keikoproj/iam-manager/pkg/k8s" - "github.com/keikoproj/iam-manager/pkg/log" - "k8s.io/api/core/v1" - "k8s.io/client-go/tools/cache" "os" "strconv" "strings" + + "k8s.io/api/core/v1" + "k8s.io/client-go/tools/cache" + + "github.com/keikoproj/iam-manager/pkg/awsapi" + "github.com/keikoproj/iam-manager/pkg/k8s" + "github.com/keikoproj/iam-manager/pkg/log" ) var ( diff --git a/internal/config/properties_test.go b/internal/config/properties_test.go index c6ed8aa..8f08295 100644 --- a/internal/config/properties_test.go +++ b/internal/config/properties_test.go @@ -2,11 +2,12 @@ package config import ( "context" + "strings" + "testing" + "github.com/golang/mock/gomock" "gopkg.in/check.v1" "k8s.io/api/core/v1" - "strings" - "testing" ) type PropertiesSuite struct { diff --git a/internal/utils/oidc.go b/internal/utils/oidc.go index 74ca95b..34d86c5 100644 --- a/internal/utils/oidc.go +++ b/internal/utils/oidc.go @@ -7,11 +7,11 @@ import ( "crypto/x509" "errors" "fmt" + "net/url" + "github.com/keikoproj/iam-manager/api/v1alpha1" "github.com/keikoproj/iam-manager/internal/config" "github.com/keikoproj/iam-manager/pkg/log" - - "net/url" ) //GetIdpServerCertThumbprint gets the Thumbbprint of the certificate which will be used to generate OIDC tokens diff --git a/internal/utils/oidc_test.go b/internal/utils/oidc_test.go index c1a83ac..9550f20 100644 --- a/internal/utils/oidc_test.go +++ b/internal/utils/oidc_test.go @@ -2,13 +2,15 @@ package utils_test import ( "context" + "testing" + "github.com/golang/mock/gomock" + "gopkg.in/check.v1" + "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/keikoproj/iam-manager/api/v1alpha1" "github.com/keikoproj/iam-manager/internal/config" "github.com/keikoproj/iam-manager/internal/utils" - "gopkg.in/check.v1" - "k8s.io/apimachinery/pkg/apis/meta/v1" - "testing" ) type OIDCTestSuite struct { diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 85e01cb..083d4b0 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -6,12 +6,14 @@ import ( "encoding/json" "errors" "fmt" + "strings" + "text/template" + + "k8s.io/api/core/v1" + iammanagerv1alpha1 "github.com/keikoproj/iam-manager/api/v1alpha1" "github.com/keikoproj/iam-manager/internal/config" "github.com/keikoproj/iam-manager/pkg/log" - "k8s.io/api/core/v1" - "strings" - "text/template" ) //GetTrustPolicy constructs trust policy diff --git a/internal/utils/utils_test.go b/internal/utils/utils_test.go index 0d9c72d..06b87d0 100644 --- a/internal/utils/utils_test.go +++ b/internal/utils/utils_test.go @@ -3,14 +3,16 @@ package utils_test import ( "context" "encoding/json" + "testing" + "github.com/golang/mock/gomock" - "github.com/keikoproj/iam-manager/api/v1alpha1" - "github.com/keikoproj/iam-manager/internal/config" - "github.com/keikoproj/iam-manager/internal/utils" "gopkg.in/check.v1" v12 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1" - "testing" + + "github.com/keikoproj/iam-manager/api/v1alpha1" + "github.com/keikoproj/iam-manager/internal/config" + "github.com/keikoproj/iam-manager/internal/utils" ) type UtilsTestSuite struct { diff --git a/main.go b/main.go index e224c07..600de82 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,14 @@ package main import ( "context" "flag" + "os" + + // +kubebuilder:scaffold:imports + "k8s.io/apimachinery/pkg/runtime" + clientgoscheme "k8s.io/client-go/kubernetes/scheme" + _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" + ctrl "sigs.k8s.io/controller-runtime" + iammanagerv1alpha1 "github.com/keikoproj/iam-manager/api/v1alpha1" "github.com/keikoproj/iam-manager/controllers" "github.com/keikoproj/iam-manager/internal/config" @@ -25,17 +33,10 @@ import ( "github.com/keikoproj/iam-manager/pkg/awsapi" "github.com/keikoproj/iam-manager/pkg/k8s" "github.com/keikoproj/iam-manager/pkg/log" - "k8s.io/apimachinery/pkg/runtime" - clientgoscheme "k8s.io/client-go/kubernetes/scheme" - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" - "os" - ctrl "sigs.k8s.io/controller-runtime" - // +kubebuilder:scaffold:imports ) var ( scheme = runtime.NewScheme() - //setupLog = ctrl.Log.WithName("setup") ) func init() { diff --git a/pkg/awsapi/eks.go b/pkg/awsapi/eks.go index 26fcd7e..9de2f96 100644 --- a/pkg/awsapi/eks.go +++ b/pkg/awsapi/eks.go @@ -4,11 +4,13 @@ package awsapi import ( "context" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/eks" "github.com/aws/aws-sdk-go/service/eks/eksiface" + "github.com/keikoproj/iam-manager/pkg/log" ) diff --git a/pkg/awsapi/eks_test.go b/pkg/awsapi/eks_test.go index 8e8f9fa..fd6cb55 100644 --- a/pkg/awsapi/eks_test.go +++ b/pkg/awsapi/eks_test.go @@ -3,15 +3,17 @@ package awsapi_test import ( "context" "errors" + "testing" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/eks" "github.com/golang/mock/gomock" + "gopkg.in/check.v1" + "github.com/keikoproj/iam-manager/internal/config" "github.com/keikoproj/iam-manager/pkg/awsapi" "github.com/keikoproj/iam-manager/pkg/awsapi/mocks" - "gopkg.in/check.v1" - "testing" ) type EKSAPISuite struct { diff --git a/pkg/awsapi/iam.go b/pkg/awsapi/iam.go index 5ca902d..81b577c 100644 --- a/pkg/awsapi/iam.go +++ b/pkg/awsapi/iam.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/iam/iamiface" + "github.com/keikoproj/iam-manager/pkg/log" ) diff --git a/pkg/awsapi/iam_test.go b/pkg/awsapi/iam_test.go index 9b66af5..451f46b 100644 --- a/pkg/awsapi/iam_test.go +++ b/pkg/awsapi/iam_test.go @@ -3,15 +3,17 @@ package awsapi_test import ( "context" "errors" + "testing" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/iam" "github.com/golang/mock/gomock" + "gopkg.in/check.v1" + "github.com/keikoproj/iam-manager/internal/config" "github.com/keikoproj/iam-manager/pkg/awsapi" "github.com/keikoproj/iam-manager/pkg/awsapi/mocks" - "gopkg.in/check.v1" - "testing" ) type IAMAPISuite struct { diff --git a/pkg/awsapi/sts.go b/pkg/awsapi/sts.go index 2600750..69a51d7 100644 --- a/pkg/awsapi/sts.go +++ b/pkg/awsapi/sts.go @@ -5,10 +5,12 @@ package awsapi import ( "context" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/sts" "github.com/aws/aws-sdk-go/service/sts/stsiface" + "github.com/keikoproj/iam-manager/pkg/log" ) diff --git a/pkg/awsapi/sts_test.go b/pkg/awsapi/sts_test.go index b2dc492..4b89905 100644 --- a/pkg/awsapi/sts_test.go +++ b/pkg/awsapi/sts_test.go @@ -3,14 +3,16 @@ package awsapi_test import ( "context" "errors" + "testing" + "github.com/aws/aws-sdk-go/service/iam" "github.com/aws/aws-sdk-go/service/sts" "github.com/golang/mock/gomock" + "gopkg.in/check.v1" + "github.com/keikoproj/iam-manager/internal/config" "github.com/keikoproj/iam-manager/pkg/awsapi" mock_awsapi "github.com/keikoproj/iam-manager/pkg/awsapi/mocks" - "gopkg.in/check.v1" - "testing" ) type STSAPISuite struct { diff --git a/pkg/k8s/client.go b/pkg/k8s/client.go index 614fb63..7d644ef 100644 --- a/pkg/k8s/client.go +++ b/pkg/k8s/client.go @@ -3,12 +3,7 @@ package k8s import ( "context" "fmt" - "github.com/keikoproj/iam-manager/pkg/log" - "k8s.io/api/core/v1" - "k8s.io/client-go/tools/cache" - "k8s.io/client-go/tools/clientcmd" "os" - "sigs.k8s.io/controller-runtime/pkg/client" "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -21,6 +16,12 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/record" "k8s.io/klog" + + "github.com/keikoproj/iam-manager/pkg/log" + "k8s.io/api/core/v1" + "k8s.io/client-go/tools/cache" + "k8s.io/client-go/tools/clientcmd" + "sigs.k8s.io/controller-runtime/pkg/client" ) type Client struct { diff --git a/pkg/k8s/rbac.go b/pkg/k8s/rbac.go index baabc9b..f43800e 100644 --- a/pkg/k8s/rbac.go +++ b/pkg/k8s/rbac.go @@ -4,11 +4,12 @@ import ( "context" "errors" "fmt" - "github.com/keikoproj/iam-manager/pkg/log" - "k8s.io/apimachinery/pkg/apis/meta/v1" corev1 "k8s.io/api/core/v1" apierr "k8s.io/apimachinery/pkg/api/errors" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/keikoproj/iam-manager/pkg/log" ) //CreateServiceAccount adds the service account diff --git a/pkg/log/log.go b/pkg/log/log.go index 7abd261..290b6a7 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -2,6 +2,7 @@ package log import ( "context" + "github.com/go-logr/logr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log/zap" diff --git a/pkg/validation/validate.go b/pkg/validation/validate.go index 2719314..88964c1 100644 --- a/pkg/validation/validate.go +++ b/pkg/validation/validate.go @@ -4,19 +4,21 @@ import ( "context" "encoding/json" "fmt" + "net/url" + "reflect" + "strings" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/iam" + "github.com/pkg/errors" + v1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/util/validation/field" + "github.com/keikoproj/iam-manager/api/v1alpha1" "github.com/keikoproj/iam-manager/internal/config" "github.com/keikoproj/iam-manager/internal/utils" "github.com/keikoproj/iam-manager/pkg/awsapi" "github.com/keikoproj/iam-manager/pkg/log" - "github.com/pkg/errors" - "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/util/validation/field" - "net/url" - "reflect" - "strings" ) //ValidateIAMPolicyAction validates policy action diff --git a/pkg/validation/validate_test.go b/pkg/validation/validate_test.go index 6318c4c..eb407cc 100644 --- a/pkg/validation/validate_test.go +++ b/pkg/validation/validate_test.go @@ -3,17 +3,19 @@ package validation_test import ( "context" "encoding/json" + "testing" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/iam" "github.com/golang/mock/gomock" + "gopkg.in/check.v1" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "github.com/keikoproj/iam-manager/api/v1alpha1" "github.com/keikoproj/iam-manager/internal/config" "github.com/keikoproj/iam-manager/pkg/awsapi" "github.com/keikoproj/iam-manager/pkg/validation" - "gopkg.in/check.v1" - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "testing" ) type ValidateSuite struct {