2022-10-21 06:01:28 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
|
|
|
package helm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/json"
|
2022-10-31 14:25:02 -04:00
|
|
|
"fmt"
|
|
|
|
"io/fs"
|
|
|
|
"os"
|
|
|
|
"path"
|
2022-11-30 11:27:08 -05:00
|
|
|
"path/filepath"
|
2022-11-25 08:56:30 -05:00
|
|
|
"sort"
|
|
|
|
"strings"
|
2022-10-21 06:01:28 -04:00
|
|
|
"testing"
|
|
|
|
|
2022-10-31 14:25:02 -04:00
|
|
|
"github.com/pkg/errors"
|
2022-10-21 06:01:28 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
2022-10-31 14:25:02 -04:00
|
|
|
"github.com/stretchr/testify/require"
|
2022-10-21 06:01:28 -04:00
|
|
|
"helm.sh/helm/v3/pkg/chart/loader"
|
2022-10-31 14:25:02 -04:00
|
|
|
"helm.sh/helm/v3/pkg/chartutil"
|
|
|
|
"helm.sh/helm/v3/pkg/engine"
|
2023-04-05 10:49:03 -04:00
|
|
|
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/idkeydigest"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/measurements"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/config"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/deploy/helm"
|
2022-10-21 06:01:28 -04:00
|
|
|
)
|
|
|
|
|
2022-10-31 14:25:02 -04:00
|
|
|
// TestLoad checks if the serialized format that Load returns correctly preserves the dependencies of the loaded chart.
|
2022-10-21 06:01:28 -04:00
|
|
|
func TestLoad(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
2022-10-31 14:25:02 -04:00
|
|
|
require := require.New(t)
|
2022-10-21 06:01:28 -04:00
|
|
|
|
2022-11-18 04:05:02 -05:00
|
|
|
config := &config.Config{Provider: config.ProviderConfig{GCP: &config.GCPConfig{}}}
|
2023-02-14 12:00:36 -05:00
|
|
|
chartLoader := ChartLoader{csp: config.GetProvider()}
|
2023-07-07 11:09:45 -04:00
|
|
|
release, err := chartLoader.Load(config, true, helm.WaitModeAtomic, []byte("secret"), []byte("salt"))
|
2022-10-31 14:25:02 -04:00
|
|
|
require.NoError(err)
|
2022-10-21 06:01:28 -04:00
|
|
|
|
|
|
|
var helmReleases helm.Releases
|
|
|
|
err = json.Unmarshal(release, &helmReleases)
|
2022-10-31 14:25:02 -04:00
|
|
|
require.NoError(err)
|
2022-10-21 06:01:28 -04:00
|
|
|
reader := bytes.NewReader(helmReleases.ConstellationServices.Chart)
|
|
|
|
chart, err := loader.LoadArchive(reader)
|
2022-10-31 14:25:02 -04:00
|
|
|
require.NoError(err)
|
2022-10-21 06:01:28 -04:00
|
|
|
assert.NotNil(chart.Dependencies())
|
|
|
|
}
|
2022-10-31 14:25:02 -04:00
|
|
|
|
2022-11-21 04:35:40 -05:00
|
|
|
// TestConstellationServices checks if the rendered constellation-services chart produces the expected yaml files.
|
|
|
|
func TestConstellationServices(t *testing.T) {
|
2022-10-31 14:25:02 -04:00
|
|
|
testCases := map[string]struct {
|
2022-11-18 04:05:02 -05:00
|
|
|
config *config.Config
|
2022-10-31 14:25:02 -04:00
|
|
|
enforceIDKeyDigest bool
|
|
|
|
ccmImage string
|
2022-11-02 12:47:10 -04:00
|
|
|
cnmImage string
|
2022-10-31 14:25:02 -04:00
|
|
|
}{
|
2023-03-17 04:53:22 -04:00
|
|
|
"AWS": {
|
2023-03-14 06:46:27 -04:00
|
|
|
config: &config.Config{
|
2023-06-30 02:46:32 -04:00
|
|
|
Provider: config.ProviderConfig{AWS: &config.AWSConfig{
|
|
|
|
DeployCSIDriver: toPtr(false),
|
|
|
|
}},
|
2023-05-03 05:11:53 -04:00
|
|
|
Attestation: config.AttestationConfig{AWSNitroTPM: &config.AWSNitroTPM{
|
2023-03-10 05:33:06 -05:00
|
|
|
Measurements: measurements.M{1: measurements.WithAllBytes(0xAA, measurements.Enforce, measurements.PCRMeasurementLength)},
|
2023-05-03 05:11:53 -04:00
|
|
|
}},
|
2023-03-14 06:46:27 -04:00
|
|
|
},
|
2023-06-26 04:13:28 -04:00
|
|
|
ccmImage: "ccmImageForAWS",
|
2022-10-31 14:25:02 -04:00
|
|
|
},
|
|
|
|
"Azure": {
|
2023-03-14 06:46:27 -04:00
|
|
|
config: &config.Config{
|
|
|
|
Provider: config.ProviderConfig{Azure: &config.AzureConfig{
|
2023-05-03 05:11:53 -04:00
|
|
|
DeployCSIDriver: toPtr(true),
|
|
|
|
}},
|
|
|
|
Attestation: config.AttestationConfig{AzureSEVSNP: &config.AzureSEVSNP{
|
2023-03-10 05:33:06 -05:00
|
|
|
Measurements: measurements.M{1: measurements.WithAllBytes(0xAA, measurements.Enforce, measurements.PCRMeasurementLength)},
|
2023-05-03 05:11:53 -04:00
|
|
|
FirmwareSignerConfig: config.SNPFirmwareSignerConfig{
|
|
|
|
AcceptedKeyDigests: idkeydigest.List{bytes.Repeat([]byte{0xAA}, 32)},
|
|
|
|
EnforcementPolicy: idkeydigest.MAAFallback,
|
|
|
|
MAAURL: "https://192.0.2.1:8080/maa",
|
2023-03-21 07:46:49 -04:00
|
|
|
},
|
2023-07-07 11:02:01 -04:00
|
|
|
BootloaderVersion: config.AttestationVersion{Value: 1, WantLatest: true},
|
|
|
|
TEEVersion: config.AttestationVersion{Value: 2, WantLatest: true},
|
|
|
|
SNPVersion: config.AttestationVersion{Value: 3, WantLatest: true},
|
|
|
|
MicrocodeVersion: config.AttestationVersion{Value: 4, WantLatest: true},
|
2023-03-14 06:46:27 -04:00
|
|
|
}},
|
|
|
|
},
|
2022-10-31 14:25:02 -04:00
|
|
|
enforceIDKeyDigest: true,
|
|
|
|
ccmImage: "ccmImageForAzure",
|
2022-11-02 12:47:10 -04:00
|
|
|
cnmImage: "cnmImageForAzure",
|
2022-10-31 14:25:02 -04:00
|
|
|
},
|
2023-03-17 04:53:22 -04:00
|
|
|
"GCP": {
|
|
|
|
config: &config.Config{
|
|
|
|
Provider: config.ProviderConfig{GCP: &config.GCPConfig{
|
|
|
|
DeployCSIDriver: toPtr(true),
|
|
|
|
}},
|
2023-05-03 05:11:53 -04:00
|
|
|
Attestation: config.AttestationConfig{GCPSEVES: &config.GCPSEVES{
|
2023-03-10 05:33:06 -05:00
|
|
|
Measurements: measurements.M{1: measurements.WithAllBytes(0xAA, measurements.Enforce, measurements.PCRMeasurementLength)},
|
2023-05-03 05:11:53 -04:00
|
|
|
}},
|
2023-03-17 04:53:22 -04:00
|
|
|
},
|
2023-06-26 04:13:28 -04:00
|
|
|
ccmImage: "ccmImageForGCP",
|
2023-03-17 04:53:22 -04:00
|
|
|
},
|
|
|
|
"OpenStack": {
|
|
|
|
config: &config.Config{
|
2023-05-03 05:11:53 -04:00
|
|
|
Provider: config.ProviderConfig{OpenStack: &config.OpenStackConfig{}},
|
|
|
|
Attestation: config.AttestationConfig{QEMUVTPM: &config.QEMUVTPM{
|
2023-03-10 05:33:06 -05:00
|
|
|
Measurements: measurements.M{1: measurements.WithAllBytes(0xAA, measurements.Enforce, measurements.PCRMeasurementLength)},
|
2023-05-03 05:11:53 -04:00
|
|
|
}},
|
2023-03-17 04:53:22 -04:00
|
|
|
},
|
2023-06-26 04:13:28 -04:00
|
|
|
ccmImage: "ccmImageForOpenStack",
|
2023-03-17 04:53:22 -04:00
|
|
|
},
|
2022-10-31 14:25:02 -04:00
|
|
|
"QEMU": {
|
2023-03-14 06:46:27 -04:00
|
|
|
config: &config.Config{
|
2023-05-03 05:11:53 -04:00
|
|
|
Provider: config.ProviderConfig{QEMU: &config.QEMUConfig{}},
|
|
|
|
Attestation: config.AttestationConfig{QEMUVTPM: &config.QEMUVTPM{
|
2023-03-10 05:33:06 -05:00
|
|
|
Measurements: measurements.M{1: measurements.WithAllBytes(0xAA, measurements.Enforce, measurements.PCRMeasurementLength)},
|
2023-05-03 05:11:53 -04:00
|
|
|
}},
|
2023-03-14 06:46:27 -04:00
|
|
|
},
|
2022-10-31 14:25:02 -04:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for name, tc := range testCases {
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
require := require.New(t)
|
|
|
|
|
2022-11-24 04:57:58 -05:00
|
|
|
chartLoader := ChartLoader{
|
2023-02-14 12:00:36 -05:00
|
|
|
csp: tc.config.GetProvider(),
|
2022-11-24 04:57:58 -05:00
|
|
|
joinServiceImage: "joinServiceImage",
|
2023-01-20 12:51:06 -05:00
|
|
|
keyServiceImage: "keyServiceImage",
|
2022-11-24 04:57:58 -05:00
|
|
|
ccmImage: tc.ccmImage,
|
|
|
|
cnmImage: tc.cnmImage,
|
|
|
|
autoscalerImage: "autoscalerImage",
|
|
|
|
verificationServiceImage: "verificationImage",
|
2022-11-25 04:01:41 -05:00
|
|
|
konnectivityImage: "konnectivityImage",
|
|
|
|
gcpGuestAgentImage: "gcpGuestAgentImage",
|
2022-11-24 04:57:58 -05:00
|
|
|
}
|
2023-03-20 09:49:04 -04:00
|
|
|
chart, err := loadChartsDir(helmFS, constellationServicesInfo.path)
|
2022-12-19 10:52:15 -05:00
|
|
|
require.NoError(err)
|
2023-06-26 04:13:28 -04:00
|
|
|
values := chartLoader.loadConstellationServicesValues()
|
2023-05-03 05:11:53 -04:00
|
|
|
err = extendConstellationServicesValues(values, tc.config, []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), []byte("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
|
2022-10-31 14:25:02 -04:00
|
|
|
require.NoError(err)
|
|
|
|
|
2022-11-21 04:35:40 -05:00
|
|
|
options := chartutil.ReleaseOptions{
|
|
|
|
Name: "testRelease",
|
|
|
|
Namespace: "testNamespace",
|
|
|
|
Revision: 1,
|
|
|
|
IsInstall: true,
|
|
|
|
IsUpgrade: false,
|
|
|
|
}
|
2023-06-30 02:46:32 -04:00
|
|
|
|
|
|
|
kubeVersion, err := chartutil.ParseKubeVersion("1.18.0")
|
|
|
|
require.NoError(err)
|
|
|
|
caps := &chartutil.Capabilities{
|
|
|
|
KubeVersion: *kubeVersion,
|
|
|
|
}
|
2022-11-21 04:35:40 -05:00
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
// Add provider tag
|
|
|
|
values["tags"] = map[string]any{
|
|
|
|
tc.config.GetProvider().String(): true,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add values that are only known after the cluster is created.
|
|
|
|
err = addInClusterValues(values, tc.config.GetProvider())
|
2022-11-21 04:35:40 -05:00
|
|
|
require.NoError(err)
|
|
|
|
|
|
|
|
// This step is needed to enabled/disable subcharts according to their tags/conditions.
|
|
|
|
err = chartutil.ProcessDependencies(chart, values)
|
2022-10-31 14:25:02 -04:00
|
|
|
require.NoError(err)
|
2022-11-21 04:35:40 -05:00
|
|
|
|
|
|
|
valuesToRender, err := chartutil.ToRenderValues(chart, values, options, caps)
|
|
|
|
require.NoError(err)
|
|
|
|
|
|
|
|
result, err := engine.Render(chart, valuesToRender)
|
|
|
|
require.NoError(err)
|
2022-11-30 11:27:08 -05:00
|
|
|
testDataPath := path.Join("testdata", tc.config.GetProvider().String(), "constellation-services")
|
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
// Build a map with the same structure as result: filepaths -> rendered template.
|
2022-11-30 11:27:08 -05:00
|
|
|
expectedData := map[string]string{}
|
|
|
|
err = filepath.Walk(testDataPath, buildTestdataMap(tc.config.GetProvider().String(), expectedData, require))
|
|
|
|
require.NoError(err)
|
|
|
|
|
|
|
|
compareMaps(expectedData, result, assert, require, t)
|
2022-11-21 04:35:40 -05:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TestOperators checks if the rendered constellation-services chart produces the expected yaml files.
|
|
|
|
func TestOperators(t *testing.T) {
|
|
|
|
testCases := map[string]struct {
|
|
|
|
csp cloudprovider.Provider
|
|
|
|
}{
|
|
|
|
"GCP": {
|
|
|
|
csp: cloudprovider.GCP,
|
|
|
|
},
|
|
|
|
"Azure": {
|
|
|
|
csp: cloudprovider.Azure,
|
|
|
|
},
|
|
|
|
"QEMU": {
|
|
|
|
csp: cloudprovider.QEMU,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for name, tc := range testCases {
|
|
|
|
t.Run(name, func(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
require := require.New(t)
|
|
|
|
|
2022-11-28 03:15:39 -05:00
|
|
|
chartLoader := ChartLoader{
|
2023-02-14 12:00:36 -05:00
|
|
|
csp: tc.csp,
|
2022-11-28 03:15:39 -05:00
|
|
|
joinServiceImage: "joinServiceImage",
|
2023-01-20 12:51:06 -05:00
|
|
|
keyServiceImage: "keyServiceImage",
|
2022-11-28 03:15:39 -05:00
|
|
|
ccmImage: "ccmImage",
|
|
|
|
cnmImage: "cnmImage",
|
|
|
|
autoscalerImage: "autoscalerImage",
|
|
|
|
constellationOperatorImage: "constellationOperatorImage",
|
|
|
|
nodeMaintenanceOperatorImage: "nodeMaintenanceOperatorImage",
|
|
|
|
}
|
2023-03-20 09:49:04 -04:00
|
|
|
chart, err := loadChartsDir(helmFS, constellationOperatorsInfo.path)
|
2022-12-19 10:52:15 -05:00
|
|
|
require.NoError(err)
|
2023-06-26 04:13:28 -04:00
|
|
|
vals := chartLoader.loadOperatorsValues()
|
2022-10-31 14:25:02 -04:00
|
|
|
|
|
|
|
options := chartutil.ReleaseOptions{
|
|
|
|
Name: "testRelease",
|
|
|
|
Namespace: "testNamespace",
|
|
|
|
Revision: 1,
|
|
|
|
IsInstall: true,
|
|
|
|
IsUpgrade: false,
|
|
|
|
}
|
|
|
|
caps := &chartutil.Capabilities{}
|
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
vals["tags"] = map[string]any{
|
|
|
|
tc.csp.String(): true,
|
|
|
|
}
|
2022-11-21 04:35:40 -05:00
|
|
|
conOpVals, ok := vals["constellation-operator"].(map[string]any)
|
|
|
|
require.True(ok)
|
|
|
|
conOpVals["constellationUID"] = "42424242424242"
|
2022-10-31 14:25:02 -04:00
|
|
|
|
2022-11-02 12:47:10 -04:00
|
|
|
// This step is needed to enabled/disable subcharts according to their tags/conditions.
|
2022-11-21 04:35:40 -05:00
|
|
|
err = chartutil.ProcessDependencies(chart, vals)
|
2022-11-02 12:47:10 -04:00
|
|
|
require.NoError(err)
|
|
|
|
|
2022-11-21 04:35:40 -05:00
|
|
|
valuesToRender, err := chartutil.ToRenderValues(chart, vals, options, caps)
|
2022-10-31 14:25:02 -04:00
|
|
|
require.NoError(err)
|
2022-11-02 12:47:10 -04:00
|
|
|
|
2022-10-31 14:25:02 -04:00
|
|
|
result, err := engine.Render(chart, valuesToRender)
|
|
|
|
require.NoError(err)
|
2022-11-30 11:27:08 -05:00
|
|
|
testDataPath := path.Join("testdata", tc.csp.String(), "constellation-operators")
|
|
|
|
|
|
|
|
// Build a map with the same structe as result: filepaths -> rendered template.
|
|
|
|
expectedData := map[string]string{}
|
|
|
|
err = filepath.Walk(testDataPath, buildTestdataMap(tc.csp.String(), expectedData, require))
|
|
|
|
require.NoError(err)
|
|
|
|
|
|
|
|
compareMaps(expectedData, result, assert, require, t)
|
2022-10-31 14:25:02 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-30 11:27:08 -05:00
|
|
|
// compareMaps ensures that both maps specify the same templates.
|
|
|
|
func compareMaps(expectedData map[string]string, result map[string]string, assert *assert.Assertions, require *require.Assertions, t *testing.T) {
|
|
|
|
// This whole block is only to produce useful error messages.
|
|
|
|
// It should allow a developer to see the missing template from just the error message.
|
|
|
|
if len(expectedData) > len(result) {
|
|
|
|
keys := getKeys(expectedData)
|
|
|
|
sort.Strings(keys)
|
|
|
|
t.Logf("expected these templates:\n%s", strings.Join(keys, "\n"))
|
|
|
|
|
|
|
|
keys = getKeys(result)
|
|
|
|
sort.Strings(keys)
|
|
|
|
t.Logf("got these templates:\n%s", strings.Join(keys, "\n"))
|
|
|
|
|
|
|
|
require.FailNow("missing templates in results.")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Walk the map and compare each result with it's expected render.
|
|
|
|
// Results where the expected-file is missing are errors.
|
|
|
|
for k, actualTemplates := range result {
|
|
|
|
if len(strings.TrimSpace(actualTemplates)) == 0 {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
// testify has an issue where when multiple documents are contained in one YAML string,
|
|
|
|
// only the first document is parsed [1]. For this reason we split the YAML string
|
|
|
|
// into a slice of strings, each entry containing one document.
|
|
|
|
// [1] https://github.com/stretchr/testify/issues/1281
|
|
|
|
renderedTemplates, ok := expectedData[k]
|
|
|
|
require.True(ok, fmt.Sprintf("unexpected render in results, missing file with expected data: %s len: %d", k, len(actualTemplates)))
|
|
|
|
expectedSplit := strings.Split(renderedTemplates, "\n---\n")
|
|
|
|
sort.Strings(expectedSplit)
|
|
|
|
actualSplit := strings.Split(actualTemplates, "\n---\n")
|
|
|
|
sort.Strings(actualSplit)
|
|
|
|
require.Equal(len(expectedSplit), len(actualSplit))
|
|
|
|
|
|
|
|
for i := range expectedSplit {
|
|
|
|
assert.YAMLEq(expectedSplit[i], actualSplit[i], fmt.Sprintf("current file: %s", k))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func getKeys(input map[string]string) []string {
|
|
|
|
keys := []string{}
|
|
|
|
for k := range input {
|
|
|
|
keys = append(keys, k)
|
|
|
|
}
|
|
|
|
return keys
|
|
|
|
}
|
|
|
|
|
|
|
|
func buildTestdataMap(csp string, expectedData map[string]string, require *require.Assertions) func(path string, info fs.FileInfo, err error) error {
|
|
|
|
return func(currentPath string, _ os.FileInfo, err error) error {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if !strings.HasSuffix(currentPath, ".yaml") {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
_, after, _ := strings.Cut(currentPath, "testdata/"+csp+"/")
|
|
|
|
|
|
|
|
data, err := os.ReadFile(currentPath)
|
|
|
|
require.NoError(err)
|
|
|
|
_, ok := expectedData[after]
|
|
|
|
require.False(ok, "read same path twice during expected data collection.")
|
|
|
|
expectedData[after] = string(data)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
// addInClusterValues adds values that are only known after the cluster is created.
|
|
|
|
func addInClusterValues(values map[string]any, csp cloudprovider.Provider) error {
|
2023-03-17 04:53:22 -04:00
|
|
|
joinVals, ok := values["join-service"].(map[string]any)
|
|
|
|
if !ok {
|
|
|
|
return errors.New("missing 'join-service' key")
|
|
|
|
}
|
2023-05-03 05:11:53 -04:00
|
|
|
|
2023-03-17 04:53:22 -04:00
|
|
|
joinVals["measurementSalt"] = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
|
|
|
|
2022-11-21 11:06:41 -05:00
|
|
|
verificationVals, ok := values["verification-service"].(map[string]any)
|
|
|
|
if !ok {
|
2023-01-20 12:51:06 -05:00
|
|
|
return fmt.Errorf("missing 'verification-service' key %v", values)
|
2022-11-21 11:06:41 -05:00
|
|
|
}
|
|
|
|
verificationVals["loadBalancerIP"] = "127.0.0.1"
|
2022-11-23 02:26:09 -05:00
|
|
|
|
|
|
|
konnectivityVals, ok := values["konnectivity"].(map[string]any)
|
|
|
|
if !ok {
|
|
|
|
return errors.New("missing 'konnectivity' key")
|
|
|
|
}
|
|
|
|
konnectivityVals["loadBalancerIP"] = "127.0.0.1"
|
|
|
|
|
2022-10-31 14:25:02 -04:00
|
|
|
ccmVals, ok := values["ccm"].(map[string]any)
|
|
|
|
if !ok {
|
|
|
|
return errors.New("missing 'ccm' key")
|
|
|
|
}
|
2022-11-23 02:26:09 -05:00
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
switch csp {
|
|
|
|
case cloudprovider.Azure:
|
|
|
|
ccmVals[cloudprovider.Azure.String()] = map[string]any{
|
|
|
|
"azureConfig": "baaaaaad",
|
|
|
|
}
|
2022-10-31 14:25:02 -04:00
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
autoscalerVals, ok := values["autoscaler"].(map[string]any)
|
|
|
|
if !ok {
|
|
|
|
return errors.New("missing 'autoscaler' key")
|
|
|
|
}
|
|
|
|
autoscalerVals["Azure"] = map[string]any{
|
|
|
|
"resourceGroup": "resourceGroup",
|
|
|
|
"subscriptionID": "subscriptionID",
|
|
|
|
"tenantID": "TenantID",
|
|
|
|
}
|
2022-10-31 14:25:02 -04:00
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
case cloudprovider.GCP:
|
|
|
|
ccmVals[cloudprovider.GCP.String()] = map[string]any{
|
|
|
|
"subnetworkPodCIDR": "192.0.2.0/24",
|
|
|
|
"projectID": "42424242424242",
|
|
|
|
"uid": "242424242424",
|
|
|
|
"secretData": "baaaaaad",
|
|
|
|
}
|
2022-11-21 11:06:41 -05:00
|
|
|
|
2023-06-26 04:13:28 -04:00
|
|
|
case cloudprovider.OpenStack:
|
|
|
|
ccmVals["OpenStack"] = map[string]any{
|
|
|
|
"secretData": "baaaaaad",
|
|
|
|
}
|
2022-11-23 02:26:09 -05:00
|
|
|
}
|
|
|
|
|
2022-10-31 14:25:02 -04:00
|
|
|
return nil
|
|
|
|
}
|
2023-03-14 06:46:27 -04:00
|
|
|
|
|
|
|
func toPtr[T any](v T) *T {
|
|
|
|
return &v
|
|
|
|
}
|