Skip to content

Commit

Permalink
Update the project for kubebuilder go/v4 layout (#14)
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 authored Nov 1, 2023
1 parent 89ff4da commit 22613e5
Show file tree
Hide file tree
Showing 23 changed files with 32 additions and 34 deletions.
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ COPY vendor/ vendor/
COPY config/ config/

# Copy the go source
COPY main.go main.go
COPY controllers/ controllers/
COPY cmd/ cmd/
COPY internal/ internal/

# Build
# the GOARCH has not a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

FROM builder as testing
WORKDIR /workspace
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ test: manifests generate fmt vet envtest ## Run tests.

.PHONY: build
build: 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

.PHONY: container-unit-test
container-unit-test: VERSION ?= $(shell cat .version)
Expand Down Expand Up @@ -184,7 +184,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v5.1.1
CONTROLLER_TOOLS_VERSION ?= v0.12.0
CONTROLLER_TOOLS_VERSION ?= v0.13.0

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
Expand Down
8 changes: 4 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
domain: cray.hpe.com
layout:
- go.kubebuilder.io/v3
- go.kubebuilder.io/v4
projectName: dws-test-driver
repo: github.com/DataWorkflowServices/dws-test-driver
resources:
- controller: true
domain: cray.hpe.com
group: dws
domain: github.io
group: dataworkflowservices
kind: Workflow
version: v1alpha1
version: v1alpha2
version: "3"
2 changes: 1 addition & 1 deletion main.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/healthz"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"

"github.com/DataWorkflowServices/dws-test-driver/controllers"
controllers "github.com/DataWorkflowServices/dws-test-driver/internal/controller"
//+kubebuilder:scaffold:imports
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/DataWorkflowServices/dws-test-driver
go 1.19

require (
github.com/DataWorkflowServices/dws v0.0.1-0.20231010162938-b6d65b00cad6
github.com/DataWorkflowServices/dws v0.0.1-0.20231031201121-13a5a69a969e
github.com/ghodss/yaml v1.0.0
github.com/go-logr/logr v1.2.4
github.com/google/go-cmp v0.5.9
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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/DataWorkflowServices/dws v0.0.1-0.20231031201121-13a5a69a969e h1:QhDrVNQ6zyJcnP0+I147Ei19QAoOL5sDvkjNTkRbELA=
github.com/DataWorkflowServices/dws v0.0.1-0.20231031201121-13a5a69a969e/go.mod h1:grHFCu0CoUK8exzS57r6cdf4qHpG1Pv5nl0n7evpaUM=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package controller

import (
"context"
Expand Down Expand Up @@ -81,7 +81,7 @@ var _ = BeforeSuite(func() {
ctx, cancel = context.WithCancel(context.TODO())

webhookPaths := []string{
filepath.Join("..", "vendor", "github.com", "DataWorkflowServices", "dws", "config", "webhook"),
filepath.Join("..", "..", "vendor", "github.com", "DataWorkflowServices", "dws", "config", "webhook"),
}

By("bootstrapping test environment")
Expand All @@ -90,7 +90,7 @@ var _ = BeforeSuite(func() {
ErrorIfCRDPathMissing: true,
CRDDirectoryPaths: []string{
// filepath.Join("..", "config", "crd", "bases"),
filepath.Join("..", "vendor", "github.com", "DataWorkflowServices", "dws", "config", "crd", "bases"),
filepath.Join("..", "..", "vendor", "github.com", "DataWorkflowServices", "dws", "config", "crd", "bases"),
},
}

Expand Down Expand Up @@ -146,7 +146,7 @@ var _ = BeforeSuite(func() {
}()

// Load the NNF ruleset to enable the webhook to parse #DW directives
ruleset, err := loadTestDWDirectiveRuleset(filepath.Join("..", "config", "dws", "test-ruleset.yaml"))
ruleset, err := loadTestDWDirectiveRuleset(filepath.Join("..", "..", "config", "dws", "test-ruleset.yaml"))
Expect(err).ToNot(HaveOccurred())

ruleset.Namespace = "default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package controller

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package controllers
package controller

import (
"context"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# github.com/DataWorkflowServices/dws v0.0.1-0.20231010162938-b6d65b00cad6
# github.com/DataWorkflowServices/dws v0.0.1-0.20231031201121-13a5a69a969e
## explicit; go 1.19
github.com/DataWorkflowServices/dws/api/v1alpha2
github.com/DataWorkflowServices/dws/config/crd/bases
github.com/DataWorkflowServices/dws/config/webhook
github.com/DataWorkflowServices/dws/controllers
github.com/DataWorkflowServices/dws/controllers/metrics
github.com/DataWorkflowServices/dws/internal/controller/metrics
github.com/DataWorkflowServices/dws/utils/dwdparse
github.com/DataWorkflowServices/dws/utils/updater
# github.com/beorn7/perks v1.0.1
Expand Down

0 comments on commit 22613e5

Please sign in to comment.