Skip to content

Commit 0e9ae67

Browse files
joelanfordclaude
andauthored
✨ Generate and use ApplyConfiguration types for Server-Side Apply (#2515)
* Generate apply configuration types for OLM API types Use controller-gen's applyconfiguration generator to produce typed apply configuration structs for Server-Side Apply. This adds generated types for ClusterCatalog, ClusterExtension, ClusterExtensionRevision, and all their sub-types in applyconfigurations/. Changes: - Add applyconfiguration generator to the Makefile generate target - Add +kubebuilder:ac:generate=true and +kubebuilder:ac:output:package markers to the API package - Add SchemeGroupVersion alias required by the generated code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Use ClusterExtensionRevision ApplyConfiguration types in Boxcutter Migrate Boxcutter from deprecated client.Patch(ctx, rev, client.Apply) to typed client.Apply(ctx, rev) using the generated ClusterExtensionRevisionApplyConfiguration types. - ClusterExtensionRevisionGenerator interface now returns AC types - GenerateRevision/GenerateRevisionFromHelmRelease build AC objects directly via builder pattern instead of API struct literals - Rename createOrUpdate to apply; uses client.Apply instead of deprecated client.Patch with client.Apply option - Owner references set via metav1ac.OwnerReference() builder instead of controllerutil.SetControllerReference - BoxcutterStorageMigrator.Migrate uses client.Apply; interface replaces Create with Apply and adds FieldOwner field - PhaseSort and helpers operate on AC types natively - All tests updated to use AC builder pattern and mock Apply Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3e293ad commit 0e9ae67

39 files changed

Lines changed: 3189 additions & 499 deletions

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,10 @@ manifests: update-crds $(MANIFESTS) $(HELM) #EXHELP Generate OLMv1 manifests
197197
$(HELM) template olmv1 helm/olmv1 --set "options.openshift.enabled=true" > /dev/null
198198

199199
.PHONY: generate
200-
generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
201-
@find api cmd hack internal -name "zz_generated.deepcopy.go" -not -path "*/vendor/*" -delete # Need to delete the files for them to be generated properly
200+
generate: $(CONTROLLER_GEN) #EXHELP Generate code containing DeepCopy, DeepCopyInto, DeepCopyObject, and ApplyConfiguration type implementations.
201+
# Need to delete the files for them to be generated properly
202+
@find api cmd hack internal -name "zz_generated.deepcopy.go" -not -path "*/vendor/*" -delete && rm -rf applyconfigurations
203+
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) applyconfiguration:headerFile="hack/boilerplate.go.txt" paths="./api/..."
202204
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) object:headerFile="hack/boilerplate.go.txt" paths="./..."
203205

204206
.PHONY: verify

api/v1/clustercatalog_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const (
4444
ReasonUserSpecifiedUnavailable = "UserSpecifiedUnavailable"
4545
)
4646

47+
// +genclient
48+
// +genclient:nonNamespaced
4749
//+kubebuilder:object:root=true
4850
//+kubebuilder:resource:scope=Cluster
4951
//+kubebuilder:subresource:status

api/v1/clusterextension_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ type ClusterExtensionInstallStatus struct {
537537
Bundle BundleMetadata `json:"bundle"`
538538
}
539539

540+
// +genclient
541+
// +genclient:nonNamespaced
540542
// +kubebuilder:object:root=true
541543
// +kubebuilder:resource:scope=Cluster
542544
// +kubebuilder:subresource:status

api/v1/clusterextensionrevision_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ type ClusterExtensionRevisionStatus struct {
252252
Conditions []metav1.Condition `json:"conditions,omitempty"`
253253
}
254254

255+
// +genclient
256+
// +genclient:nonNamespaced
255257
// +kubebuilder:object:root=true
256258
// +kubebuilder:resource:scope=Cluster
257259
// +kubebuilder:subresource:status

api/v1/groupversion_info.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
// Package v1 contains API Schema definitions for the olm v1 API group
1818
// +kubebuilder:object:generate=true
1919
// +groupName=olm.operatorframework.io
20+
// +kubebuilder:ac:generate=true
21+
// +kubebuilder:ac:output:package=../../applyconfigurations
2022
package v1
2123

2224
import (
@@ -28,6 +30,10 @@ var (
2830
// GroupVersion is group version used to register these objects
2931
GroupVersion = schema.GroupVersion{Group: "olm.operatorframework.io", Version: "v1"}
3032

33+
// SchemeGroupVersion is an alias for GroupVersion, required by the
34+
// generated apply configuration code.
35+
SchemeGroupVersion = GroupVersion
36+
3137
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
3238
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
3339

applyconfigurations/api/v1/bundlemetadata.go

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfigurations/api/v1/catalogfilter.go

Lines changed: 232 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)