Skip to content

Commit 2d224e0

Browse files
Despiregithub-actions[bot]CI/CD pipeline
authored
feat: propagate credentials update (#2056)
Closes #1967 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added provider credential copy and equality operations for more reliable credential handling. * **Bug Fixes / Reconciliation** * Reconciliation now detects and applies credential differences to in-memory cluster state and defers other work when updates occur. * **Tests** * Added comprehensive tests for credential copy/compare and node-pool credential update scenarios. * **Chores** * Updated deployment image tags for multiple components. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: CI/CD pipeline <CI/CD-pipeline@users.noreply.github.com>
1 parent efb98e6 commit 2d224e0

6 files changed

Lines changed: 1389 additions & 8 deletions

File tree

manifests/claudie/kustomization.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ apiVersion: kustomize.config.k8s.io/v1beta1
5656
kind: Kustomization
5757
images:
5858
- name: ghcr.io/berops/claudie/ansibler
59-
newTag: c71fbb0-4077
59+
newTag: d9754c7-4083
6060
- name: ghcr.io/berops/claudie/autoscaler-adapter
61-
newTag: c71fbb0-4077
61+
newTag: d9754c7-4083
6262
- name: ghcr.io/berops/claudie/claudie-operator
63-
newTag: f62bf86-4079
63+
newTag: d9754c7-4083
6464
- name: ghcr.io/berops/claudie/kube-eleven
65-
newTag: c71fbb0-4077
65+
newTag: d9754c7-4083
6666
- name: ghcr.io/berops/claudie/kuber
67-
newTag: c71fbb0-4077
67+
newTag: d9754c7-4083
6868
- name: ghcr.io/berops/claudie/manager
69-
newTag: c71fbb0-4077
69+
newTag: d9754c7-4083
7070
- name: ghcr.io/berops/claudie/terraformer
71-
newTag: c71fbb0-4077
71+
newTag: d9754c7-4083

manifests/testing-framework/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ secretGenerator:
8989

9090
images:
9191
- name: ghcr.io/berops/claudie/testing-framework
92-
newTag: c71fbb0-4077
92+
newTag: d9754c7-4083

proto/pb/spec/utils.go

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,181 @@ func (pr *Provider) Credentials() string {
9292
}
9393
}
9494

