Skip to content

Commit

Permalink
cleanup serverless chart config (#1798)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbadura authored Oct 6, 2023
1 parent 554b7bc commit c7a0e5f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 144 deletions.
38 changes: 0 additions & 38 deletions internal/deploy/values/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,44 +50,6 @@ func (b *builder) addDefaultGlobalTLSCrtAndKey(tlsCrt, tlsKey string) *builder {
})
}

type serverlessRegistryConfig struct {
enable bool
serverAddress string
internalServerAddress string
registryAddress string
}

func (b *builder) addDefaultServerlessRegistryConfig(config serverlessRegistryConfig) *builder {
return b.addDefaultValues(map[string]interface{}{
"serverless": map[string]interface{}{
"dockerRegistry": map[string]interface{}{
"enableInternal": config.enable,
"internalServerAddress": config.internalServerAddress,
"serverAddress": config.serverAddress,
"registryAddress": config.registryAddress,
},
},
})
}

// https://github.com/GoogleContainerTools/kaniko/issues/1592
// https://github.com/kyma-project/kyma/issues/13051
func (b *builder) addDefaultServerlessKanikoForce() *builder {
return b.addDefaultValues(map[string]interface{}{
"serverless": map[string]interface{}{
"containers": map[string]interface{}{
"manager": map[string]interface{}{
"envs": map[string]interface{}{
"functionBuildExecutorArgs": map[string]interface{}{
"value": "--insecure,--skip-tls-verify,--skip-unused-stages,--log-format=text,--cache=true,--force",
},
},
},
},
},
})
}

