Files
open-cluster-management/Makefile
Qing Hao c516beffa6
Some checks failed
Post / images (amd64, addon-manager) (push) Failing after 46s
Post / images (amd64, placement) (push) Failing after 41s
Post / images (amd64, registration-operator) (push) Failing after 39s
Post / images (amd64, work) (push) Failing after 42s
Post / images (arm64, addon-manager) (push) Failing after 39s
Post / images (arm64, placement) (push) Failing after 39s
Post / images (arm64, registration) (push) Failing after 40s
Post / images (arm64, registration-operator) (push) Failing after 42s
Post / images (arm64, work) (push) Failing after 39s
Post / images (amd64, registration) (push) Failing after 7m46s
Post / image manifest (addon-manager) (push) Has been skipped
Post / image manifest (placement) (push) Has been skipped
Post / image manifest (registration) (push) Has been skipped
Post / image manifest (registration-operator) (push) Has been skipped
Post / image manifest (work) (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped
Post / coverage (push) Failing after 14m33s
Scorecard supply-chain security / Scorecard analysis (push) Failing after 1m25s
Close stale issues and PRs / stale (push) Successful in 46s
Add addon conversion webhook for v1alpha1/v1beta1 API migration (#1289)
* Add addon conversion webhook for v1alpha1/v1beta1 API migration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Qing Hao <qhao@redhat.com>

* Fix GroupVersion compatibility issues after API dependency update

This commit fixes compilation and test errors introduced by updating
the API dependency to use native conversion functions from PR #411.

Changes include:

1. Fix GroupVersion type mismatches across the codebase:
   - Updated OwnerReference creation to use schema.GroupVersion
   - Fixed webhook scheme registration to use proper GroupVersion type
   - Applied fixes to addon, placement, migration, work, and registration controllers

2. Enhance addon conversion webhook:
   - Use native API conversion functions from addon/v1beta1/conversion.go
   - Fix InstallNamespace annotation key to match expected format
   - Add custom logic to populate deprecated ConfigReferent field in ConfigReferences
   - Properly preserve annotations during v1alpha1 <-> v1beta1 conversion

3. Remove duplicate conversion code:
   - Deleted pkg/addon/webhook/conversion/ directory (~500 lines)
   - Now using native conversion functions from the API repository

4. Patch vendored addon-framework:
   - Fixed GroupVersion errors in agentdeploy utils

All unit tests pass successfully (97 packages, 0 failures).

Signed-off-by: Qing Hao <qhao@redhat.com>

---------

Signed-off-by: Qing Hao <qhao@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-24 08:26:35 +00:00

144 lines
5.0 KiB
Makefile

SHELL :=/bin/bash
all: build
.PHONY: all
# Include the library makefile
include $(addprefix ./vendor/github.com/openshift/build-machinery-go/make/, \
golang.mk \
targets/openshift/deps.mk \
targets/openshift/images.mk \
targets/openshift/yaml-patch.mk\
lib/tmp.mk\
)
# Include the integration/e2e setup makefile.
include ./test/integration-test.mk
include ./test/e2e-test.mk
include ./test/olm-test.mk
OPERATOR_SDK?=$(PERMANENT_TMP_GOPATH)/bin/operator-sdk
OPERATOR_SDK_VERSION?=v1.32.0
operatorsdk_gen_dir:=$(dir $(OPERATOR_SDK))
HELM?=$(PERMANENT_TMP_GOPATH)/bin/helm
HELM_VERSION?=v3.14.0
helm_gen_dir:=$(dir $(HELM))
GOLANGCI_LINT?=$(PERMANENT_TMP_GOPATH)/bin/golangci-lint
GOLANGCI_LINT_VERSION?=v2.4.0
golangci_lint_gen_dir:=$(dir $(GOLANGCI_LINT))
# RELEASED_CSV_VERSION indicates the last released operator version.
# can find the released operator version from
# https://github.com/k8s-operatorhub/community-operators/tree/main/operators/cluster-manager
# https://github.com/k8s-operatorhub/community-operators/tree/main/operators/klusterlet
RELEASED_CSV_VERSION?=0.14.0
export RELEASED_CSV_VERSION
# CSV_VERSION is used to generate latest CSV manifests
CSV_VERSION?=9.9.9
export CSV_VERSION
OPERATOR_SDK_ARCHOS:=linux_amd64
HELM_ARCHOS:=linux-amd64
ifeq ($(GOHOSTOS),darwin)
ifeq ($(GOHOSTARCH),amd64)
OPERATOR_SDK_ARCHOS:=darwin_amd64
HELM_ARCHOS:=darwin-amd64
endif
ifeq ($(GOHOSTARCH),arm64)
OPERATOR_SDK_ARCHOS:=darwin_arm64
HELM_ARCHOS:=darwin-arm64
endif
endif
# Add packages to do unit test
GO_TEST_PACKAGES :=./pkg/...
GO_TEST_FLAGS := -race -coverprofile=coverage.out
IMAGE_REGISTRY?=quay.io/open-cluster-management
IMAGE_TAG?=latest
OPERATOR_IMAGE_NAME ?= $(IMAGE_REGISTRY)/registration-operator:$(IMAGE_TAG)
# WORK_IMAGE can be set in the env to override calculated value
WORK_IMAGE ?= $(IMAGE_REGISTRY)/work:$(IMAGE_TAG)
# REGISTRATION_IMAGE can be set in the env to override calculated value
REGISTRATION_IMAGE ?= $(IMAGE_REGISTRY)/registration:$(IMAGE_TAG)
# PLACEMENT_IMAGE can be set in the env to override calculated value
PLACEMENT_IMAGE ?= $(IMAGE_REGISTRY)/placement:$(IMAGE_TAG)
# ADDON_MANAGER_IMAGE can be set in the env to override calculated value
ADDON_MANAGER_IMAGE ?= $(IMAGE_REGISTRY)/addon-manager:$(IMAGE_TAG)
$(call build-image,registration,$(REGISTRATION_IMAGE),./build/Dockerfile.registration,.)
$(call build-image,work,$(WORK_IMAGE),./build/Dockerfile.work,.)
$(call build-image,placement,$(PLACEMENT_IMAGE),./build/Dockerfile.placement,.)
$(call build-image,registration-operator,$(OPERATOR_IMAGE_NAME),./build/Dockerfile.registration-operator,.)
$(call build-image,addon-manager,$(ADDON_MANAGER_IMAGE),./build/Dockerfile.addon,.)
copy-crd: ensure-yaml-patch
bash -x hack/copy-crds.sh $(YAML_PATCH)
update: copy-crd update-csv
test-unit: ensure-kubebuilder-tools
update-csv: ensure-operator-sdk ensure-helm
bash -x hack/update-csv.sh
verify-crds: ensure-yaml-patch
bash -x hack/verify-crds.sh $(YAML_PATCH)
verify-gocilint: ensure-golangci-lint
$(GOLANGCI_LINT) run --timeout=5m --modules-download-mode vendor ./...
install-golang-gci:
go install github.com/daixiang0/gci@v0.13.7
fmt-imports: install-golang-gci
gci write --skip-generated -s standard -s default -s "prefix(open-cluster-management.io)" -s localmodule cmd pkg test dependencymagnet
verify-fmt-imports: install-golang-gci
@output=$$(gci diff --skip-generated -s standard -s default -s "prefix(open-cluster-management.io)" -s localmodule cmd pkg test dependencymagnet); \
if [ -n "$$output" ]; then \
echo "Diff output is not empty: $$output"; \
echo "Please run 'make fmt-imports' to format the golang files imports automatically."; \
exit 1; \
else \
echo "Diff output is empty"; \
fi
verify: verify-fmt-imports verify-crds verify-gocilint
ensure-operator-sdk:
ifeq "" "$(wildcard $(OPERATOR_SDK))"
$(info Installing operator-sdk into '$(OPERATOR_SDK)')
mkdir -p '$(operatorsdk_gen_dir)'
curl -s -f -L https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk_$(OPERATOR_SDK_ARCHOS) -o '$(OPERATOR_SDK)'
chmod +x '$(OPERATOR_SDK)';
else
$(info Using existing operator-sdk from "$(OPERATOR_SDK)")
endif
ensure-helm:
ifeq "" "$(wildcard $(HELM))"
$(info Installing helm into '$(HELM)')
mkdir -p '$(helm_gen_dir)'
curl -s -f -L https://get.helm.sh/helm-$(HELM_VERSION)-$(HELM_ARCHOS).tar.gz -o '$(helm_gen_dir)$(HELM_VERSION)-$(HELM_ARCHOS).tar.gz'
tar -zvxf '$(helm_gen_dir)/$(HELM_VERSION)-$(HELM_ARCHOS).tar.gz' -C $(helm_gen_dir)
mv $(helm_gen_dir)/$(HELM_ARCHOS)/helm $(HELM)
rm -rf $(helm_gen_dir)/$(HELM_ARCHOS)
chmod +x '$(HELM)';
else
$(info Using existing helm from "$(HELM)")
endif
ensure-golangci-lint:
ifeq "" "$(wildcard $(GOLANGCI_LINT))"
$(info Installing golangci-lint into '$(GOLANGCI_LINT)')
mkdir -p '$(golangci_lint_gen_dir)'
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b '$(golangci_lint_gen_dir)' $(GOLANGCI_LINT_VERSION)
else
$(info Using existing golangci-lint from "$(GOLANGCI_LINT)")
endif