Skip to content

Commit

Permalink
Update the project for kubebuilder go/v4 layout
Browse files Browse the repository at this point in the history
Change the layout to follow the Standard Go Project Layout, as described
in https://book.kubebuilder.io/migration/v3vsv4.  This allows newer releases
of kubebuilder to be used with this repo.

Signed-off-by: Dean Roehrich <[email protected]>
  • Loading branch information
roehrich-hpe committed Oct 20, 2023
1 parent d15ab71 commit 4c6dd4c
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 19 deletions.
24 changes: 21 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
#
# Copyright 2021-2023 Hewlett Packard Enterprise Development LP
# Other additional copyright holders may be indicated within.
#
# The entirety of this work is licensed under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
#
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build the manager binary
FROM golang:1.19 as builder

Expand All @@ -6,13 +24,13 @@ WORKDIR /workspace
COPY go.mod go.mod
COPY go.sum go.sum
COPY vendor/ vendor/
COPY main.go main.go
COPY cmd/ cmd/
COPY api/ api/
COPY controllers/ controllers/
COPY internal/ internal/
COPY github/cluster-api/util/conversion/ github/cluster-api/util/conversion/

# 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

FROM builder as testing
WORKDIR /workspace
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ vet: ## Run go vet against code.
go vet ./...

# Explicitly specifying directories to test here to avoid running tests in .dws-operator for the time being.
# ./controllers/...
# ./internal/...
# ./api/...
# Below is a list of ginkgo test flags that may be used to generate different test patterns.
# Specifying 'count=1' is the idiomatic way to disable test caching
Expand Down Expand Up @@ -168,17 +168,17 @@ container-unit-test: .version ## Build docker image with the manager and execute
${DOCKER} build -f Dockerfile --label $(IMAGE_TAG_BASE)-$@:$(VERSION)-$@ -t $(IMAGE_TAG_BASE)-$@:$(VERSION) --target testing .
${DOCKER} run --rm -t --name $@-lustre-fs-operator $(IMAGE_TAG_BASE)-$@:$(VERSION)

TESTDIR ?= ./controllers/... ./api/...
TESTDIR ?= ./internal/... ./api/...
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --bin-dir $(LOCALBIN))" go test $(TESTDIR) -coverprofile cover.out -args -ginkgo.v

##@ Build

build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go
go build -o bin/manager cmd/main.go

run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
go run cmd/main.go

docker-build: VERSION ?= $(shell cat .version)
docker-build: .version ## Build docker image with the manager.
Expand Down
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# More info: https://book.kubebuilder.io/reference/project-config.html
domain: cray.hpe.com
layout:
- go.kubebuilder.io/v3
- go.kubebuilder.io/v4
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
Expand Down
4 changes: 2 additions & 2 deletions main.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (

lusv1alpha1 "github.com/NearNodeFlash/lustre-fs-operator/api/v1alpha1"
lusv1beta1 "github.com/NearNodeFlash/lustre-fs-operator/api/v1beta1"
"github.com/NearNodeFlash/lustre-fs-operator/controllers"
"github.com/NearNodeFlash/lustre-fs-operator/internal/controller"
//+kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -83,7 +83,7 @@ func main() {
os.Exit(1)
}

if err = (&controllers.LustreFileSystemReconciler{
if err = (&controller.LustreFileSystemReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/NearNodeFlash/lustre-fs-operator

go 1.19

replace github.com/DataWorkflowServices/dws => ../dws-a.git

require (
github.com/DataWorkflowServices/dws v0.0.1-0.20231010162938-b6d65b00cad6
github.com/HewlettPackard/lustre-csi-driver v0.0.0-20220623192103-4ce53adacc95
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataWorkflowServices/dws v0.0.1-0.20231010162938-b6d65b00cad6 h1:+j1ex3+PaJApQzCR7reMIJULPL+a7uOHYRJdSQVRWhA=
github.com/DataWorkflowServices/dws v0.0.1-0.20231010162938-b6d65b00cad6/go.mod h1:grHFCu0CoUK8exzS57r6cdf4qHpG1Pv5nl0n7evpaUM=
github.com/HewlettPackard/lustre-csi-driver v0.0.0-20220623192103-4ce53adacc95 h1:5neutLfJ4zWKHLeYw+a1EfW2veMC3sI50RNvgfeax9Q=
github.com/HewlettPackard/lustre-csi-driver v0.0.0-20220623192103-4ce53adacc95/go.mod h1:Wwr96QYACIixBjBXpST9yMS81WxMu/tF/zc/5OW21Dk=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

package controllers
package controller

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

package controllers
package controller

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

package controllers
package controller

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* limitations under the License.
*/

package controllers
package controller

import (
"context"
Expand Down Expand Up @@ -79,9 +79,9 @@ var _ = BeforeSuite(func() {

testEnv = &envtest.Environment{
WebhookInstallOptions: envtest.WebhookInstallOptions{Paths: []string{
filepath.Join("..", "config", "webhook"),
filepath.Join("..", "..", "config", "webhook"),
}},
CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
ErrorIfCRDPathMissing: true,
AttachControlPlaneOutput: true,

Expand Down
3 changes: 2 additions & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# github.com/DataWorkflowServices/dws v0.0.1-0.20231010162938-b6d65b00cad6
# github.com/DataWorkflowServices/dws v0.0.1-0.20231010162938-b6d65b00cad6 => ../dws-a.git
## explicit; go 1.19
github.com/DataWorkflowServices/dws/utils/updater
# github.com/HewlettPackard/lustre-csi-driver v0.0.0-20220623192103-4ce53adacc95
Expand Down Expand Up @@ -719,3 +719,4 @@ sigs.k8s.io/structured-merge-diff/v4/value
# sigs.k8s.io/yaml v1.3.0
## explicit; go 1.12
sigs.k8s.io/yaml
# github.com/DataWorkflowServices/dws => ../dws-a.git

0 comments on commit 4c6dd4c

Please sign in to comment.