Skip to content

Commit a82538d

Browse files
authored
add support for reconcile-resources flag (#580)
Description of changes: aws-controllers-k8s/runtime#176 This PR adds template changes to support the reconcile-resources flag which was recently added to the ACK runtime. This flag allows users to specify which resource kinds should be reconciled by a controller, providing more granular control over controller behavior. When the flag is set, only the specified resource kinds will be reconciled by the controller. If unspecified, all resources will be reconciled (default behavior). By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 50d6e7a commit a82538d

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

pkg/generate/ack/release.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/aws-controllers-k8s/code-generator/pkg/generate/templateset"
2222
ackmetadata "github.com/aws-controllers-k8s/code-generator/pkg/metadata"
2323
ackmodel "github.com/aws-controllers-k8s/code-generator/pkg/model"
24+
"github.com/aws-controllers-k8s/pkg/names"
2425
)
2526

2627
var (
@@ -103,6 +104,10 @@ func Release(
103104
releaseFuncMap(m.MetaVars().ControllerName),
104105
)
105106
metaVars := m.MetaVars()
107+
reconcileResources := make([]string, len(metaVars.CRDNames))
108+
for i, name := range metaVars.CRDNames {
109+
reconcileResources[i] = names.New(name).Camel
110+
}
106111

107112
releaseVars := &templateReleaseVars{
108113
metaVars,
@@ -112,6 +117,7 @@ func Release(
112117
},
113118
metadata,
114119
serviceAccountName,
120+
reconcileResources,
115121
}
116122
for _, path := range releaseTemplatePaths {
117123
outPath := strings.TrimSuffix(path, ".tpl")
@@ -140,4 +146,6 @@ type templateReleaseVars struct {
140146
Metadata *ackmetadata.ServiceMetadata
141147
// ServiceAccountName is the name of the ServiceAccount used in the Helm chart
142148
ServiceAccountName string
149+
// ReconcileResources contains all CRD names in their original format
150+
ReconcileResources []string
143151
}

templates/helm/templates/deployment.yaml.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ spec:
5959
- "$(ACK_WATCH_NAMESPACE)"
6060
- --watch-selectors
6161
- "$(ACK_WATCH_SELECTORS)"
62+
- --reconcile-resources
63+
- "$(RECONCILE_RESOURCES)"
6264
- --deletion-policy
6365
- "$(DELETION_POLICY)"
6466
{{ "{{- if .Values.leaderElection.enabled }}" }}
@@ -107,6 +109,8 @@ spec:
107109
value: {{ IncludeTemplate "watch-namespace" }}
108110
- name: ACK_WATCH_SELECTORS
109111
value: {{ "{{ .Values.watchSelectors }}" }}
112+
- name: RECONCILE_RESOURCES
113+
value: {{ "{{ join \",\" .Values.reconcile.resources | quote }}" }}
110114
- name: DELETION_POLICY
111115
value: {{ "{{ .Values.deletionPolicy }}" }}
112116
- name: LEADER_ELECTION_NAMESPACE

templates/helm/values.schema.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,14 @@
239239
},
240240
"resourceMaxConcurrentSyncs": {
241241
"type": "object"
242+
},
243+
"resources": {
244+
"type": "array",
245+
"items": {
246+
"type": "string"
247+
},
248+
"description": "List of resource kinds to reconcile. If empty, all resources will be reconciled.",
249+
"default": []
242250
}
243251
},
244252
"type": "object"

templates/helm/values.yaml.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ reconcile:
137137
# An object representing the reconcile max concurrent syncs configuration for each specific
138138
# resource.
139139
resourceMaxConcurrentSyncs: {}
140+
141+
# Set the value of resources to specify which resource kinds to reconcile.
142+
# If empty, all resources will be reconciled.
143+
# If specified, only the listed resource kinds will be reconciled.
144+
resources:
145+
{{- range $resource := .ReconcileResources }}
146+
- {{ $resource }}
147+
{{- end }}
140148

141149
serviceAccount:
142150
# Specifies whether a service account should be created

0 commit comments

Comments
 (0)