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

⚠️ Introduce v1alpha2 API #190

Merged
merged 3 commits into from
Aug 24, 2023
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
4 changes: 3 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ linters-settings:
- "disableStutteringCheck"
stylecheck:
# https://staticcheck.io/docs/options#checks
checks: ["all", "-ST1000"]
checks: ["all", "-ST1000", "-ST1003", "-ST1016"]
dot-import-whitelist:
- "github.com/onsi/gomega"
importas:
Expand Down Expand Up @@ -134,6 +134,8 @@ linters-settings:
alias: configclient
# CAPI Operator
- pkg: sigs.k8s.io/cluster-api-operator/api/v1alpha1
alias: operatorv1alpha1
- pkg: sigs.k8s.io/cluster-api-operator/api/v1alpha2
Fedosin marked this conversation as resolved.
Show resolved Hide resolved
alias: operatorv1
- pkg: sigs.k8s.io/cluster-api-operator/internal/controller
alias: providercontroller
Expand Down
42 changes: 42 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ KPROMO_VER := v3.5.1
KPROMO_BIN := kpromo
KPROMO := $(TOOLS_BIN_DIR)/$(KPROMO_BIN)-$(KPROMO_VER)

CONVERSION_GEN_VER := v0.27.3
CONVERSION_GEN_BIN := conversion-gen
CONVERSION_GEN := $(TOOLS_BIN_DIR)/$(CONVERSION_GEN_BIN)-$(CONVERSION_GEN_VER)

CONVERSION_VERIFIER_VER := v1.5.0
CONVERSION_VERIFIER_BIN := conversion-verifier
CONVERSION_VERIFIER := $(TOOLS_BIN_DIR)/$(CONVERSION_VERIFIER_BIN)-$(CONVERSION_VERIFIER_VER)

# It is set by Prow GIT_TAG, a git-based tag of the form vYYYYMMDD-hash, e.g., v20210120-v0.3.10-308-gc61521971
TAG ?= dev
ARCH ?= amd64
Expand Down Expand Up @@ -153,6 +161,14 @@ RELEASE_DIR := $(ROOT)/out
CHART_DIR := $(RELEASE_DIR)/charts/cluster-api-operator
CHART_PACKAGE_DIR := $(RELEASE_DIR)/package

# Set --output-base for conversion-gen if we are not within GOPATH
ROOT_DIR_RELATIVE := .
ifneq ($(abspath $(ROOT_DIR_RELATIVE)),$(shell go env GOPATH)/src/sigs.k8s.io/cluster-api-operator)
CONVERSION_GEN_OUTPUT_BASE := --output-base=$(ROOT_DIR_RELATIVE)
else
export GOPATH := $(shell go env GOPATH)
endif

all: generate test operator

help: ## Display this help
Expand All @@ -173,6 +189,8 @@ gotestsum: $(GOTESTSUM) ## Build a local copy of gotestsum.
helm: $(HELM) ## Build a local copy of helm.
yq: $(YQ) ## Build a local copy of yq.
kpromo: $(KPROMO) ## Build a local copy of kpromo.
conversion-gen: $(CONVERSION_GEN) ## Build a local copy of conversion-gen.
conversion-verifier: $(CONVERSION_VERIFIER) ## Build a local copy of conversion-verifier.

$(KUSTOMIZE): ## Build kustomize from tools folder.
CGO_ENABLED=0 GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/kustomize/kustomize/v5 $(KUSTOMIZE_BIN) $(KUSTOMIZE_VER)
Expand Down Expand Up @@ -213,6 +231,12 @@ $(YQ):
$(KPROMO):
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) sigs.k8s.io/promo-tools/v3/cmd/kpromo $(KPROMO_BIN) ${KPROMO_VER}

$(CONVERSION_GEN):
GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) k8s.io/code-generator/cmd/conversion-gen $(CONVERSION_GEN_BIN) ${CONVERSION_GEN_VER}

$(CONVERSION_VERIFIER):
cd hack/tools/; GOBIN=$(TOOLS_BIN_DIR) go build -tags=tools -o $@ sigs.k8s.io/cluster-api/hack/tools/conversion-verifier

.PHONY: cert-mananger
cert-manager: # Install cert-manager on the cluster. This is used for development purposes only.
$(ROOT)/hack/cert-manager.sh
Expand Down Expand Up @@ -295,6 +319,7 @@ verify-gen: generate
generate: $(CONTROLLER_GEN) $(HELM) release-chart ## Generate code
$(MAKE) generate-manifests
$(MAKE) generate-go
$(MAKE) generate-go-conversions
$(HELM) template capi-operator $(CHART_PACKAGE_DIR)/$(PACKAGE_NAME)-$(HELM_CHART_TAG).tgz > test/e2e/resources/full-chart-install.yaml

.PHONY: generate-go
Expand All @@ -316,6 +341,15 @@ generate-manifests: $(CONTROLLER_GEN) ## Generate manifests for the operator e.g
output:webhook:dir=./config/webhook \
webhook

.PHONY: generate-go-conversions
generate-go-conversions: $(CONVERSION_GEN) ## Generate conversions go code
$(MAKE) clean-generated-conversions SRC_DIRS="./api/v1alpha1"
$(CONVERSION_GEN) \
--input-dirs=./api/v1alpha1 \
--build-tag=ignore_autogenerated_core \
--output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \
--go-header-file=$(ROOT)/hack/boilerplate.go.txt

.PHONY: modules
modules: ## Runs go mod to ensure modules are up to date.
go mod tidy
Expand Down Expand Up @@ -472,6 +506,14 @@ promote-images: $(KPROMO)
## Cleanup / Verification
## --------------------------------------

.PHONY: verify-conversions
verify-conversions: $(CONVERSION_VERIFIER) ## Verifies expected API conversion are in place
$(CONVERSION_VERIFIER)

.PHONY: clean-generated-conversions
clean-generated-conversions: ## Remove files generated by conversion-gen from the mentioned dirs
(IFS=','; for i in $(SRC_DIRS); do find $$i -type f -name 'zz_generated.conversion*' -exec rm -f {} \;; done)

.PHONY: clean
clean: ## Remove all generated files
$(MAKE) clean-bin
Expand Down
33 changes: 33 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,37 @@ resources:
kind: InfrastructureProvider
path: sigs.k8s.io/cluster-api-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: cluster.x-k8s.io
group: operator
kind: CoreProvider
path: sigs.k8s.io/cluster-api-operator/api/v1alpha2
version: v1alpha2
- api:
crdVersion: v1
namespaced: true
domain: cluster.x-k8s.io
group: operator
kind: BootstrapProvider
path: sigs.k8s.io/cluster-api-operator/api/v1alpha2
version: v1alpha2
- api:
crdVersion: v1
namespaced: true
domain: cluster.x-k8s.io
group: operator
kind: ControlPlaneProvider
path: sigs.k8s.io/cluster-api-operator/api/v1alpha2
version: v1alpha2
- api:
crdVersion: v1
namespaced: true
domain: cluster.x-k8s.io
group: operator
kind: InfrastructureProvider
path: sigs.k8s.io/cluster-api-operator/api/v1alpha2
version: v1alpha2
version: "3"
19 changes: 19 additions & 0 deletions api/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2023 The Kubernetes Authors.

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.
*/

// Package v1alpha1 contains the v1alpha1 API implementation.
// +k8s:conversion-gen=sigs.k8s.io/cluster-api-operator/api/v1alpha2
package v1alpha1
2 changes: 2 additions & 0 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ var (

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme

localSchemeBuilder = SchemeBuilder.SchemeBuilder
)
Loading
Loading