From d5527b51930165e1c8cd995d338cc7897d500e2f Mon Sep 17 00:00:00 2001 From: Alvaro Aleman Date: Wed, 28 May 2025 15:47:00 -0400 Subject: [PATCH] Update applyconfiguration-gen so acs implement runtime.applyconfiguration --- .../generators/applyconfiguration.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/applyconfiguration.go b/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/applyconfiguration.go index 4deb1771875..85062bf7c4d 100644 --- a/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/applyconfiguration.go +++ b/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/generators/applyconfiguration.go @@ -115,6 +115,7 @@ func (g *applyConfigurationGenerator) GenerateType(c *generator.Context, t *type sw.Do(constructor, typeParams) } } + g.generateIsApplyConfiguration(typeParams.ApplyConfig.ApplyConfiguration, sw) g.generateWithFuncs(t, typeParams, sw, nil, &[]string{}) g.generateGetters(t, typeParams, sw, nil) return sw.Error() @@ -145,7 +146,8 @@ func blocklisted(t *types.Type, member types.Member) bool { func needsGetter(t *types.Type, member types.Member) bool { // Needed when applying an ApplyConfiguration - return objectMeta.Name == t.Name && member.Name == "Name" + return (objectMeta.Name == t.Name && (member.Name == "Name" || member.Name == "Namespace")) || + (typeMeta.Name == t.Name && (member.Name == "Kind" || member.Name == "APIVersion")) } func (g *applyConfigurationGenerator) generateGetters(t *types.Type, typeParams TypeParams, sw *generator.SnippetWriter, embed *memberParams) { @@ -270,6 +272,10 @@ func (g *applyConfigurationGenerator) generateStruct(sw *generator.SnippetWriter sw.Do("}\n", typeParams) } +func (g *applyConfigurationGenerator) generateIsApplyConfiguration(t *types.Type, sw *generator.SnippetWriter) { + sw.Do("func (b $.|public$) IsApplyConfiguration() {}\n", t) +} + func deref(t *types.Type) *types.Type { for t.Kind == types.Pointer { t = t.Elem