func (b *builder) addDefaultk3dValuesForIstio() *builder {
return b.addDefaultValues(map[string]interface{}{
"istio": map[string]interface{}{
Expand Down
13 changes: 1 addition & 12 deletions internal/deploy/values/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package values

import (
"encoding/base64"
"fmt"
"os"
"path/filepath"

Expand Down Expand Up @@ -46,20 +45,10 @@ func Merge(sources Sources, workspaceDir string, clusterInfo clusterinfo.Info) (
}

func addClusterSpecificDefaults(builder *builder, clusterInfo clusterinfo.Info) {
if k3d, isK3d := clusterInfo.(clusterinfo.K3d); isK3d {

k3dRegistry := fmt.Sprintf("k3d-%s-registry:5000", k3d.ClusterName)
defaultRegistryConfig := serverlessRegistryConfig{
enable: false,
registryAddress: k3dRegistry,
serverAddress: k3dRegistry,
internalServerAddress: k3dRegistry,
}
if _, isK3d := clusterInfo.(clusterinfo.K3d); isK3d {
builder.
addDefaultServerlessRegistryConfig(defaultRegistryConfig).
addDefaultGlobalDomainName(defaultLocalKymaDomain).
addDefaultGlobalTLSCrtAndKey(defaultLocalTLSCrtEnc, defaultLocalTLSKeyEnc).
addDefaultServerlessKanikoForce().
addDefaultk3dValuesForIstio()
} else if gardener, isGardener := clusterInfo.(clusterinfo.Gardener); isGardener {
builder.addDefaultGlobalDomainName(gardener.Domain)
Expand Down
94 changes: 0 additions & 94 deletions internal/deploy/values/values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,65 +192,6 @@ func TestMerge(t *testing.T) {
"tlsCrt": defaultLocalTLSCrtEnc,
"tlsKey": defaultLocalTLSKeyEnc,
},
"serverless": map[string]interface{}{
"dockerRegistry": map[string]interface{}{
"enableInternal": false,
"internalServerAddress": "k3d-foo-registry:5000",
"serverAddress": "k3d-foo-registry:5000",
"registryAddress": "k3d-foo-registry:5000",
},
"containers": map[string]interface{}{
"manager": map[string]interface{}{
"envs": map[string]interface{}{
"functionBuildExecutorArgs": map[string]interface{}{
"value": "--insecure,--skip-tls-verify,--skip-unused-stages,--log-format=text,--cache=true,--force",
},
},
},
},
},
"istio": map[string]interface{}{
"helmValues": map[string]interface{}{
"cni": map[string]string{
"cniConfDir": "/var/lib/rancher/k3s/agent/etc/cni/net.d",
"cniBinDir": "/bin",
},
},
},
}

require.NoError(t, err)
require.Truef(t, reflect.DeepEqual(expected, actual), "want: %#v\n got: %#v\n", expected, actual)
})

t.Run("Serverless registry overrides", func(t *testing.T) {
src := Sources{ValueFiles: []string{"./testdata/registry-overrides.yaml"}}
actual, err := Merge(src, "testdata", clusterinfo.K3d{ClusterName: "foo"})

expected := Values{
"global": map[string]interface{}{
"domainName": "local.kyma.dev",
"tlsCrt": defaultLocalTLSCrtEnc,
"tlsKey": defaultLocalTLSKeyEnc,
},
"serverless": map[string]interface{}{
"dockerRegistry": map[string]interface{}{
"enableInternal": true,
"password": "secret password",
"internalServerAddress": "internal-address",
"serverAddress": "external-address",
"registryAddress": "external-push-address",
},
"containers": map[string]interface{}{
"manager": map[string]interface{}{
"envs": map[string]interface{}{
"functionBuildExecutorArgs": map[string]interface{}{
"value": "--insecure,--skip-tls-verify,--skip-unused-stages,--log-format=text,--cache=true,--force",
},
},
},
},
},
"istio": map[string]interface{}{
"helmValues": map[string]interface{}{
"cni": map[string]string{
Expand All @@ -271,7 +212,6 @@ func TestMerge(t *testing.T) {
"global.domainName=github.com",
"global.tlsCrt=github_tls_crt",
"global.tlsKey=github_tls_key",
"serverless.dockerRegistry.enableInternal=true",
},
}, "testdata", clusterinfo.K3d{ClusterName: "foo"})

Expand All @@ -281,23 +221,6 @@ func TestMerge(t *testing.T) {
"tlsCrt": "github_tls_crt",
"tlsKey": "github_tls_key",
},
"serverless": map[string]interface{}{
"dockerRegistry": map[string]interface{}{
"enableInternal": true,
"internalServerAddress": "k3d-foo-registry:5000",
"serverAddress": "k3d-foo-registry:5000",
"registryAddress": "k3d-foo-registry:5000",
},
"containers": map[string]interface{}{
"manager": map[string]interface{}{
"envs": map[string]interface{}{
"functionBuildExecutorArgs": map[string]interface{}{
"value": "--insecure,--skip-tls-verify,--skip-unused-stages,--log-format=text,--cache=true,--force",
},
},
},
},
},
"istio": map[string]interface{}{
"helmValues": map[string]interface{}{
"cni": map[string]string{
Expand All @@ -323,23 +246,6 @@ func TestMerge(t *testing.T) {
"tlsCrt": defaultLocalTLSCrtEnc,
"tlsKey": defaultLocalTLSKeyEnc,
},
"serverless": map[string]interface{}{
"dockerRegistry": map[string]interface{}{
"enableInternal": false,
"internalServerAddress": "k3d-foo-registry:5000",
"serverAddress": "k3d-foo-registry:5000",
"registryAddress": "k3d-foo-registry:5000",
},
"containers": map[string]interface{}{
"manager": map[string]interface{}{
"envs": map[string]interface{}{
"functionBuildExecutorArgs": map[string]interface{}{
"value": "--insecure,--skip-tls-verify,--skip-unused-stages,--log-format=text,--cache=true,--force",
},
},
},
},
},
"istio": map[string]interface{}{
"helmValues": map[string]interface{}{
"cni": map[string]string{
Expand Down

0 comments on commit c7a0e5f

Please sign in to comment.