mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
Replace interface{} -> any (#370)
This commit is contained in:
parent
7592143a69
commit
2d121d9243
@ -53,7 +53,7 @@ func New(log *logger.Logger) (*Client, error) {
|
||||
}
|
||||
|
||||
// InstallConstellationServices installs the constellation-services chart. In the future this chart should bundle all microservices.
|
||||
func (h *Client) InstallConstellationServices(ctx context.Context, release helm.Release, extraVals map[string]interface{}) error {
|
||||
func (h *Client) InstallConstellationServices(ctx context.Context, release helm.Release, extraVals map[string]any) error {
|
||||
h.Namespace = constants.HelmNamespace
|
||||
h.ReleaseName = release.ReleaseName
|
||||
h.Wait = release.Wait
|
||||
@ -79,15 +79,15 @@ func (h *Client) InstallConstellationServices(ctx context.Context, release helm.
|
||||
|
||||
// mergeMaps returns a new map that is the merger of it's inputs.
|
||||
// Taken from: https://github.com/helm/helm/blob/dbc6d8e20fe1d58d50e6ed30f09a04a77e4c68db/pkg/cli/values/options.go#L91-L108.
|
||||
func mergeMaps(a, b map[string]interface{}) map[string]interface{} {
|
||||
out := make(map[string]interface{}, len(a))
|
||||
func mergeMaps(a, b map[string]any) map[string]any {
|
||||
out := make(map[string]any, len(a))
|
||||
for k, v := range a {
|
||||
out[k] = v
|
||||
}
|
||||
for k, v := range b {
|
||||
if v, ok := v.(map[string]interface{}); ok {
|
||||
if v, ok := v.(map[string]any); ok {
|
||||
if bv, ok := out[k]; ok {
|
||||
if bv, ok := bv.(map[string]interface{}); ok {
|
||||
if bv, ok := bv.(map[string]any); ok {
|
||||
out[k] = mergeMaps(bv, v)
|
||||
continue
|
||||
}
|
||||
@ -196,9 +196,9 @@ func (h *Client) installlCiliumGCP(ctx context.Context, kubectl k8sapi.Client, r
|
||||
|
||||
func (h *Client) installCiliumQEMU(ctx context.Context, release helm.Release, subnetworkPodCIDR, kubeAPIEndpoint string) error {
|
||||
// configure pod network CIDR
|
||||
release.Values["ipam"] = map[string]interface{}{
|
||||
"operator": map[string]interface{}{
|
||||
"clusterPoolIPv4PodCIDRList": []interface{}{
|
||||
release.Values["ipam"] = map[string]any{
|
||||
"operator": map[string]any{
|
||||
"clusterPoolIPv4PodCIDRList": []any{
|
||||
subnetworkPodCIDR,
|
||||
},
|
||||
},
|
||||
|
@ -14,25 +14,25 @@ import (
|
||||
|
||||
func TestMe(t *testing.T) {
|
||||
testCases := map[string]struct {
|
||||
vals map[string]interface{}
|
||||
extraVals map[string]interface{}
|
||||
expected map[string]interface{}
|
||||
vals map[string]any
|
||||
extraVals map[string]any
|
||||
expected map[string]any
|
||||
}{
|
||||
"equal": {
|
||||
vals: map[string]interface{}{
|
||||
"join-service": map[string]interface{}{
|
||||
vals: map[string]any{
|
||||
"join-service": map[string]any{
|
||||
"key1": "foo",
|
||||
"key2": "bar",
|
||||
},
|
||||
},
|
||||
extraVals: map[string]interface{}{
|
||||
"join-service": map[string]interface{}{
|
||||
extraVals: map[string]any{
|
||||
"join-service": map[string]any{
|
||||
"extraKey1": "extraFoo",
|
||||
"extraKey2": "extraBar",
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"join-service": map[string]interface{}{
|
||||
expected: map[string]any{
|
||||
"join-service": map[string]any{
|
||||
"key1": "foo",
|
||||
"key2": "bar",
|
||||
"extraKey1": "extraFoo",
|
||||
@ -41,18 +41,18 @@ func TestMe(t *testing.T) {
|
||||
},
|
||||
},
|
||||
"missing join-service extraVals": {
|
||||
vals: map[string]interface{}{
|
||||
"join-service": map[string]interface{}{
|
||||
vals: map[string]any{
|
||||
"join-service": map[string]any{
|
||||
"key1": "foo",
|
||||
"key2": "bar",
|
||||
},
|
||||
},
|
||||
extraVals: map[string]interface{}{
|
||||
extraVals: map[string]any{
|
||||
"extraKey1": "extraFoo",
|
||||
"extraKey2": "extraBar",
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
"join-service": map[string]interface{}{
|
||||
expected: map[string]any{
|
||||
"join-service": map[string]any{
|
||||
"key1": "foo",
|
||||
"key2": "bar",
|
||||
},
|
||||
@ -61,20 +61,20 @@ func TestMe(t *testing.T) {
|
||||
},
|
||||
},
|
||||
"missing join-service vals": {
|
||||
vals: map[string]interface{}{
|
||||
vals: map[string]any{
|
||||
"key1": "foo",
|
||||
"key2": "bar",
|
||||
},
|
||||
extraVals: map[string]interface{}{
|
||||
"join-service": map[string]interface{}{
|
||||
extraVals: map[string]any{
|
||||
"join-service": map[string]any{
|
||||
"extraKey1": "extraFoo",
|
||||
"extraKey2": "extraBar",
|
||||
},
|
||||
},
|
||||
expected: map[string]interface{}{
|
||||
expected: map[string]any{
|
||||
"key1": "foo",
|
||||
"key2": "bar",
|
||||
"join-service": map[string]interface{}{
|
||||
"join-service": map[string]any{
|
||||
"extraKey1": "extraFoo",
|
||||
"extraKey2": "extraBar",
|
||||
},
|
||||
|
@ -41,5 +41,5 @@ type clusterUtil interface {
|
||||
// Naming is inspired by Helm.
|
||||
type helmClient interface {
|
||||
InstallCilium(context.Context, k8sapi.Client, helm.Release, k8sapi.SetupPodNetworkInput) error
|
||||
InstallConstellationServices(ctx context.Context, release helm.Release, extraVals map[string]interface{}) error
|
||||
InstallConstellationServices(ctx context.Context, release helm.Release, extraVals map[string]any) error
|
||||
}
|
||||
|
@ -498,9 +498,9 @@ func getIPAddr() (string, error) {
|
||||
|
||||
// setupExtraVals create a helm values map for consumption by helm-install.
|
||||
// Will move to a more dedicated place once that place becomes apparent.
|
||||
func setupExtraVals(initialMeasurementsJSON []byte, idkeydigest []byte, measurementSalt []byte) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"join-service": map[string]interface{}{
|
||||
func setupExtraVals(initialMeasurementsJSON []byte, idkeydigest []byte, measurementSalt []byte) map[string]any {
|
||||
return map[string]any{
|
||||
"join-service": map[string]any{
|
||||
"measurements": string(initialMeasurementsJSON),
|
||||
"idkeydigest": hex.EncodeToString(idkeydigest),
|
||||
"measurementSalt": base64.StdEncoding.EncodeToString(measurementSalt),
|
||||
|
@ -684,6 +684,6 @@ func (s *stubHelmClient) InstallCilium(ctx context.Context, kubectl k8sapi.Clien
|
||||
return s.ciliumError
|
||||
}
|
||||
|
||||
func (s *stubHelmClient) InstallConstellationServices(ctx context.Context, release helm.Release, extraVals map[string]interface{}) error {
|
||||
func (s *stubHelmClient) InstallConstellationServices(ctx context.Context, release helm.Release, extraVals map[string]any) error {
|
||||
return s.servicesError
|
||||
}
|
||||
|
@ -124,8 +124,8 @@ func TestUpdateImage(t *testing.T) {
|
||||
"success": {
|
||||
updater: &stubImageUpdater{
|
||||
setImage: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"spec": map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"spec": map[string]any{
|
||||
"image": "old-image",
|
||||
},
|
||||
},
|
||||
@ -137,8 +137,8 @@ func TestUpdateImage(t *testing.T) {
|
||||
"image is the same": {
|
||||
updater: &stubImageUpdater{
|
||||
setImage: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"spec": map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"spec": map[string]any{
|
||||
"image": "old-image",
|
||||
},
|
||||
},
|
||||
@ -153,8 +153,8 @@ func TestUpdateImage(t *testing.T) {
|
||||
"update error": {
|
||||
updater: &stubImageUpdater{
|
||||
setImage: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"spec": map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"spec": map[string]any{
|
||||
"image": "old-image",
|
||||
},
|
||||
},
|
||||
@ -167,7 +167,7 @@ func TestUpdateImage(t *testing.T) {
|
||||
"no spec": {
|
||||
updater: &stubImageUpdater{
|
||||
setImage: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{},
|
||||
Object: map[string]any{},
|
||||
},
|
||||
},
|
||||
newImage: "new-image",
|
||||
@ -176,7 +176,7 @@ func TestUpdateImage(t *testing.T) {
|
||||
"not a map": {
|
||||
updater: &stubImageUpdater{
|
||||
setImage: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"spec": "not a map",
|
||||
},
|
||||
},
|
||||
@ -187,8 +187,8 @@ func TestUpdateImage(t *testing.T) {
|
||||
"no spec.image": {
|
||||
updater: &stubImageUpdater{
|
||||
setImage: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"spec": map[string]interface{}{},
|
||||
Object: map[string]any{
|
||||
"spec": map[string]any{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -215,7 +215,7 @@ func TestUpdateImage(t *testing.T) {
|
||||
|
||||
assert.NoError(err)
|
||||
if tc.wantUpdate {
|
||||
assert.Equal(tc.newImage, tc.updater.updatedImage.Object["spec"].(map[string]interface{})["image"])
|
||||
assert.Equal(tc.newImage, tc.updater.updatedImage.Object["spec"].(map[string]any)["image"])
|
||||
} else {
|
||||
assert.Nil(tc.updater.updatedImage)
|
||||
}
|
||||
|
@ -190,9 +190,9 @@ type warnLogger struct {
|
||||
}
|
||||
|
||||
// Infof is a no-op since we don't want extra info messages when using the CLI.
|
||||
func (wl warnLogger) Infof(format string, args ...interface{}) {}
|
||||
func (wl warnLogger) Infof(format string, args ...any) {}
|
||||
|
||||
// Warnf prints a formatted warning from the validator.
|
||||
func (wl warnLogger) Warnf(fmtStr string, args ...interface{}) {
|
||||
func (wl warnLogger) Warnf(fmtStr string, args ...any) {
|
||||
wl.cmd.PrintErrf("Warning: %s\n", fmt.Sprintf(fmtStr, args...))
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ func TestUpgradePlan(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func mustMarshal(t *testing.T, v interface{}) []byte {
|
||||
func mustMarshal(t *testing.T, v any) []byte {
|
||||
t.Helper()
|
||||
b, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
|
@ -66,7 +66,7 @@ func (i *ChartLoader) loadCilium(csp cloudprovider.Provider, conformanceMode boo
|
||||
return helm.Release{}, fmt.Errorf("packaging chart: %w", err)
|
||||
}
|
||||
|
||||
var ciliumVals map[string]interface{}
|
||||
var ciliumVals map[string]any
|
||||
switch csp {
|
||||
case cloudprovider.GCP:
|
||||
ciliumVals = gcpVals
|
||||
@ -81,7 +81,7 @@ func (i *ChartLoader) loadCilium(csp cloudprovider.Provider, conformanceMode boo
|
||||
ciliumVals["kubeProxyReplacementHealthzBindAddr"] = ""
|
||||
ciliumVals["kubeProxyReplacement"] = "partial"
|
||||
ciliumVals["sessionAffinity"] = true
|
||||
ciliumVals["cni"] = map[string]interface{}{
|
||||
ciliumVals["cni"] = map[string]any{
|
||||
"chainingMode": "portmap",
|
||||
}
|
||||
|
||||
@ -107,15 +107,15 @@ func (i *ChartLoader) loadConstellationServices(csp cloudprovider.Provider, mast
|
||||
return helm.Release{}, fmt.Errorf("marshaling enforcedPCRs: %w", err)
|
||||
}
|
||||
|
||||
vals := map[string]interface{}{
|
||||
"global": map[string]interface{}{
|
||||
vals := map[string]any{
|
||||
"global": map[string]any{
|
||||
"kmsPort": constants.KMSPort,
|
||||
"serviceBasePath": constants.ServiceBasePath,
|
||||
"joinConfigCMName": constants.JoinConfigMap,
|
||||
"k8sVersionCMName": constants.K8sVersion,
|
||||
"internalCMName": constants.InternalConfigMap,
|
||||
},
|
||||
"kms": map[string]interface{}{
|
||||
"kms": map[string]any{
|
||||
"image": versions.KmsImage,
|
||||
"masterSecret": base64.StdEncoding.EncodeToString(masterSecret),
|
||||
"salt": base64.StdEncoding.EncodeToString(salt),
|
||||
@ -125,7 +125,7 @@ func (i *ChartLoader) loadConstellationServices(csp cloudprovider.Provider, mast
|
||||
"masterSecretName": constants.ConstellationMasterSecretStoreName,
|
||||
"measurementsFilename": constants.MeasurementsFilename,
|
||||
},
|
||||
"join-service": map[string]interface{}{
|
||||
"join-service": map[string]any{
|
||||
"csp": csp,
|
||||
"enforcedPCRs": string(enforcedPCRsJSON),
|
||||
"image": versions.JoinImage,
|
||||
|
@ -6,32 +6,32 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
package helm
|
||||
|
||||
var azureVals = map[string]interface{}{
|
||||
"endpointRoutes": map[string]interface{}{
|
||||
var azureVals = map[string]any{
|
||||
"endpointRoutes": map[string]any{
|
||||
"enabled": true,
|
||||
},
|
||||
"encryption": map[string]interface{}{
|
||||
"encryption": map[string]any{
|
||||
"enabled": true,
|
||||
"type": "wireguard",
|
||||
},
|
||||
"l7Proxy": false,
|
||||
"ipam": map[string]interface{}{
|
||||
"operator": map[string]interface{}{
|
||||
"ipam": map[string]any{
|
||||
"operator": map[string]any{
|
||||
"clusterPoolIPv4PodCIDRList": []string{
|
||||
"10.244.0.0/16",
|
||||
},
|
||||
},
|
||||
},
|
||||
"strictModeCIDR": "10.244.0.0/16",
|
||||
"image": map[string]interface{}{
|
||||
"image": map[string]any{
|
||||
"repository": "ghcr.io/3u13r/cilium",
|
||||
"suffix": "",
|
||||
"tag": "v1.12.1-edg",
|
||||
"digest": "sha256:fdac430143fe719331698b76fbe66410631a21afd3405407d56db260d2d6999b",
|
||||
"useDigest": true,
|
||||
},
|
||||
"operator": map[string]interface{}{
|
||||
"image": map[string]interface{}{
|
||||
"operator": map[string]any{
|
||||
"image": map[string]any{
|
||||
"repository": "ghcr.io/3u13r/operator",
|
||||
"tag": "v1.12.1-edg",
|
||||
"suffix": "",
|
||||
@ -46,24 +46,24 @@ var azureVals = map[string]interface{}{
|
||||
"kubeProxyReplacementHealthzBindAddr": "0.0.0.0:10256",
|
||||
}
|
||||
|
||||
var gcpVals = map[string]interface{}{
|
||||
"endpointRoutes": map[string]interface{}{
|
||||
var gcpVals = map[string]any{
|
||||
"endpointRoutes": map[string]any{
|
||||
"enabled": true,
|
||||
},
|
||||
"tunnel": "disabled",
|
||||
"encryption": map[string]interface{}{
|
||||
"encryption": map[string]any{
|
||||
"enabled": true,
|
||||
"type": "wireguard",
|
||||
},
|
||||
"image": map[string]interface{}{
|
||||
"image": map[string]any{
|
||||
"repository": "ghcr.io/3u13r/cilium",
|
||||
"suffix": "",
|
||||
"tag": "v1.12.1-edg",
|
||||
"digest": "sha256:fdac430143fe719331698b76fbe66410631a21afd3405407d56db260d2d6999b",
|
||||
"useDigest": true,
|
||||
},
|
||||
"operator": map[string]interface{}{
|
||||
"image": map[string]interface{}{
|
||||
"operator": map[string]any{
|
||||
"image": map[string]any{
|
||||
"repository": "ghcr.io/3u13r/operator",
|
||||
"suffix": "",
|
||||
"tag": "v1.12.1-edg",
|
||||
@ -72,7 +72,7 @@ var gcpVals = map[string]interface{}{
|
||||
},
|
||||
},
|
||||
"l7Proxy": false,
|
||||
"ipam": map[string]interface{}{
|
||||
"ipam": map[string]any{
|
||||
"mode": "kubernetes",
|
||||
},
|
||||
"kubeProxyReplacement": "strict",
|
||||
@ -80,23 +80,23 @@ var gcpVals = map[string]interface{}{
|
||||
"kubeProxyReplacementHealthzBindAddr": "0.0.0.0:10256",
|
||||
}
|
||||
|
||||
var qemuVals = map[string]interface{}{
|
||||
"endpointRoutes": map[string]interface{}{
|
||||
var qemuVals = map[string]any{
|
||||
"endpointRoutes": map[string]any{
|
||||
"enabled": true,
|
||||
},
|
||||
"encryption": map[string]interface{}{
|
||||
"encryption": map[string]any{
|
||||
"enabled": true,
|
||||
"type": "wireguard",
|
||||
},
|
||||
"image": map[string]interface{}{
|
||||
"image": map[string]any{
|
||||
"repository": "ghcr.io/3u13r/cilium",
|
||||
"suffix": "",
|
||||
"tag": "v1.12.1-edg",
|
||||
"digest": "sha256:fdac430143fe719331698b76fbe66410631a21afd3405407d56db260d2d6999b",
|
||||
"useDigest": true,
|
||||
},
|
||||
"operator": map[string]interface{}{
|
||||
"image": map[string]interface{}{
|
||||
"operator": map[string]any{
|
||||
"image": map[string]any{
|
||||
"repository": "ghcr.io/3u13r/operator",
|
||||
"suffix": "",
|
||||
"tag": "v1.12.1-edg",
|
||||
|
@ -213,7 +213,7 @@ func (v *QEMUVariables) String() string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func writeLinef(builder *strings.Builder, format string, a ...interface{}) {
|
||||
func writeLinef(builder *strings.Builder, format string, a ...any) {
|
||||
builder.WriteString(fmt.Sprintf(format, a...))
|
||||
builder.WriteByte('\n')
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ var _ yaml.Marshaler = Measurements{}
|
||||
|
||||
// MarshalYAML forces that measurements are written as base64. Default would
|
||||
// be to print list of bytes.
|
||||
func (m Measurements) MarshalYAML() (interface{}, error) {
|
||||
func (m Measurements) MarshalYAML() (any, error) {
|
||||
base64Map := make(map[uint32]string)
|
||||
|
||||
for key, value := range m {
|
||||
|
@ -364,7 +364,7 @@ func TestExportPCRs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func mustMarshal(t *testing.T, v interface{}) string {
|
||||
func mustMarshal(t *testing.T, v any) string {
|
||||
t.Helper()
|
||||
b, err := json.Marshal(v)
|
||||
require.NoError(t, err)
|
||||
|
@ -65,8 +65,8 @@ type (
|
||||
|
||||
// AttestationLogger is a logger used to print warnings and infos during attestation validation.
|
||||
type AttestationLogger interface {
|
||||
Infof(format string, args ...interface{})
|
||||
Warnf(format string, args ...interface{})
|
||||
Infof(format string, args ...any)
|
||||
Warnf(format string, args ...any)
|
||||
}
|
||||
|
||||
// AttestationDocument contains the TPM attestation with signed user data.
|
||||
|
@ -406,10 +406,10 @@ type testAttestationLogger struct {
|
||||
warnings []string
|
||||
}
|
||||
|
||||
func (w *testAttestationLogger) Infof(format string, args ...interface{}) {
|
||||
func (w *testAttestationLogger) Infof(format string, args ...any) {
|
||||
w.infos = append(w.infos, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
||||
func (w *testAttestationLogger) Warnf(format string, args ...interface{}) {
|
||||
func (w *testAttestationLogger) Warnf(format string, args ...any) {
|
||||
w.warnings = append(w.warnings, fmt.Sprintf(format, args...))
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ func (m Measurements) CopyFrom(other Measurements) {
|
||||
|
||||
// MarshalYAML overwrites the default behaviour of writing out []byte not as
|
||||
// single bytes, but as a single base64 encoded string.
|
||||
func (m Measurements) MarshalYAML() (interface{}, error) {
|
||||
func (m Measurements) MarshalYAML() (any, error) {
|
||||
base64Map := make(map[uint32]string)
|
||||
|
||||
for key, value := range m {
|
||||
@ -103,7 +103,7 @@ func (m Measurements) MarshalYAML() (interface{}, error) {
|
||||
|
||||
// UnmarshalYAML overwrites the default behaviour of reading []byte not as
|
||||
// single bytes, but as a single base64 encoded string.
|
||||
func (m *Measurements) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (m *Measurements) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
base64Map := make(map[uint32]string)
|
||||
err := unmarshal(base64Map)
|
||||
if err != nil {
|
||||
|
@ -117,7 +117,7 @@ func TestUnmarshalYAML(t *testing.T) {
|
||||
require := require.New(t)
|
||||
|
||||
var m Measurements
|
||||
err := m.UnmarshalYAML(func(i interface{}) error {
|
||||
err := m.UnmarshalYAML(func(i any) error {
|
||||
if base64Map, ok := i.(map[uint32]string); ok {
|
||||
for key, value := range tc.inputBase64Map {
|
||||
base64Map[key] = value
|
||||
|
@ -9,7 +9,7 @@ package helm
|
||||
// Release bundles all information necessary to create a helm release.
|
||||
type Release struct {
|
||||
Chart []byte
|
||||
Values map[string]interface{}
|
||||
Values map[string]any
|
||||
ReleaseName string
|
||||
Wait bool
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user