Skip to content

Commit

Permalink
fix linter errors from updating golint
Browse files Browse the repository at this point in the history
  • Loading branch information
tnthornton committed Sep 24, 2024
1 parent b9382a2 commit 1d3ccad
Show file tree
Hide file tree
Showing 25 changed files with 218 additions and 218 deletions.
4 changes: 2 additions & 2 deletions internal/cache/bbolt_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/rest"
toolscache "k8s.io/client-go/tools/cache"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
Expand Down Expand Up @@ -122,7 +122,7 @@ func WithBBoltCache(file string, opts ...Option) clients.NewCacheMiddlewareFn {
// set or wrap DefaultTransform.
o.DefaultTransform = wrapCacheTranform(o.DefaultTransform, bc.putObject)
// get undelying object from cache without copying.
o.DefaultUnsafeDisableDeepCopy = pointer.Bool(true)
o.DefaultUnsafeDisableDeepCopy = ptr.To(true)
// deep copy objects before returning by default.
bc.deepCopy = o.DefaultUnsafeDisableDeepCopy == nil || !*o.DefaultUnsafeDisableDeepCopy
ca, err := fn(cfg, o)
Expand Down
14 changes: 7 additions & 7 deletions internal/graph/model/apiextensions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
extv1 "github.com/crossplane/crossplane/apis/apiextensions/v1"
Expand Down Expand Up @@ -110,18 +110,18 @@ func TestGetCompositeResourceDefinition(t *testing.T) {
Group: "group",
Names: CompositeResourceDefinitionNames{
Plural: "clusterexamples",
Singular: pointer.String("clusterexample"),
Singular: ptr.To("clusterexample"),
ShortNames: []string{"cex"},
Kind: "ClusterExample",
ListKind: pointer.String("ClusterExampleList"),
ListKind: ptr.To("ClusterExampleList"),
Categories: []string{"example"},
},
ClaimNames: &CompositeResourceDefinitionNames{
Plural: "examples",
Singular: pointer.String("example"),
Singular: ptr.To("example"),
ShortNames: []string{"ex"},
Kind: "Example",
ListKind: pointer.String("ExampleList"),
ListKind: ptr.To("ExampleList"),
Categories: []string{"example"},
},
Versions: []CompositeResourceDefinitionVersion{{
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestGetComposition(t *testing.T) {
APIVersion: "group/v1",
Kind: "ClusterExample",
},
WriteConnectionSecretsToNamespace: pointer.String("ns"),
WriteConnectionSecretsToNamespace: ptr.To("ns"),
},
},
want: Composition{
Expand All @@ -215,7 +215,7 @@ func TestGetComposition(t *testing.T) {
APIVersion: "group/v1",
Kind: "ClusterExample",
},
WriteConnectionSecretsToNamespace: pointer.String("ns"),
WriteConnectionSecretsToNamespace: ptr.To("ns"),
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/graph/model/common.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"
kunstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/errors"
Expand Down Expand Up @@ -180,7 +180,7 @@ func GetSecret(s *corev1.Secret) Secret {
}

if s.Type != "" {
out.Type = pointer.String(string(s.Type))
out.Type = ptr.To(string(s.Type))
}

return out
Expand Down
14 changes: 7 additions & 7 deletions internal/graph/model/common_test.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"
kunstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
kschema "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/test"
Expand All @@ -51,7 +51,7 @@ func TestGetConditions(t *testing.T) {
Status: ConditionStatusTrue,
Reason: string(xpv1.ReasonAvailable),
LastTransitionTime: c.LastTransitionTime.Time,
Message: pointer.String("I'm here!"),
Message: ptr.To("I'm here!"),
}},
},
"Empty": {
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestGetSecret(t *testing.T) {
Metadata: ObjectMeta{
Name: "cool",
},
Type: pointer.String("cool"),
Type: ptr.To("cool"),
data: map[string]string{"cool": "secret"},
},
},
Expand Down Expand Up @@ -374,10 +374,10 @@ func TestGetCustomResourceDefinition(t *testing.T) {
Group: "group",
Names: CustomResourceDefinitionNames{
Plural: "clusterexamples",
Singular: pointer.String("clusterexample"),
Singular: ptr.To("clusterexample"),
ShortNames: []string{"cex"},
Kind: "ClusterExample",
ListKind: pointer.String("ClusterExampleList"),
ListKind: ptr.To("ClusterExampleList"),
Categories: []string{"example"},
},
Scope: ResourceScopeNamespaceScoped,
Expand All @@ -391,7 +391,7 @@ func TestGetCustomResourceDefinition(t *testing.T) {
Conditions: []Condition{{
Type: string(kextv1.Established),
Reason: "VeryCoolCRD",
Message: pointer.String("So cool"),
Message: ptr.To("So cool"),
// NOTE(tnthornton) transition is being truncated
// during marshaling.
LastTransitionTime: transition.Truncate(time.Second),
Expand Down Expand Up @@ -528,7 +528,7 @@ func TestGetKubernetesResource(t *testing.T) {
Name: "cool",
},
Metadata: ObjectMeta{
Namespace: pointer.String("default"),
Namespace: ptr.To("default"),
Name: "cool",
},
Spec: CompositeResourceClaimSpec{
Expand Down
4 changes: 2 additions & 2 deletions internal/graph/model/composite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kunstructured "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/resource/unstructured/claim"
Expand Down Expand Up @@ -152,7 +152,7 @@ func TestGetCompositeResourceClaim(t *testing.T) {
APIVersion: "example.org/v1",
Kind: "CompositeResource",
Metadata: ObjectMeta{
Namespace: pointer.String("default"),
Namespace: ptr.To("default"),
Name: "cool",
},
Spec: CompositeResourceClaimSpec{
Expand Down
8 changes: 4 additions & 4 deletions internal/graph/model/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package model

import (
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

// GetEventType from the supplied Kubernetes event type.
Expand Down Expand Up @@ -53,17 +53,17 @@ func GetEvent(e *corev1.Event) Event {
}

if e.Reason != "" {
out.Reason = pointer.String(e.Reason)
out.Reason = ptr.To(e.Reason)
}
if e.Message != "" {
out.Message = pointer.String(e.Message)
out.Message = ptr.To(e.Message)
}
if e.Count != 0 {
c := int(e.Count)
out.Count = &c
}
if e.Source.Component != "" {
out.Source = &EventSource{Component: pointer.String(e.Source.Component)}
out.Source = &EventSource{Component: ptr.To(e.Source.Component)}
}
ft := e.FirstTimestamp.Time
out.FirstTime = &ft
Expand Down
8 changes: 4 additions & 4 deletions internal/graph/model/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kschema "k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func TestGetEvent(t *testing.T) {
Expand Down Expand Up @@ -67,11 +67,11 @@ func TestGetEvent(t *testing.T) {
Name: "cool",
},
Type: &warn,
Reason: pointer.String("BadStuff"),
Message: pointer.String("Bad stuff happened."),
Reason: ptr.To("BadStuff"),
Message: ptr.To("Bad stuff happened."),
Count: func() *int { i := 42; return &i }(),
Source: &EventSource{
Component: pointer.String("that-thing"),
Component: ptr.To("that-thing"),
},
FirstTime: &now,
LastTime: &now,
Expand Down
8 changes: 4 additions & 4 deletions internal/graph/model/fieldpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
kextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

"github.com/upbound/xgql/internal/unstructured"
)
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestPavedAccess_FieldPath(t *testing.T) {
"Success": {
reason: "Returns value at fieldPath.",
args: args{
fieldPath: pointer.String("metadata.name"),
fieldPath: ptr.To("metadata.name"),
object: crd,
},
want: want{
Expand All @@ -118,7 +118,7 @@ func TestPavedAccess_FieldPath(t *testing.T) {
"Wildcard": {
reason: "Returns all values in expanded wildcard paths.",
args: args{
fieldPath: pointer.String("spec.status.conditions[*].reason"),
fieldPath: ptr.To("spec.status.conditions[*].reason"),
object: crd,
},
want: want{
Expand All @@ -128,7 +128,7 @@ func TestPavedAccess_FieldPath(t *testing.T) {
"WrongPath": {
reason: "Returns nil.",
args: args{
fieldPath: pointer.String("bad.field.path"),
fieldPath: ptr.To("bad.field.path"),
object: crd,
},
want: want{
Expand Down
6 changes: 3 additions & 3 deletions internal/graph/model/objectmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

// ObjectMeta that is common to all Kubernetes objects.
Expand Down Expand Up @@ -51,10 +51,10 @@ func GetObjectMeta(m metav1.Object) ObjectMeta {
}

if n := m.GetGenerateName(); n != "" {
om.GenerateName = pointer.String(n)
om.GenerateName = ptr.To(n)
}
if n := m.GetNamespace(); n != "" {
om.Namespace = pointer.String(n)
om.Namespace = ptr.To(n)
}
if t := m.GetDeletionTimestamp(); t != nil {
om.DeletionTime = &t.Time
Expand Down
6 changes: 3 additions & 3 deletions internal/graph/model/objectmeta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

func TestGetObjectMeta(t *testing.T) {
Expand Down Expand Up @@ -56,9 +56,9 @@ func TestGetObjectMeta(t *testing.T) {
return u
}(),
want: ObjectMeta{
Namespace: pointer.String("default"),
Namespace: ptr.To("default"),
Name: "cool-rando",
GenerateName: pointer.String("cool-"),
GenerateName: ptr.To("cool-"),
UID: "no-you-id",
ResourceVersion: "42",
Generation: 42,
Expand Down
Loading

0 comments on commit 1d3ccad

Please sign in to comment.