Commit f5a5a44e authored by Hordur Freyr Yngvason's avatar Hordur Freyr Yngvason
Browse files

Merge branch 'ingress_api_version' into 'master'

feat: added support of new ingress apiVersion

See merge request gitlab-org/cluster-integration/auto-deploy-image!175
parents c2cde787 93c5e37e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
apiVersion: v1
description: GitLab's Auto-deploy Helm Chart
name: auto-deploy-app
version: 2.4.0
version: 2.5.0
icon: https://gitlab.com/gitlab-com/gitlab-artwork/raw/master/logo/logo-square.png
+16 −0
Original line number Diff line number Diff line
{{- if and (.Values.service.enabled) (or (.Values.ingress.enabled) (not (hasKey .Values.ingress "enabled"))) -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
apiVersion: networking.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress"}}
apiVersion: networking.k8s.io/v1beta1
{{ else }}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
  name: {{ template "fullname" . }}
@@ -59,9 +65,19 @@ spec:
      &httpRule
      paths:
      - path: {{ .Values.ingress.path | default "/" | quote }}
        {{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
        pathType: Prefix
        {{- end }}
        backend:
          {{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
          service:
            name: {{ template "fullname" . }}
            port:
              number: {{ .Values.service.externalPort }}
          {{ else }}
          serviceName: {{ template "fullname" . }}
          servicePort: {{ .Values.service.externalPort }}
          {{- end }}
{{- if .Values.service.commonName }}
  - host: {{ template "hostname" .Values.service.commonName }}
    http:
+5 −5
Original line number Diff line number Diff line
module gitlab.com/gitlab-org/charts/auto-deploy-app/test

go 1.13
go 1.15

require (
	github.com/gruntwork-io/terratest v0.28.15
	github.com/stretchr/testify v1.4.0
	k8s.io/api v0.18.3
	k8s.io/apimachinery v0.18.3
	github.com/gruntwork-io/terratest v0.32.1
	github.com/stretchr/testify v1.6.1
	k8s.io/api v0.19.7
	k8s.io/apimachinery v0.19.7
)
+108 −0

File changed.

Preview size limit exceeded, changes collapsed.

+38 −0
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@ import (
	"github.com/gruntwork-io/terratest/modules/helm"
	"github.com/stretchr/testify/require"
	extensions "k8s.io/api/extensions/v1beta1"
	networkingv1 "k8s.io/api/networking/v1"
	networkingv1beta "k8s.io/api/networking/v1beta1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

@@ -322,3 +324,39 @@ func TestIngressTemplate_TLSSecret(t *testing.T) {
		})
	}
}

func TestIngressTemplate_NetworkingV1Beta1(t *testing.T) {
	templates := []string{"templates/ingress.yaml"}
	releaseName := "ingress-networking-v1beta1"
	opts := &helm.Options{
		SetValues: map[string]string{"ingress.enabled": "true"},
	}
	output := helm.RenderTemplate(t, opts, helmChartPath, releaseName, templates, "--api-versions", "networking.k8s.io/v1beta1/Ingress")
	ingress := new(networkingv1beta.Ingress)
	helm.UnmarshalK8SYaml(t, output, ingress)
	require.Equal(t, "networking.k8s.io/v1beta1", ingress.APIVersion)
}

func TestIngressTemplate_NetworkingV1(t *testing.T) {
	templates := []string{"templates/ingress.yaml"}
	releaseName := "ingress-networking-v1"
	opts := &helm.Options{
		SetValues: map[string]string{"ingress.enabled": "true"},
	}
	output := helm.RenderTemplate(t, opts, helmChartPath, releaseName, templates, "--api-versions", "networking.k8s.io/v1/Ingress")
	ingress := new(networkingv1.Ingress)
	helm.UnmarshalK8SYaml(t, output, ingress)
	require.Equal(t, "networking.k8s.io/v1", ingress.APIVersion)
}

func TestIngressTemplate_Extensions(t *testing.T) {
	templates := []string{"templates/ingress.yaml"}
	releaseName := "ingress-extensions-v1beta1"
	opts := &helm.Options{
		SetValues: map[string]string{"ingress.enabled": "true"},
	}
	output := helm.RenderTemplate(t, opts, helmChartPath, releaseName, templates, "--api-versions", "extensions/v1beta1/Ingress")
	ingress := new(extensions.Ingress)
	helm.UnmarshalK8SYaml(t, output, ingress)
	require.Equal(t, "extensions/v1beta1", ingress.APIVersion)
}
Loading