diff --git a/Dockerfile b/Containerile similarity index 90% rename from Dockerfile rename to Containerile index 43cfcb0..fe9acd9 100644 --- a/Dockerfile +++ b/Containerile @@ -10,12 +10,11 @@ COPY go.sum go.sum RUN go mod download # Copy the go source -COPY main.go main.go -COPY api/ api/ -COPY controllers/ controllers/ +COPY pkg/ pkg/ +COPY cmd/ cmd/ # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager cmd/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/Makefile b/Makefile index 3d24b90..5ed012f 100644 --- a/Makefile +++ b/Makefile @@ -64,11 +64,11 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: manifests generate fmt vet ## Build manager binary. - go build -o bin/manager main.go + go build -o bin/manager cmd/main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. - go run ./main.go + go run ./cmd/main.go # If you wish built the manager image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. diff --git a/PROJECT b/PROJECT index 2b6551f..1c58ed9 100644 --- a/PROJECT +++ b/PROJECT @@ -10,6 +10,6 @@ resources: domain: awsauth.io group: crd kind: AwsAuthMapSnippet - path: github.com/inovex/aws-auth-controller/api/v1beta1 + path: github.com/inovex/aws-auth-controller/pkg/api/v1beta1 version: v1beta1 version: "3" diff --git a/main.go b/cmd/main.go similarity index 96% rename from main.go rename to cmd/main.go index d7f0c66..aab97b6 100644 --- a/main.go +++ b/cmd/main.go @@ -31,8 +31,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" - crdv1beta1 "github.com/inovex/aws-auth-controller/api/v1beta1" - "github.com/inovex/aws-auth-controller/controllers" + crdv1beta1 "github.com/inovex/aws-auth-controller/pkg/api/v1beta1" + "github.com/inovex/aws-auth-controller/pkg/controllers" //+kubebuilder:scaffold:imports ) diff --git a/go.mod b/go.mod index cab25de..b0dd38f 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( k8s.io/api v0.26.3 k8s.io/apimachinery v0.26.3 k8s.io/client-go v0.26.3 - sigs.k8s.io/controller-runtime v0.14.5 + sigs.k8s.io/controller-runtime v0.14.6 sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index 346d86b..3da910b 100644 --- a/go.sum +++ b/go.sum @@ -615,6 +615,8 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/controller-runtime v0.14.5 h1:6xaWFqzT5KuAQ9ufgUaj1G/+C4Y1GRkhrxl+BJ9i+5s= sigs.k8s.io/controller-runtime v0.14.5/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= +sigs.k8s.io/controller-runtime v0.14.6 h1:oxstGVvXGNnMvY7TAESYk+lzr6S3V5VFxQ6d92KcwQA= +sigs.k8s.io/controller-runtime v0.14.6/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= diff --git a/api/v1beta1/awsauthmapsnippet_types.go b/pkg/api/v1beta1/awsauthmapsnippet_types.go similarity index 100% rename from api/v1beta1/awsauthmapsnippet_types.go rename to pkg/api/v1beta1/awsauthmapsnippet_types.go diff --git a/api/v1beta1/groupversion_info.go b/pkg/api/v1beta1/groupversion_info.go similarity index 100% rename from api/v1beta1/groupversion_info.go rename to pkg/api/v1beta1/groupversion_info.go diff --git a/api/v1beta1/zz_generated.deepcopy.go b/pkg/api/v1beta1/zz_generated.deepcopy.go similarity index 100% rename from api/v1beta1/zz_generated.deepcopy.go rename to pkg/api/v1beta1/zz_generated.deepcopy.go diff --git a/controllers/awsauth.go b/pkg/controllers/awsauth.go similarity index 98% rename from controllers/awsauth.go rename to pkg/controllers/awsauth.go index 2f24078..654d9f2 100644 --- a/controllers/awsauth.go +++ b/pkg/controllers/awsauth.go @@ -3,7 +3,7 @@ package controllers import ( "context" - crdv1beta1 "github.com/inovex/aws-auth-controller/api/v1beta1" + crdv1beta1 "github.com/inovex/aws-auth-controller/pkg/api/v1beta1" corev1 "k8s.io/api/core/v1" apierrs "k8s.io/apimachinery/pkg/api/errors" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/controllers/awsauthmapsnippet_controller.go b/pkg/controllers/awsauthmapsnippet_controller.go similarity index 99% rename from controllers/awsauthmapsnippet_controller.go rename to pkg/controllers/awsauthmapsnippet_controller.go index a622551..e8dc901 100644 --- a/controllers/awsauthmapsnippet_controller.go +++ b/pkg/controllers/awsauthmapsnippet_controller.go @@ -26,7 +26,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/log" - crdv1beta1 "github.com/inovex/aws-auth-controller/api/v1beta1" + crdv1beta1 "github.com/inovex/aws-auth-controller/pkg/api/v1beta1" ) // AwsAuthMapSnippetReconciler reconciles an AwsAuthMapSnippet object diff --git a/controllers/awsauthmapsnippet_controller_test.go b/pkg/controllers/awsauthmapsnippet_controller_test.go similarity index 98% rename from controllers/awsauthmapsnippet_controller_test.go rename to pkg/controllers/awsauthmapsnippet_controller_test.go index 2256370..8d6dede 100644 --- a/controllers/awsauthmapsnippet_controller_test.go +++ b/pkg/controllers/awsauthmapsnippet_controller_test.go @@ -4,7 +4,7 @@ import ( "context" "time" - crdv1beta1 "github.com/inovex/aws-auth-controller/api/v1beta1" + crdv1beta1 "github.com/inovex/aws-auth-controller/pkg/api/v1beta1" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/controllers/suite_test.go b/pkg/controllers/suite_test.go similarity index 95% rename from controllers/suite_test.go rename to pkg/controllers/suite_test.go index 81cebd1..f329e9d 100644 --- a/controllers/suite_test.go +++ b/pkg/controllers/suite_test.go @@ -33,7 +33,7 @@ import ( logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - crdv1beta1 "github.com/inovex/aws-auth-controller/api/v1beta1" + crdv1beta1 "github.com/inovex/aws-auth-controller/pkg/api/v1beta1" //+kubebuilder:scaffold:imports ) @@ -74,7 +74,7 @@ var _ = BeforeSuite(func() { By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, }