blob: c82b4d3609344ccda687bbb8f0a244dbaaecfc44 [file] [log] [blame]
garciadeblas83775ba2025-07-23 18:35:24 +02001#######################################################################################
2# Copyright ETSI Contributors and Others.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13# implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#######################################################################################
17
18# Placeholder module for supporting custom transformations
19
20# Import SDK modules
21use ../../krm *
22use ../location.nu
23
24
25# Placeholder for a custom "create" transformation for a Brick of `custom`, `custom-hr`, or `full-custom` types, to be applied to the ResourceList received from stdin.
26# - If the Brick is of `custom` type, a `basic` Brick transformation will be applied right before in the pipeline.
27# - If the Brick is of `custom-hr` type, a `helmreleaseset` Brick transformation will be applied right before in the pipeline.
28# - If the Brick is of `full-custom` type, only this transformation will be applied to the original ResourceList.
29export def "create" [
30 brick: record # Brick specification
31 environment: record = {} # Record with environment variables to load
32]: [
33 record -> record
34] {
35 let rl: record = $in
36
37 # Get the key parts
38 let brick_name: string = ($brick | get -i name | default "untitled-brick")
39 let brick_type: string = ($brick | get -i type | default "basic" | str downcase)
40 let kustomization_name: string = ($brick | get $.kustomization.name)
41 let kustomization_namespace: string = ($brick | get -i $.kustomization.namespace | default "flux-system")
42
43 # Here would come your custom transformations over `rl`
44 # . . .
45 print $"Here we are applying a custom `create` transformation of '($brick_type)' type."
46 # The print above is just informative. Please remove in your final custom transformation.
47
48 # Here we should return the result of the custom transformations.
49 # For the sake of the example, let's return just the original ResouceList with no transformations
50 $rl
51}
52
53
54# Placeholder for a custom "update" transformation for a Brick of `custom`, `custom-hr`, or `full-custom` types, to be applied to the ResourceList received from stdin.
55# - If the Brick is of `custom` type, a `basic` Brick transformation will be applied right before in the pipeline.
56# - If the Brick is of `custom-hr` type, a `helmreleaseset` Brick transformation will be applied right before in the pipeline.
57# - If the Brick is of `full-custom` type, only this transformation will be applied to the original ResourceList.
58export def "update" [
59 brick: record # Brick specification
60 environment: record = {} # Record with environment variables to load
61]: [
62 record -> record
63] {
64 let rl: record = $in
65
66 # Get the key parts
67 let brick_name: string = ($brick | get -i name | default "untitled-brick")
68 let brick_type: string = ($brick | get -i type | default "basic" | str downcase)
69 let kustomization_name: string = ($brick | get $.kustomization.name)
70 let kustomization_namespace: string = ($brick | get -i $.kustomization.namespace | default "flux-system")
71
72 # Here would come your custom transformations over `rl`
73 # . . .
74 print $"Here we are applying a custom `update` transformation of '($brick_type)' type."
75 # The print above is just informative. Please remove in your final custom transformation.
76
77 # Here we should return the result of the custom transformations.
78 # For the sake of the example, let's return just the original ResouceList with no transformations
79 $rl
80}
81
82
83# Placeholder for a custom "delete" transformation for a Brick of `custom`, `custom-hr`, or `full-custom` types, to be applied to the ResourceList received from stdin.
84# - If the Brick is of `custom` type, a `basic` Brick transformation will be applied right before in the pipeline.
85# - If the Brick is of `custom-hr` type, a `helmreleaseset` Brick transformation will be applied right before in the pipeline.
86# - If the Brick is of `full-custom` type, only this transformation will be applied to the original ResourceList.
87export def "delete" [
88 brick: record # Brick specification
89 environment: record = {} # Record with environment variables to load
90]: [
91 record -> record
92] {
93 let rl: record = $in
94
95 # Get the key parts
96 let brick_name: string = ($brick | get -i name | default "untitled-brick")
97 let brick_type: string = ($brick | get -i type | default "basic" | str downcase)
98 let kustomization_name: string = ($brick | get $.kustomization.name)
99 let kustomization_namespace: string = ($brick | get -i $.kustomization.namespace | default "flux-system")
100
101 # Here would come your custom transformations over `rl`
102 # . . .
103 print $"Here we are applying a custom `delete` transformation of '($brick_type)' type."
104 # The print above is just informative. Please remove in your final custom transformation.
105
106 # Here we should return the result of the custom transformations.
107 # For the sake of the example, let's return just the original ResouceList with no transformations
108 $rl
109}