From 060faae528a4a619721e4869328abe909b7864d2 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Tue, 28 Feb 2023 12:44:21 -0500 Subject: [PATCH] config: use toPtr func to get pointers (#1287) Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- internal/config/config.go | 18 +++++++++++------- internal/config/config_test.go | 4 ---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index 515b61ed8..90583b94b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -282,7 +282,7 @@ func Default() *Config { MicroserviceVersion: compatibility.EnsurePrefixV(constants.VersionInfo), KubernetesVersion: string(versions.Default), StateDiskSizeGB: 30, - DebugCluster: func() *bool { b := false; return &b }(), + DebugCluster: toPtr(false), Provider: ProviderConfig{ AWS: &AWSConfig{ Region: "", @@ -300,11 +300,11 @@ func Default() *Config { ResourceGroup: "", InstanceType: "Standard_DC4as_v5", StateDiskType: "Premium_LRS", - DeployCSIDriver: func() *bool { b := true; return &b }(), + DeployCSIDriver: toPtr(true), IDKeyDigest: idkeydigest.DefaultsFor(cloudprovider.Azure), - EnforceIDKeyDigest: func() *bool { b := true; return &b }(), - ConfidentialVM: func() *bool { b := true; return &b }(), - SecureBoot: func() *bool { b := false; return &b }(), + EnforceIDKeyDigest: toPtr(true), + ConfidentialVM: toPtr(true), + SecureBoot: toPtr(false), Measurements: measurements.DefaultsFor(cloudprovider.Azure), }, GCP: &GCPConfig{ @@ -314,11 +314,11 @@ func Default() *Config { ServiceAccountKeyPath: "", InstanceType: "n2d-standard-4", StateDiskType: "pd-ssd", - DeployCSIDriver: func() *bool { b := true; return &b }(), + DeployCSIDriver: toPtr(true), Measurements: measurements.DefaultsFor(cloudprovider.GCP), }, OpenStack: &OpenStackConfig{ - DirectDownload: func() *bool { b := true; return &b }(), + DirectDownload: toPtr(true), }, QEMU: &QEMUConfig{ ImageFormat: "raw", @@ -622,3 +622,7 @@ func (c *Config) Validate(force bool) error { return &ValidationError{validationErrMsgs: validationErrMsgs} } + +func toPtr[T any](v T) *T { + return &v +} diff --git a/internal/config/config_test.go b/internal/config/config_test.go index c78c6c611..f81b8b1aa 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -832,7 +832,3 @@ func TestConfigVersionCompatibility(t *testing.T) { }) } } - -func toPtr[T any](v T) *T { - return &v -}