Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.enableHttpRoutes | default .Values.installGatewayAPI }}
{{- if (ternary .Values.enableHttpRoutes .Values.installGatewayAPI (hasKey .Values "enableHttpRoutes")) }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no-parenthesis alternative:

{{- if hasKey .Values "enableHttpRoutes" | ternary .Values.enableHttpRoutes .Values.installGatewayAPI }}

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.enableHttpRoutes | default .Values.installGatewayAPI }}
{{- if (ternary .Values.enableHttpRoutes .Values.installGatewayAPI (hasKey .Values "enableHttpRoutes")) }}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.enableTcpRoutes | default .Values.installGatewayAPI }}
{{- if (ternary .Values.enableTcpRoutes .Values.installGatewayAPI (hasKey .Values "enableTcpRoutes")) }}
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.enableTlsRoutes | default .Values.installGatewayAPI }}
{{- if (ternary .Values.enableTcpRoutes .Values.installGatewayAPI (hasKey .Values "enableTcpRoutes")) }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be enableTlsRoutes

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
Expand Down
6 changes: 3 additions & 3 deletions charts/linkerd-crds/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
installGatewayAPI: true
# -- Controls if Linkerd should install the Gateway API HTTPRoutes and
# GRPCRoutes CRDs. If unspecified, the value of `installGatewayAPI` is used.
enableHttpRoutes: false
# enableHttpRoutes: false
# -- Controls if Linkerd should install the Gateway API TLSRoutes CRD. If
# unspecified, the value of `installGatewayAPI` is used.
enableTlsRoutes: false
# enableTlsRoutes: false
# -- Controls if Linkerd should install the Gateway API TCPRoutes CRD. If
# unspecified, the value of `installGatewayAPI` is used.
enableTcpRoutes: false
# enableTcpRoutes: false
40 changes: 32 additions & 8 deletions cli/cmd/install_helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"bytes"
"fmt"
"path/filepath"
"testing"

Expand All @@ -24,15 +25,31 @@ func TestRenderHelm(t *testing.T) {
t.Run("Non-HA mode", func(t *testing.T) {
chartCrds := chartCrds(t)
chartControlPlane := chartControlPlane(t, false, "", "111", "222")
testRenderHelm(t, chartCrds, "install_helm_crds_output.golden")
testRenderHelm(t, chartControlPlane, "install_helm_control_plane_output.golden")
testRenderHelm(t, chartCrds, nil, "install_helm_crds_output.golden")
testRenderHelm(t, chartControlPlane, nil, "install_helm_control_plane_output.golden")
})

t.Run("CRDs without Gateway API", func(t *testing.T) {
chartCrds := chartCrds(t)
testRenderHelm(t, chartCrds, map[string]interface{}{
"installGatewayAPI": false,
}, "install_helm_crds_without_gateway_output.golden")
})

t.Run("CRDs without Gateway API routes", func(t *testing.T) {
chartCrds := chartCrds(t)
testRenderHelm(t, chartCrds, map[string]interface{}{
"enableHttpRoutes": false,
"enableTcpRoutes": false,
"enableTlsRoutes": false,
}, "install_helm_crds_without_gateway_output.golden")
})

t.Run("HA mode", func(t *testing.T) {
chartCrds := chartCrds(t)
chartControlPlane := chartControlPlane(t, true, "", "111", "222")
testRenderHelm(t, chartCrds, "install_helm_crds_output_ha.golden")
testRenderHelm(t, chartControlPlane, "install_helm_control_plane_output_ha.golden")
testRenderHelm(t, chartCrds, nil, "install_helm_crds_output_ha.golden")
testRenderHelm(t, chartControlPlane, nil, "install_helm_control_plane_output_ha.golden")
})

t.Run("HA mode with GID", func(t *testing.T) {
Expand All @@ -42,7 +59,7 @@ proxy:
gid: 4231
`
chartControlPlane := chartControlPlane(t, true, additionalConfig, "111", "222")
testRenderHelm(t, chartControlPlane, "install_helm_control_plane_output_ha_with_gid.golden")
testRenderHelm(t, chartControlPlane, nil, "install_helm_control_plane_output_ha_with_gid.golden")
})

t.Run("HA mode with podLabels and podAnnotations", func(t *testing.T) {
Expand All @@ -55,7 +72,7 @@ podAnnotations:
asda: fasda
`
chartControlPlane := chartControlPlane(t, true, additionalConfig, "333", "444")
testRenderHelm(t, chartControlPlane, "install_helm_output_ha_labels.golden")
testRenderHelm(t, chartControlPlane, nil, "install_helm_output_ha_labels.golden")
})

t.Run("HA mode with custom namespaceSelector", func(t *testing.T) {
Expand All @@ -76,11 +93,11 @@ profileValidator:
- enabled
`
chartControlPlane := chartControlPlane(t, true, additionalConfig, "111", "222")
testRenderHelm(t, chartControlPlane, "install_helm_output_ha_namespace_selector.golden")
testRenderHelm(t, chartControlPlane, nil, "install_helm_output_ha_namespace_selector.golden")
})
}

func testRenderHelm(t *testing.T, linkerd2Chart *chart.Chart, goldenFileName string) {
func testRenderHelm(t *testing.T, linkerd2Chart *chart.Chart, additionalValues map[string]interface{}, goldenFileName string) {
var (
chartName = "linkerd2"
namespace = "linkerd-dev"
Expand Down Expand Up @@ -139,6 +156,9 @@ func testRenderHelm(t *testing.T, linkerd2Chart *chart.Chart, goldenFileName str
if err != nil {
t.Fatal("Unexpected error", err)
}
for k, v := range additionalValues {
overrideConfig[k] = v
}

releaseOptions := chartutil.ReleaseOptions{
Name: chartName,
Expand All @@ -147,11 +167,15 @@ func testRenderHelm(t *testing.T, linkerd2Chart *chart.Chart, goldenFileName str
IsInstall: true,
}

fmt.Println("overrideConfig", overrideConfig)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover debugging?


valuesToRender, err := chartutil.ToRenderValues(linkerd2Chart, overrideConfig, releaseOptions, nil)
if err != nil {
t.Fatal("Unexpected error", err)
}

fmt.Println("valuesToRender", valuesToRender)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto


rendered, err := engine.Render(linkerd2Chart, valuesToRender)
if err != nil {
t.Fatal("Unexpected error", err)
Expand Down
19 changes: 13 additions & 6 deletions cli/cmd/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,6 @@ func TestIgnoreCluster(t *testing.T) {
}

func TestRenderCRDs(t *testing.T) {
defaultValues, err := testInstallOptions()
if err != nil {
t.Fatal(err)
}
addFakeTLSSecrets(defaultValues)

var buf bytes.Buffer
if err := renderCRDs(context.Background(), nil, &buf, values.Options{}, "yaml"); err != nil {
t.Fatalf("Failed to render templates: %v", err)
Expand All @@ -304,6 +298,19 @@ func TestRenderCRDs(t *testing.T) {
}
}

func TestRenderCRDsWithGatewayAPI(t *testing.T) {
options := values.Options{
Values: []string{"installGatewayAPI=true"},
}
var buf bytes.Buffer
if err := renderCRDs(context.Background(), nil, &buf, options, "yaml"); err != nil {
t.Fatalf("Failed to render templates: %v", err)
}
if err := testDataDiffer.DiffTestYAML("install_crds_with_gateway_api.golden", buf.String()); err != nil {
t.Error(err)
}
}

func TestValidateAndBuild_Errors(t *testing.T) {
t.Run("Fails validation for invalid ignoreInboundPorts", func(t *testing.T) {
values, err := testInstallOptions()
Expand Down
Loading
Loading