Skip to content

Commit

Permalink
refactor: put code in pkg and cmd (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
henninge authored Mar 31, 2023
1 parent 9a81ad5 commit 28c0c5a
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 15 deletions.
7 changes: 3 additions & 4 deletions Dockerfile → Containerile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions main.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion controllers/awsauth.go → pkg/controllers/awsauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions controllers/suite_test.go → pkg/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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,
}

Expand Down

0 comments on commit 28c0c5a

Please sign in to comment.