diff --git a/.gitignore b/.gitignore index e2883f72..e16dcc09 100644 --- a/.gitignore +++ b/.gitignore @@ -90,4 +90,7 @@ tags # Support for Project snippet scope +# Created by Mac +*.DS_Store + # End of https://www.toptal.com/developers/gitignore/api/go,vim,visualstudiocode,git diff --git a/Dockerfile b/Dockerfile index 0155d528..f09f5bff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,10 +10,11 @@ COPY go.mod go.sum ./ COPY vendor/ vendor/ # Copy the project source -COPY main.go Makefile ./ +COPY Makefile ./ +COPY cmd/main.go cmd/main.go COPY hack/ hack/ COPY api/ api/ -COPY controllers/ controllers/ +COPY internal/controller/ internal/controller/ COPY config/ config/ COPY pkg/ pkg/ COPY service/ service/ diff --git a/Makefile b/Makefile index 55ba6813..e91ddb75 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ go-build: ## Run go build against code. @GOBIN=${GOBIN} ./hack/go-build.sh run: manifests generate fmt vet ## Run a controller from your host. - go run ./main.go + go run ./cmd/main.go container-build: test ## Build container image with the manager. $(IMAGE_BUILD_CMD) build --platform="linux/amd64" -t ${IMG} . diff --git a/PROJECT b/PROJECT index 85efe3a6..c89508ea 100644 --- a/PROJECT +++ b/PROJECT @@ -4,7 +4,7 @@ # More info: https://book.kubebuilder.io/reference/project-config.html domain: openshift.io layout: -- go.kubebuilder.io/v3 +- go.kubebuilder.io/v4 plugins: manifests.sdk.operatorframework.io/v2: {} scorecard.sdk.operatorframework.io/v2: {} diff --git a/main.go b/cmd/main.go similarity index 96% rename from main.go rename to cmd/main.go index cddfb8ae..68b5cb75 100644 --- a/main.go +++ b/cmd/main.go @@ -21,7 +21,7 @@ import ( "os" apiv1alpha1 "github.com/red-hat-storage/ocs-client-operator/api/v1alpha1" - "github.com/red-hat-storage/ocs-client-operator/controllers" + "github.com/red-hat-storage/ocs-client-operator/internal/controller" "github.com/red-hat-storage/ocs-client-operator/pkg/templates" "github.com/red-hat-storage/ocs-client-operator/pkg/utils" admwebhook "github.com/red-hat-storage/ocs-client-operator/pkg/webhook" @@ -155,7 +155,7 @@ func main() { }}, ) - if err = (&controllers.StorageClientReconciler{ + if err = (&controller.StorageClientReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), OperatorNamespace: utils.GetOperatorNamespace(), @@ -164,7 +164,7 @@ func main() { os.Exit(1) } - if err = (&controllers.StorageClaimReconciler{ + if err = (&controller.StorageClaimReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), OperatorNamespace: utils.GetOperatorNamespace(), @@ -182,7 +182,7 @@ func main() { os.Exit(1) } - if err = (&controllers.OperatorConfigMapReconciler{ + if err = (&controller.OperatorConfigMapReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), OperatorNamespace: utils.GetOperatorNamespace(), diff --git a/hack/go-build.sh b/hack/go-build.sh index d297064a..f9488ab6 100755 --- a/hack/go-build.sh +++ b/hack/go-build.sh @@ -7,5 +7,5 @@ export GO111MODULE=${GO111MODULE:-on} set -x -go build -a -o ${GOBIN:-bin}/manager main.go +go build -a -o ${GOBIN:-bin}/manager cmd/main.go go build -a -o ${GOBIN:-bin}/status-reporter ./service/status-report/main.go diff --git a/controllers/generate.go b/internal/controller/generate.go similarity index 96% rename from controllers/generate.go rename to internal/controller/generate.go index 3284e6b4..2bd9eca7 100644 --- a/controllers/generate.go +++ b/internal/controller/generate.go @@ -14,4 +14,4 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controllers +package controller diff --git a/controllers/operatorconfigmap_controller.go b/internal/controller/operatorconfigmap_controller.go similarity index 99% rename from controllers/operatorconfigmap_controller.go rename to internal/controller/operatorconfigmap_controller.go index 9b02cfd0..528f8f8d 100644 --- a/controllers/operatorconfigmap_controller.go +++ b/internal/controller/operatorconfigmap_controller.go @@ -11,7 +11,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controllers +package controller import ( "bytes" diff --git a/controllers/pvc-rules.yaml b/internal/controller/pvc-rules.yaml similarity index 100% rename from controllers/pvc-rules.yaml rename to internal/controller/pvc-rules.yaml diff --git a/controllers/sliceutils.go b/internal/controller/sliceutils.go similarity index 98% rename from controllers/sliceutils.go rename to internal/controller/sliceutils.go index 69a318f0..e2787fa6 100644 --- a/controllers/sliceutils.go +++ b/internal/controller/sliceutils.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controllers +package controller //nolint:deadcode,unused func contains(slice []string, s string) bool { diff --git a/controllers/sliceutils_test.go b/internal/controller/sliceutils_test.go similarity index 99% rename from controllers/sliceutils_test.go rename to internal/controller/sliceutils_test.go index 4e2f35c6..fc847d4e 100644 --- a/controllers/sliceutils_test.go +++ b/internal/controller/sliceutils_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controllers +package controller import ( "testing" diff --git a/controllers/storageclaim_controller.go b/internal/controller/storageclaim_controller.go similarity index 99% rename from controllers/storageclaim_controller.go rename to internal/controller/storageclaim_controller.go index c5dfc20a..38c1d9d5 100644 --- a/controllers/storageclaim_controller.go +++ b/internal/controller/storageclaim_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controllers +package controller import ( "context" diff --git a/controllers/storageclient_controller.go b/internal/controller/storageclient_controller.go similarity index 99% rename from controllers/storageclient_controller.go rename to internal/controller/storageclient_controller.go index f06b171b..221bd4da 100644 --- a/controllers/storageclient_controller.go +++ b/internal/controller/storageclient_controller.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controllers +package controller import ( "context" diff --git a/controllers/suite_test.go b/internal/controller/suite_test.go similarity index 95% rename from controllers/suite_test.go rename to internal/controller/suite_test.go index 91347311..9932193b 100644 --- a/controllers/suite_test.go +++ b/internal/controller/suite_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package controllers +package controller import ( "path/filepath" @@ -49,7 +49,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: false, }