diff --git a/pkg/apis/terraform/v1alpha1/provider_types.go b/pkg/apis/terraform/v1alpha1/provider_types.go index 3c9581d47..e7a39557d 100644 --- a/pkg/apis/terraform/v1alpha1/provider_types.go +++ b/pkg/apis/terraform/v1alpha1/provider_types.go @@ -26,7 +26,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" corev1alpha1 "github.com/appvia/terranetes-controller/pkg/apis/core/v1alpha1" ) @@ -254,7 +254,7 @@ func (p *Provider) HasBackendTemplate() bool { // IsPreloadingEnabled returns true if the provider is enabled for preloading func (p *Provider) IsPreloadingEnabled() bool { - if p.Spec.Preload != nil && pointer.BoolDeref(p.Spec.Preload.Enabled, false) { + if p.Spec.Preload != nil && ptr.Deref(p.Spec.Preload.Enabled, false) { return true } diff --git a/pkg/apis/terraform/v1alpha1/revision_types.go b/pkg/apis/terraform/v1alpha1/revision_types.go index e106a5003..ae0c108de 100644 --- a/pkg/apis/terraform/v1alpha1/revision_types.go +++ b/pkg/apis/terraform/v1alpha1/revision_types.go @@ -24,7 +24,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" corev1alpha1 "github.com/appvia/terranetes-controller/pkg/apis/core/v1alpha1" ) @@ -77,7 +77,7 @@ func NewCloudResourceFromRevision(revision *Revision) (*CloudResource, error) { values := make(map[string]interface{}) for _, v := range revision.Spec.Inputs { if v.Default == nil { - if pointer.BoolDeref(v.Required, true) { + if ptr.Deref(v.Required, true) { values[v.Key] = "CHANGE_ME" } continue diff --git a/pkg/cmd/tnctl/create/configuration/build.go b/pkg/cmd/tnctl/create/configuration/build.go index 795e336a1..f9c79526a 100644 --- a/pkg/cmd/tnctl/create/configuration/build.go +++ b/pkg/cmd/tnctl/create/configuration/build.go @@ -33,7 +33,7 @@ import ( "github.com/tidwall/sjson" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/yaml" terraformv1alpha1 "github.com/appvia/terranetes-controller/pkg/apis/terraform/v1alpha1" @@ -194,7 +194,7 @@ func (o *Command) Run(ctx context.Context) error { } vf := terraformv1alpha1.ValueFromSource{} vf.Key = variable.Name - vf.Secret = pointer.String(answer) + vf.Secret = ptr.To(answer) configuration.Spec.ValueFrom = append(configuration.Spec.ValueFrom, vf) continue diff --git a/pkg/cmd/tnctl/create/revision.go b/pkg/cmd/tnctl/create/revision.go index 148a49fe9..44a678bda 100644 --- a/pkg/cmd/tnctl/create/revision.go +++ b/pkg/cmd/tnctl/create/revision.go @@ -28,7 +28,7 @@ import ( "github.com/fatih/color" "github.com/hashicorp/terraform-config-inspect/tfconfig" "github.com/spf13/cobra" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" terraformv1alpha1 "github.com/appvia/terranetes-controller/pkg/apis/terraform/v1alpha1" "github.com/appvia/terranetes-controller/pkg/cmd" @@ -366,7 +366,7 @@ func (o *RevisionCommand) retrieveInputs(module *tfconfig.Module) error { }) } else { o.ValueFrom = append(o.ValueFrom, terraformv1alpha1.ValueFromSource{ - Context: pointer.String(input.Context), + Context: ptr.To(input.Context), Key: input.Key, Name: variable.Name, }) diff --git a/pkg/cmd/tnctl/verify/revision.go b/pkg/cmd/tnctl/verify/revision.go index d8985e975..c360850d5 100644 --- a/pkg/cmd/tnctl/verify/revision.go +++ b/pkg/cmd/tnctl/verify/revision.go @@ -30,7 +30,7 @@ import ( "github.com/spf13/cobra" "github.com/tidwall/gjson" appsv1 "k8s.io/api/apps/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" terraformv1alpha1 "github.com/appvia/terranetes-controller/pkg/apis/terraform/v1alpha1" "github.com/appvia/terranetes-controller/pkg/cmd" @@ -398,7 +398,7 @@ func (o *RevisionCommand) checkRevisionInputs(revision *terraformv1alpha1.Revisi if input.Key == "" { v.Failed("Input (spec.inputs[%d].key) does not have a key defined", i) } - if input.Default == nil && pointer.BoolDeref(input.Required, false) { + if input.Default == nil && ptr.Deref(input.Required, false) { v.Warning("Input (spec.inputs[%d].default) does not have a default defined", i) } } diff --git a/pkg/controller/preload/ensure.go b/pkg/controller/preload/ensure.go index ebf4ef3e9..6dbf3c677 100644 --- a/pkg/controller/preload/ensure.go +++ b/pkg/controller/preload/ensure.go @@ -28,7 +28,7 @@ import ( batchv1 "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/yaml" @@ -204,7 +204,7 @@ func (c *Controller) ensurePreload(provider *terraformv1alpha1.Provider) control "Cloud": provider.Spec.Provider.String(), "Name": provider.Name, "SecretRef": provider.Spec.SecretRef, - "ServiceAccount": pointer.StringDeref(provider.Spec.ServiceAccount, ""), + "ServiceAccount": ptr.Deref(provider.Spec.ServiceAccount, ""), "Source": provider.Spec.Source, }, "Region": provider.Spec.Preload.Region, diff --git a/pkg/handlers/cloudresources/validation.go b/pkg/handlers/cloudresources/validation.go index 394c60fbd..6c1f1425a 100644 --- a/pkg/handlers/cloudresources/validation.go +++ b/pkg/handlers/cloudresources/validation.go @@ -26,7 +26,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" @@ -177,7 +177,7 @@ func validate(ctx context.Context, cc client.Client, o *terraformv1alpha1.CloudR // @step: now we need to ensure any variables defined in the revision are present for _, input := range rv.Spec.Inputs { - if pointer.BoolDeref(input.Required, false) && input.Default == nil { + if ptr.Deref(input.Required, false) && input.Default == nil { var found bool if o.Spec.HasVariables() { diff --git a/pkg/handlers/contexts/validation.go b/pkg/handlers/contexts/validation.go index c82b2c62d..1f0477207 100644 --- a/pkg/handlers/contexts/validation.go +++ b/pkg/handlers/contexts/validation.go @@ -25,7 +25,7 @@ import ( "strings" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" @@ -112,7 +112,7 @@ func (v *validator) ValidateDelete(ctx context.Context, obj runtime.Object) (adm for i := 0; i < len(list.Items); i++ { for _, x := range list.Items[i].Spec.ValueFrom { - if pointer.StringDeref(x.Context, "") == current.Name { + if ptr.Deref(x.Context, "") == current.Name { inuse = append(inuse, list.Items[i].GetNamespacedName().String()) } } diff --git a/pkg/server/webhooks.go b/pkg/server/webhooks.go index 7d474f815..8cbbd7533 100644 --- a/pkg/server/webhooks.go +++ b/pkg/server/webhooks.go @@ -24,7 +24,7 @@ import ( "os" admissionv1 "k8s.io/api/admissionregistration/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/appvia/terranetes-controller/pkg/register" @@ -64,7 +64,7 @@ func (s *Server) registerWebhooks(ctx context.Context) error { o.Webhooks[i].ClientConfig.CABundle = ca o.Webhooks[i].ClientConfig.Service.Namespace = os.Getenv("KUBE_NAMESPACE") o.Webhooks[i].ClientConfig.Service.Name = "controller" - o.Webhooks[i].ClientConfig.Service.Port = pointer.Int32(443) + o.Webhooks[i].ClientConfig.Service.Port = ptr.To(int32(443)) } case *admissionv1.MutatingWebhookConfiguration: @@ -72,7 +72,7 @@ func (s *Server) registerWebhooks(ctx context.Context) error { o.Webhooks[i].ClientConfig.CABundle = ca o.Webhooks[i].ClientConfig.Service.Namespace = os.Getenv("KUBE_NAMESPACE") o.Webhooks[i].ClientConfig.Service.Name = "controller" - o.Webhooks[i].ClientConfig.Service.Port = pointer.Int32(443) + o.Webhooks[i].ClientConfig.Service.Port = ptr.To(int32(443)) } default: @@ -97,8 +97,8 @@ func (s *Server) registerWebhooks(ctx context.Context) error { Service: &admissionv1.ServiceReference{ Name: "controller", Namespace: os.Getenv("KUBE_NAMESPACE"), - Path: pointer.String("/validate/terraform.appvia.io/namespaces"), - Port: pointer.Int32(443), + Path: ptr.To("/validate/terraform.appvia.io/namespaces"), + Port: ptr.To(int32(443)), }, CABundle: ca, }, diff --git a/pkg/utils/jobs/jobs.go b/pkg/utils/jobs/jobs.go index f9520b2b4..71ed601d4 100644 --- a/pkg/utils/jobs/jobs.go +++ b/pkg/utils/jobs/jobs.go @@ -26,7 +26,7 @@ import ( batchv1 "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/yaml" terraformv1alpha1 "github.com/appvia/terranetes-controller/pkg/apis/terraform/v1alpha1" @@ -117,10 +117,10 @@ func (r *Render) NewJobWatch(namespace, stage string, executorImage string) *bat }, }, Spec: batchv1.JobSpec{ - BackoffLimit: pointer.Int32(0), - Completions: pointer.Int32(1), - Parallelism: pointer.Int32(1), - TTLSecondsAfterFinished: pointer.Int32(3600), + BackoffLimit: ptr.To(int32(0)), + Completions: ptr.To(int32(1)), + Parallelism: ptr.To(int32(1)), + TTLSecondsAfterFinished: ptr.To(int32(3600)), Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: utils.MergeStringMaps(r.configuration.GetLabels(), map[string]string{ @@ -133,9 +133,9 @@ func (r *Render) NewJobWatch(namespace, stage string, executorImage string) *bat Spec: v1.PodSpec{ RestartPolicy: v1.RestartPolicyNever, SecurityContext: &v1.PodSecurityContext{ - RunAsGroup: pointer.Int64(65534), - RunAsNonRoot: pointer.Bool(true), - RunAsUser: pointer.Int64(65534), + RunAsGroup: ptr.To(int64(65534)), + RunAsNonRoot: ptr.To(true), + RunAsUser: ptr.To(int64(65534)), }, Containers: []v1.Container{ { @@ -145,9 +145,9 @@ func (r *Render) NewJobWatch(namespace, stage string, executorImage string) *bat Command: []string{"/watch_logs.sh"}, Args: []string{"-e", endpoint}, SecurityContext: &v1.SecurityContext{ - AllowPrivilegeEscalation: pointer.Bool(false), + AllowPrivilegeEscalation: ptr.To(false), Capabilities: &v1.Capabilities{Drop: []v1.Capability{"ALL"}}, - Privileged: pointer.Bool(false), + Privileged: ptr.To(false), }, }, }, @@ -202,7 +202,7 @@ func (r *Render) createTerraformFromTemplate(options Options, stage string) (*ba "Name": r.provider.Name, "Namespace": r.provider.Namespace, "SecretRef": r.provider.Spec.SecretRef, - "ServiceAccount": pointer.StringDeref(r.provider.Spec.ServiceAccount, ""), + "ServiceAccount": ptr.Deref(r.provider.Spec.ServiceAccount, ""), "Source": string(r.provider.Spec.Source), }, "EnableInfraCosts": options.EnableInfraCosts, diff --git a/test/fixtures/revision.go b/test/fixtures/revision.go index 6278d0d22..c357ddda7 100644 --- a/test/fixtures/revision.go +++ b/test/fixtures/revision.go @@ -20,7 +20,7 @@ package fixtures import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" corev1alpha1 "github.com/appvia/terranetes-controller/pkg/apis/core/v1alpha1" terraformv1alpha1 "github.com/appvia/terranetes-controller/pkg/apis/terraform/v1alpha1" @@ -81,7 +81,7 @@ func NewAWSBucketRevision(name string) *terraformv1alpha1.Revision { { Key: "bucket_name", Description: "The name of the bucket", - Required: pointer.Bool(true), + Required: ptr.To(true), Default: &runtime.RawExtension{ Raw: []byte(`{"value": "test"}`), },