Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to project layout v4 #174

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ COPY go.sum go.sum
RUN go mod download

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

# 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 kaoto main.go
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o kaoto 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
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ vet: ## Run go vet against code.

.PHONY: test
test: manifests generate fmt vet ## Run tests.
go test ./pkg/... ./controllers/...
go test ./pkg/... ./internal/...

.PHONY: test/e2e
test/e2e: manifests generate fmt vet ## Run e2e tests.
Expand All @@ -126,11 +126,11 @@ test/e2e: manifests generate fmt vet ## Run e2e tests.

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
go build -ldflags="$(GOLDFLAGS)" -o bin/kaoto main.go
go build -ldflags="$(GOLDFLAGS)" -o bin/kaoto cmd/main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run -ldflags="$(GOLDFLAGS)" main.go run --leader-election=false --zap-devel
go run -ldflags="$(GOLDFLAGS)" cmd/main.go run --leader-election=false --zap-devel


.PHONY: run/local
Expand Down Expand Up @@ -233,8 +233,8 @@ YQ ?= $(LOCALBIN)/yq

## Tool Versions
KUSTOMIZE_VERSION ?= v5.3.0
CONTROLLER_TOOLS_VERSION ?= v0.13.0
CODEGEN_VERSION ?= v0.29.0
CONTROLLER_TOOLS_VERSION ?= v0.14.0
CODEGEN_VERSION ?= v0.29.1
GOLANG_LINT_VERSION ?= v1.55.2
OPERATOR_SDK_VERSION ?= v1.33.0

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: kaoto.io
layout:
- go.kubebuilder.io/v3
- go.kubebuilder.io/v4
multigroup: true
plugins:
manifests.sdk.operatorframework.io/v2: {}
Expand Down
4 changes: 2 additions & 2 deletions bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=kaoto-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.30.0
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.33.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v4

# Labels for testing.
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
Expand Down
File renamed without changes.
78 changes: 42 additions & 36 deletions config/crd/bases/designer.kaoto.io_kaotoes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
controller-gen.kubebuilder.io/version: v0.14.0
name: kaotoes.designer.kaoto.io
spec:
group: designer.kaoto.io
Expand Down Expand Up @@ -34,14 +34,19 @@ spec:
description: Kaoto is the Schema for the kaotoes API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
Expand All @@ -64,42 +69,42 @@ spec:
conditions:
items:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
\n type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
state of this API Resource.\n---\nThis struct is intended for
direct use as an array at the field path .status.conditions. For
example,\n\n\n\ttype FooStatus struct{\n\t // Represents the
observations of a foo's current state.\n\t // Known .status.conditions.type
are: \"Available\", \"Progressing\", and \"Degraded\"\n\t //
+patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t
\ // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t
\ // other fields\n\t}"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another. This should be when
the underlying condition changed. If that is not known, then
using the time when the API field changed is acceptable.
description: |-
lastTransitionTime is the last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition. This may be an empty string.
description: |-
message is a human readable message indicating details about the transition.
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon. For instance, if .metadata.generation
is currently 12, but the .status.conditions[x].observedGeneration
is 9, the condition is out of date with respect to the current
state of the instance.
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition. Producers
of specific condition types may define expected values and
meanings for this field, and whether the values are considered
a guaranteed API. The value should be a CamelCase string.
description: |-
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
maxLength: 1024
minLength: 1
Expand All @@ -113,11 +118,12 @@ spec:
- Unknown
type: string
type:
description: type of condition in CamelCase or in foo.example.com/CamelCase.
--- Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
description: |-
type of condition in CamelCase or in foo.example.com/CamelCase.
---
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be
useful (see .node.status.conditions), the ability to deconflict is important.
The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
Expand Down
2 changes: 1 addition & 1 deletion config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ kind: Kustomization
images:
- name: controller
newName: quay.io/kaotoio/kaoto-operator
newTag: 0.0.9
newTag: latest
1 change: 0 additions & 1 deletion config/manifests/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# used to generate the 'manifests/' directory in a bundle.
resources:
- bases/kaoto-operator.clusterserviceversion.yaml
- ../rbac/backend
- ../default
- ../samples
- ../scorecard
8 changes: 4 additions & 4 deletions hack/scripts/gen_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mkdir -p "${PROJECT_ROOT}/pkg/client/kaoto"
"${PROJECT_ROOT}"/bin/applyconfiguration-gen \
--go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \
--output-base="${TMP_DIR}/client" \
--input-dirs=github.com/kaotoIO/kaoto-operator/apis/designer/v1alpha1 \
--input-dirs=github.com/kaotoIO/kaoto-operator/api/designer/v1alpha1 \
--output-package=github.com/kaotoIO/kaoto-operator/pkg/client/kaoto/applyconfiguration

"${PROJECT_ROOT}"/bin/client-gen \
Expand All @@ -22,22 +22,22 @@ mkdir -p "${PROJECT_ROOT}/pkg/client/kaoto"
--plural-exceptions="Kaoto:Kaotoes" \
--input=designer/v1alpha1 \
--clientset-name "versioned" \
--input-base=github.com/kaotoIO/kaoto-operator/apis \
--input-base=github.com/kaotoIO/kaoto-operator/api \
--apply-configuration-package=github.com/kaotoIO/kaoto-operator/pkg/client/kaoto/applyconfiguration \
--output-package=github.com/kaotoIO/kaoto-operator/pkg/client/kaoto/clientset

"${PROJECT_ROOT}"/bin/lister-gen \
--go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \
--output-base="${TMP_DIR}/client" \
--plural-exceptions="Kaoto:Kaotoes" \
--input-dirs=github.com/kaotoIO/kaoto-operator/apis/designer/v1alpha1 \
--input-dirs=github.com/kaotoIO/kaoto-operator/api/designer/v1alpha1 \
--output-package=github.com/kaotoIO/kaoto-operator/pkg/client/kaoto/listers

"${PROJECT_ROOT}"/bin/informer-gen \
--go-header-file="${PROJECT_ROOT}/hack/boilerplate.go.txt" \
--output-base="${TMP_DIR}/client" \
--plural-exceptions="Kaoto:Kaotoes" \
--input-dirs=github.com/kaotoIO/kaoto-operator/apis/designer/v1alpha1 \
--input-dirs=github.com/kaotoIO/kaoto-operator/api/designer/v1alpha1 \
--versioned-clientset-package=github.com/kaotoIO/kaoto-operator/pkg/client/kaoto/clientset/versioned \
--listers-package=github.com/kaotoIO/kaoto-operator/pkg/client/kaoto/listers \
--output-package=github.com/kaotoIO/kaoto-operator/pkg/client/kaoto/informers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"

kaotoApi "github.com/kaotoIO/kaoto-operator/apis/designer/v1alpha1"
kaotoApi "github.com/kaotoIO/kaoto-operator/api/designer/v1alpha1"
"github.com/kaotoIO/kaoto-operator/pkg/defaults"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"k8s.io/apimachinery/pkg/api/resource"

kaotoiov1alpha1 "github.com/kaotoIO/kaoto-operator/apis/designer/v1alpha1"
kaotoiov1alpha1 "github.com/kaotoIO/kaoto-operator/api/designer/v1alpha1"
)