95+
func (pr *Provider) CopyCredentials(other *Provider) {
96+
if pr == nil {
97+
return
98+
}
99+
100+
if other == nil {
101+
return
102+
}
103+
104+
switch p := pr.ProviderType.(type) {
105+
case *Provider_Aws:
106+
o, ok := other.ProviderType.(*Provider_Aws)
107+
if !ok {
108+
return
109+
}
110+
111+
p.Aws.AccessKey = o.Aws.AccessKey
112+
p.Aws.SecretKey = o.Aws.SecretKey
113+
case *Provider_Azure:
114+
o, ok := other.ProviderType.(*Provider_Azure)
115+
if !ok {
116+
return
117+
}
118+
119+
p.Azure.ClientSecret = o.Azure.ClientSecret
120+
case *Provider_Cloudflare:
121+
o, ok := other.ProviderType.(*Provider_Cloudflare)
122+
if !ok {
123+
return
124+
}
125+
126+
p.Cloudflare.Token = o.Cloudflare.Token
127+
case *Provider_Cloudrift:
128+
o, ok := other.ProviderType.(*Provider_Cloudrift)
129+
if !ok {
130+
return
131+
}
132+
133+
p.Cloudrift.Token = o.Cloudrift.Token
134+
case *Provider_Exoscale:
135+
o, ok := other.ProviderType.(*Provider_Exoscale)
136+
if !ok {
137+
return
138+
}
139+
140+
p.Exoscale.ApiSecret = o.Exoscale.ApiSecret
141+
p.Exoscale.ApiKey = o.Exoscale.ApiKey
142+
case *Provider_Gcp:
143+
o, ok := other.ProviderType.(*Provider_Gcp)
144+
if !ok {
145+
return
146+
}
147+
148+
p.Gcp.Key = o.Gcp.Key
149+
case *Provider_Hetzner:
150+
o, ok := other.ProviderType.(*Provider_Hetzner)
151+
if !ok {
152+
return
153+
}
154+
155+
p.Hetzner.Token = o.Hetzner.Token
156+
case *Provider_Oci:
157+
o, ok := other.ProviderType.(*Provider_Oci)
158+
if !ok {
159+
return
160+
}
161+
162+
p.Oci.KeyFingerprint = o.Oci.KeyFingerprint
163+
p.Oci.PrivateKey = o.Oci.PrivateKey
164+
case *Provider_Openstack:
165+
o, ok := other.ProviderType.(*Provider_Openstack)
166+
if !ok {
167+
return
168+
}
169+
170+
p.Openstack.ApplicationCredentialID = o.Openstack.ApplicationCredentialID
171+
p.Openstack.ApplicationCredentialSecret = o.Openstack.ApplicationCredentialSecret
172+
default:
173+
// do nothing.
174+
}
175+
}
176+
177+
// Checks whether these two providers have the same credentials.
178+
func (pr *Provider) CredentialsEqual(other *Provider) (equal bool) {
179+
if pr == nil {
180+
return
181+
}
182+
183+
if other == nil {
184+
return
185+
}
186+
187+
switch p := pr.ProviderType.(type) {
188+
case *Provider_Aws:
189+
o, ok := other.ProviderType.(*Provider_Aws)
190+
if !ok {
191+
return
192+
}
193+
194+
accessKey := p.Aws.AccessKey == o.Aws.AccessKey
195+
secretKey := p.Aws.SecretKey == o.Aws.SecretKey
196+
197+
equal = accessKey && secretKey
198+
case *Provider_Azure:
199+
o, ok := other.ProviderType.(*Provider_Azure)
200+
if !ok {
201+
return
202+
}
203+
204+
equal = p.Azure.ClientSecret == o.Azure.ClientSecret
205+
case *Provider_Cloudflare:
206+
o, ok := other.ProviderType.(*Provider_Cloudflare)
207+
if !ok {
208+
return
209+
}
210+
211+
equal = p.Cloudflare.Token == o.Cloudflare.Token
212+
case *Provider_Cloudrift:
213+
o, ok := other.ProviderType.(*Provider_Cloudrift)
214+
if !ok {
215+
return
216+
}
217+
218+
equal = p.Cloudrift.Token == o.Cloudrift.Token
219+
case *Provider_Exoscale:
220+
o, ok := other.ProviderType.(*Provider_Exoscale)
221+
if !ok {
222+
return
223+
}
224+
225+
apiSecret := p.Exoscale.ApiSecret == o.Exoscale.ApiSecret
226+
apiKey := p.Exoscale.ApiKey == o.Exoscale.ApiKey
227+
228+
equal = apiSecret && apiKey
229+
case *Provider_Gcp:
230+
o, ok := other.ProviderType.(*Provider_Gcp)
231+
if !ok {
232+
return
233+
}
234+
235+
equal = p.Gcp.Key == o.Gcp.Key
236+
case *Provider_Hetzner:
237+
o, ok := other.ProviderType.(*Provider_Hetzner)
238+
if !ok {
239+
return
240+
}
241+
242+
equal = p.Hetzner.Token == o.Hetzner.Token
243+
case *Provider_Oci:
244+
o, ok := other.ProviderType.(*Provider_Oci)
245+
if !ok {
246+
return
247+
}
248+
249+
fingerprint := p.Oci.KeyFingerprint == o.Oci.KeyFingerprint
250+
key := p.Oci.PrivateKey == o.Oci.PrivateKey
251+
252+
equal = fingerprint && key
253+
case *Provider_Openstack:
254+
o, ok := other.ProviderType.(*Provider_Openstack)
255+
if !ok {
256+
return
257+
}
258+
259+
id := p.Openstack.ApplicationCredentialID == o.Openstack.ApplicationCredentialID
260+
secret := p.Openstack.ApplicationCredentialSecret == o.Openstack.ApplicationCredentialSecret
261+
262+
equal = id && secret
263+
default:
264+
// do nothing.
265+
}
266+
267+
return
268+
}
269+
95270
// MustExtractTargetPath returns the target path of the external template repository.
96271
// If the URL of the repository is invalid this functions panics.
97272
// The target path is the path where the templates should be downloaded on the local

0 commit comments

Comments
 (0)