Skip to content

Commit

Permalink
- fixing up the linting issues caused by the deprecation of pointer l…
Browse files Browse the repository at this point in the history
…ibrary
  • Loading branch information
gambol99 committed Dec 22, 2023
1 parent b0eba82 commit ec16856
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/terraform/v1alpha1/provider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/terraform/v1alpha1/revision_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/tnctl/create/configuration/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/tnctl/create/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/tnctl/verify/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/preload/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/handlers/cloudresources/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions pkg/handlers/contexts/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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())
}
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/server/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -64,15 +64,15 @@ 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:
for i := 0; i < len(o.Webhooks); i++ {
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:
Expand All @@ -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,
},
Expand Down
22 changes: 11 additions & 11 deletions pkg/utils/jobs/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand All @@ -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{
{
Expand All @@ -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),
},
},
},
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/revision.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"}`),
},
Expand Down

0 comments on commit ec16856

Please sign in to comment.