type ClusterType string
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/kaoto/applyconfiguration/utils.go

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

2 changes: 1 addition & 1 deletion pkg/client/kaoto/clientset/versioned/fake/register.go

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

2 changes: 1 addition & 1 deletion pkg/client/kaoto/clientset/versioned/scheme/register.go

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.

2 changes: 1 addition & 1 deletion pkg/client/kaoto/informers/externalversions/generic.go

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

2 changes: 1 addition & 1 deletion pkg/client/kaoto/listers/designer/v1alpha1/kaoto.go

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

8 changes: 4 additions & 4 deletions pkg/cmd/run/run.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package run

import (
"github.com/kaotoIO/kaoto-operator/internal/controller/designer"
"github.com/kaotoIO/kaoto-operator/pkg/controller"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand All @@ -12,8 +13,7 @@ import (
rtclient "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"

designerApi "github.com/kaotoIO/kaoto-operator/apis/designer/v1alpha1"
designerCtl "github.com/kaotoIO/kaoto-operator/controllers/designer"
designerApi "github.com/kaotoIO/kaoto-operator/api/designer/v1alpha1"
routev1 "github.com/openshift/api/route/v1"

utilruntime "k8s.io/apimachinery/pkg/util/runtime"
Expand Down Expand Up @@ -41,7 +41,7 @@ func NewRunCmd() *cobra.Command {
Short: "run",
RunE: func(cmd *cobra.Command, args []string) error {
return controller.Start(options, func(manager manager.Manager, opts controller.Options) error {
selector, err := designerCtl.AppSelector()
selector, err := designer.AppSelector()
if err != nil {
return errors.Wrap(err, "unable to compute cache's watch selector")
}
Expand All @@ -55,7 +55,7 @@ func NewRunCmd() *cobra.Command {
&corev1.ServiceAccount{}: {Label: selector},
}

rec, err := designerCtl.NewKaotoReconciler(manager)
rec, err := designer.NewKaotoReconciler(manager)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/designer_deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/rs/xid"

kaoto "github.com/kaotoIO/kaoto-operator/apis/designer/v1alpha1"
kaoto "github.com/kaotoIO/kaoto-operator/api/designer/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

. "github.com/kaotoIO/kaoto-operator/test/support"
Expand Down
Loading
Loading