File tree Expand file tree Collapse file tree 2 files changed +80
-0
lines changed Expand file tree Collapse file tree 2 files changed +80
-0
lines changed Original file line number Diff line number Diff line change @@ -276,6 +276,69 @@ spec:
276
276
password: <password> # or KCL_SRC_PASSWORD environment variable
277
277
` ` `
278
278
279
+ You can provide credentials in a Secret to your pipeline step under the name `kcl-registry`.
280
+
281
+ ` ` ` yaml
282
+ # composition.yaml
283
+ apiVersion: apiextensions.crossplane.io/v1
284
+ kind: Composition
285
+ metadata:
286
+ name: example
287
+ spec:
288
+ compositeTypeRef:
289
+ apiVersion: example.crossplane.io/v1beta1
290
+ kind: XR
291
+ mode: Pipeline
292
+ pipeline:
293
+ - step: basic
294
+ functionRef:
295
+ name: function-kcl
296
+ input:
297
+ apiVersion: krm.kcl.dev/v1alpha1
298
+ kind: KCLInput
299
+ source: |
300
+ # Read the XR
301
+ oxr = option("params").oxr
302
+ # Patch the XR with the status field
303
+ dxr = {
304
+ **option("params").dxr
305
+ status.dummy = "cool-status"
306
+ }
307
+ # Construct a bucket
308
+ bucket = {
309
+ apiVersion = "s3.aws.upbound.io/v1beta1"
310
+ kind = "Bucket"
311
+ metadata.annotations: {
312
+ "krm.kcl.dev/composition-resource-name" = "bucket"
313
+ }
314
+ spec.forProvider.region = option("oxr").spec.region
315
+ }
316
+ # Return the bucket and patched XR
317
+ items = [bucket, dxr]
318
+ credentials: # If private OCI registry
319
+ - name: kcl-registry
320
+ source: Secret
321
+ secretRef:
322
+ namespace: default
323
+ name: default
324
+ ` ` `
325
+
326
+ And your secret :
327
+
328
+ ` ` ` yaml
329
+ apiVersion: v1
330
+ kind: Secret
331
+ metadata:
332
+ name: default
333
+ namsepace: default
334
+ data:
335
+ username: dXNlcm5hbWU=
336
+ password: cGFzc3dvcmQ=
337
+ url: aHR0cHM6Ly9leGFtcGxlLmNvbQ==
338
+ ` ` `
339
+
340
+ You can use these credentials with `crossplane render --function-credentials=secret.yaml xr.yaml composition.yaml functions.yaml`.
341
+
279
342
# ## Run Config
280
343
281
344
` ` ` yaml
Original file line number Diff line number Diff line change @@ -60,6 +60,23 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
60
60
if f .dependencies != "" {
61
61
in .Spec .Dependencies = f .dependencies + "\n " + in .Spec .Dependencies
62
62
}
63
+ // Add credentials
64
+ if creds , ok := req .Credentials ["kcl-registry" ]; ok {
65
+ data := creds .GetCredentialData ()
66
+ if data != nil {
67
+ if password , ok := data .Data ["password" ]; ok {
68
+ in .Spec .Credentials .Password = string (password )
69
+ if username , ok := data .Data ["username" ]; ok {
70
+ in .Spec .Credentials .Username = string (username )
71
+ }
72
+ if url , ok := data .Data ["url" ]; ok {
73
+ in .Spec .Credentials .Url = string (url )
74
+ }
75
+ } else {
76
+ log .Info ("Warning: required password not found in the credentials" )
77
+ }
78
+ }
79
+ }
63
80
if err := in .Validate (); err != nil {
64
81
response .Fatal (rsp , errors .Wrap (err , "invalid function input" ))
65
82
return rsp , nil
You can’t perform that action at this time.
0 commit comments