airshipctl/krm-functions/templater/local-resource/example-use.yaml
Sirajudeen 8971bc4882 skip generating etherenet_mac_address when null
* Host-generator template is generating a null value like below when host
  catalogue is not having any mac value for the interface.
  ethernet_mac_address: <no value>

* added another condition to ethernet_mac_address generation logic
  so generate only if macAddresses is provided and if it has
  value for the respective interface ( oam, pxe ...)

Closes: #404
Change-Id: I2fafe5ceaa4c58855a17929c1c41d60045d1675a
2021-08-26 20:58:35 +00:00

43 lines
1.2 KiB
YAML

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: airshipit.org/v1alpha1
kind: Templater
metadata:
annotations:
config.kubernetes.io/function: |
container:
image: localhost/templater
values:
hosts:
- macAddresses:
oam: 00:aa:bb:cc:dd
pxe: 00:aa:bb:cc:ee
name: node-1
- macAddresses:
oam: 00:aa:bb:cc:ff
name: node-2
- macAddresses:
pxe: 00:aa:bb:cc:22
name: node-3
template: |
{{ range .hosts -}}
---
apiVersion: metal3.io/v1alpha1
kind: BareMetalHost
metadata:
name: {{ .name }}
spec:
{{- if and (.macAddresses) (.macAddresses.oam) }}
bootMACAddress: {{ .macAddresses.oam }}
{{- end }}
{{ end -}}