Merge "Add service params snippet"

This commit is contained in:
Zuul
2024-09-17 00:20:29 +00:00
committed by Gerrit Code Review
3 changed files with 63 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm Helm-Toolkit
name: helm-toolkit
version: 0.2.70
version: 0.2.71
home: https://docs.openstack.org/openstack-helm
icon: https://www.openstack.org/themes/openstack/images/project-mascots/OpenStack-Helm/OpenStack_Project_OpenStackHelm_vertical.png
sources:

View File

@@ -0,0 +1,61 @@
{{/*
Copyright 2017 The Openstack-Helm Authors.
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.
*/}}
{{/*
abstract: |
Inserts kubernetes service parameters from values as is.
values: |
network:
serviceExample:
service:
type: loadBalancer
loadBalancerIP: 1.1.1.1
usage: |
---
apiVersion: v1
kind: Service
metadata:
name: 'serviceExample'
spec:
ports:
- name: s-example
port: 1111
{{ .Values.network.serviceExample | include "helm-toolkit.snippets.service_params" | indent 2 }}
return: |
type: loadBalancer
loadBalancerIP: 1.1.1.1
*/}}
{{- define "helm-toolkit.snippets.service_params" }}
{{- $serviceParams := dict }}
{{- if hasKey . "service" }}
{{- $serviceParams = .service }}
{{- end }}
{{- if hasKey . "node_port" }}
{{- if hasKey .node_port "enabled" }}
{{- if .node_port.enabled }}
{{- $_ := set $serviceParams "type" "NodePort" }}
{{- end }}
{{- end }}
{{- end }}
{{- if hasKey . "external_policy_local" }}
{{- if .external_policy_local }}
{{- $_ := set $serviceParams "externalTrafficPolicy" "Local" }}
{{- end }}
{{- end }}
{{- if $serviceParams }}
{{- $serviceParams | toYaml }}
{{- end }}
{{- end }}

View File

@@ -77,4 +77,5 @@ helm-toolkit:
- 0.2.68 Use quay.io/airshipit/kubernetes-entrypoint:latest-ubuntu_focal by default
- 0.2.69 Use quay.io/airshipit/kubernetes-entrypoint:latest-ubuntu_focal by default
- 0.2.70 Decode url-encoded password for rabbit connection
- 0.2.71 Add snippet with service parameters
...