Skip to content

Commit

Permalink
Merge pull request #1407 from qu1queee/qu1queee/utils_pointer_conflict
Browse files Browse the repository at this point in the history
Package k8s.io/utils/pointer conflict
  • Loading branch information
openshift-ci[bot] authored Oct 18, 2023
2 parents 2dac976 + 50a2216 commit 53e9df3
Show file tree
Hide file tree
Showing 43 changed files with 444 additions and 389 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
k8s.io/client-go v0.26.9
k8s.io/code-generator v0.26.9
k8s.io/kubectl v0.26.9
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
k8s.io/utils v0.0.0-20230209194617-a36077c30491
knative.dev/pkg v0.0.0-20230221145627-8efb3485adcf
sigs.k8s.io/controller-runtime v0.14.6
sigs.k8s.io/yaml v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -817,8 +817,8 @@ k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOG
k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a/go.mod h1:y5VtZWM9sHHc2ZodIH/6SHzXj+TPU5USoA8lcIeKEKY=
k8s.io/kubectl v0.26.9 h1:0Z8wEFQoXqWbWfT7G9si5EKVjYf5KG4hocSB7B8Jkbc=
k8s.io/kubectl v0.26.9/go.mod h1:Rl9W561iyUZtzwgstHcKChzUo2xMaGqb7Za6jUDMKP4=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY=
k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/pkg v0.0.0-20230221145627-8efb3485adcf h1:TwvZFDpkyqpK2OCAwvNGV2Zjk14FzIh8X8Ci/du3jYI=
knative.dev/pkg v0.0.0-20230221145627-8efb3485adcf/go.mod h1:VO/fcEsq43seuONRQxZyftWHjpMabYzRHDtpSEQ/eoQ=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/build/v1beta1/build_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/ptr"
"k8s.io/utils/pointer"
)

const (
Expand Down Expand Up @@ -90,7 +90,7 @@ func (src *Build) ConvertFrom(ctx context.Context, obj *unstructured.Unstructure
if src.Spec.Retention == nil {
src.Spec.Retention = &BuildRetention{}
}
src.Spec.Retention.AtBuildDeletion = ptr.To[bool](value == "true")
src.Spec.Retention.AtBuildDeletion = pointer.Bool(value == "true")
delete(src.ObjectMeta.Annotations, v1alpha1.AnnotationBuildRunDeletion)
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/build/v1beta1/buildrun_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/ptr"
"k8s.io/utils/pointer"
)

// ensure v1beta1 implements the Conversion interface
Expand Down Expand Up @@ -47,7 +47,7 @@ func (src *BuildRun) ConvertTo(ctx context.Context, obj *unstructured.Unstructur
if src.Spec.ServiceAccount != nil && *src.Spec.ServiceAccount == ".generate" {
alphaBuildRun.Spec.ServiceAccount = &v1alpha1.ServiceAccount{
Name: &src.ObjectMeta.Name,
Generate: ptr.To[bool](true),
Generate: pointer.Bool(true),
}
} else {
alphaBuildRun.Spec.ServiceAccount = &v1alpha1.ServiceAccount{
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/build/v1beta1/buildstrategy_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
runtime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/ptr"
"k8s.io/utils/pointer"
)

// ensure v1beta1 implements the Conversion interface
Expand Down Expand Up @@ -252,7 +252,7 @@ func (src *BuildStrategySpec) ConvertFrom(bs v1alpha1.BuildStrategySpec) {
Name: "dockerfile",
Description: "The Dockerfile to be built.",
Type: ParameterTypeString,
Default: ptr.To[string]("Dockerfile"),
Default: pointer.String("Dockerfile"),
})
}

Expand Down
14 changes: 7 additions & 7 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"
"k8s.io/utils/pointer"
)

const (
Expand Down Expand Up @@ -85,8 +85,8 @@ var (
metricBuildRunEstablishDurationBuckets = []float64{0, 1, 2, 3, 5, 7, 10, 15, 20, 30}
metricBuildRunRampUpDurationBuckets = prometheus.LinearBuckets(0, 1, 10)

root = ptr.To[int64](0)
nonRoot = ptr.To[int64](1000)
root = pointer.Int64(0)
nonRoot = pointer.Int64(1000)
)

// Config hosts different parameters that
Expand Down Expand Up @@ -162,7 +162,7 @@ func NewDefaultConfig() *Config {
},
},
SecurityContext: &corev1.SecurityContext{
AllowPrivilegeEscalation: ptr.To[bool](false),
AllowPrivilegeEscalation: pointer.Bool(false),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{
"ALL",
Expand All @@ -186,7 +186,7 @@ func NewDefaultConfig() *Config {
},
},
SecurityContext: &corev1.SecurityContext{
AllowPrivilegeEscalation: ptr.To[bool](false),
AllowPrivilegeEscalation: pointer.Bool(false),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{
"ALL",
Expand Down Expand Up @@ -214,7 +214,7 @@ func NewDefaultConfig() *Config {
// in all possible scenarios, we run this step as root with DAC_OVERRIDE
// capability.
SecurityContext: &corev1.SecurityContext{
AllowPrivilegeEscalation: ptr.To[bool](false),
AllowPrivilegeEscalation: pointer.Bool(false),
RunAsUser: root,
RunAsGroup: root,
Capabilities: &corev1.Capabilities{
Expand Down Expand Up @@ -244,7 +244,7 @@ func NewDefaultConfig() *Config {
},
},
SecurityContext: &corev1.SecurityContext{
AllowPrivilegeEscalation: ptr.To[bool](false),
AllowPrivilegeEscalation: pointer.Bool(false),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{
"ALL",
Expand Down
10 changes: 5 additions & 5 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
pipeline "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/utils/ptr"
"k8s.io/utils/pointer"

. "github.com/shipwright-io/build/pkg/config"
)
Expand Down Expand Up @@ -126,15 +126,15 @@ var _ = Describe("Config", func() {
}

configWithEnvVariableOverrides(overrides, func(config *Config) {
nonRoot := ptr.To[int64](1000)
nonRoot := pointer.Int64(1000)
Expect(config.GitContainerTemplate).To(Equal(pipeline.Step{
Image: "myregistry/custom/git-image",
Command: []string{
"/ko-app/git",
},
Env: []corev1.EnvVar{{Name: "HOME", Value: "/shared-home"}},
SecurityContext: &corev1.SecurityContext{
AllowPrivilegeEscalation: ptr.To[bool](false),
AllowPrivilegeEscalation: pointer.Bool(false),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{
"ALL",
Expand Down Expand Up @@ -228,14 +228,14 @@ var _ = Describe("Config", func() {
}

configWithEnvVariableOverrides(overrides, func(config *Config) {
nonRoot := ptr.To[int64](1000)
nonRoot := pointer.Int64(1000)
Expect(config.WaiterContainerTemplate).To(Equal(pipeline.Step{
Image: "myregistry/custom/image",
Command: []string{"/ko-app/waiter"},
Args: []string{"start"},
Env: []corev1.EnvVar{{Name: "HOME", Value: "/shared-home"}},
SecurityContext: &corev1.SecurityContext{
AllowPrivilegeEscalation: ptr.To[bool](false),
AllowPrivilegeEscalation: pointer.Bool(false),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{
"ALL",
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/ptr"
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -113,7 +113,7 @@ func (r *ReconcileBuild) Reconcile(ctx context.Context, request reconcile.Reques
}

b.Status.Registered = build.ConditionStatusPtr(corev1.ConditionTrue)
b.Status.Message = ptr.To[string](build.AllValidationsSucceeded)
b.Status.Message = pointer.String(build.AllValidationsSucceeded)
if err := r.client.Status().Update(ctx, b); err != nil {
return reconcile.Result{}, err
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/reconciler/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"
"k8s.io/utils/pointer"
crc "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -371,7 +371,7 @@ var _ = Describe("Reconcile Build", func() {
Context("when source URL is specified", func() {
// validate file protocol
It("fails when source URL is invalid", func() {
buildSample.Spec.Source.URL = ptr.To[string]("foobar")
buildSample.Spec.Source.URL = pointer.String("foobar")
buildSample.SetAnnotations(map[string]string{
build.AnnotationBuildVerifyRepository: "true",
})
Expand All @@ -385,7 +385,7 @@ var _ = Describe("Reconcile Build", func() {

// validate https protocol
It("fails when public source URL is unreachable", func() {
buildSample.Spec.Source.URL = ptr.To[string]("https://github.com/shipwright-io/sample-go-fake")
buildSample.Spec.Source.URL = pointer.String("https://github.com/shipwright-io/sample-go-fake")
buildSample.SetAnnotations(map[string]string{
build.AnnotationBuildVerifyRepository: "true",
})
Expand All @@ -400,7 +400,7 @@ var _ = Describe("Reconcile Build", func() {

// skip validation because of empty sourceURL annotation
It("succeed when source URL is invalid because source annotation is empty", func() {
buildSample.Spec.Source.URL = ptr.To[string]("foobar")
buildSample.Spec.Source.URL = pointer.String("foobar")

// Fake some client Get calls and ensure we populate all
// different resources we could get during reconciliation
Expand Down Expand Up @@ -451,7 +451,7 @@ var _ = Describe("Reconcile Build", func() {
// skip validation because build references a sourceURL secret
It("succeed when source URL is fake private URL because build reference a sourceURL secret", func() {
buildSample := ctl.BuildWithClusterBuildStrategyAndSourceSecret(buildName, namespace, buildStrategyName)
buildSample.Spec.Source.URL = ptr.To[string]("https://github.yourco.com/org/build-fake")
buildSample.Spec.Source.URL = pointer.String("https://github.yourco.com/org/build-fake")
buildSample.Spec.Source.Credentials.Name = registrySecret

// Fake some client Get calls and ensure we populate all
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/buildrun/buildrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/utils/ptr"
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -182,7 +182,7 @@ func (r *ReconcileBuildRun) Reconcile(ctx context.Context, request reconcile.Req
// mark transient build as "registered" and validated
build.Status.Registered = buildv1alpha1.ConditionStatusPtr(corev1.ConditionTrue)
build.Status.Reason = buildv1alpha1.BuildReasonPtr(buildv1alpha1.SucceedStatus)
build.Status.Message = ptr.To[string](buildv1alpha1.AllValidationsSucceeded)
build.Status.Message = pointer.String(buildv1alpha1.AllValidationsSucceeded)
}
}

Expand Down Expand Up @@ -220,7 +220,7 @@ func (r *ReconcileBuildRun) Reconcile(ctx context.Context, request reconcile.Req
if build.GetAnnotations()[buildv1alpha1.AnnotationBuildRunDeletion] == "true" && !resources.IsOwnedByBuild(build, buildRun.OwnerReferences) {
if err := r.setOwnerReferenceFunc(build, buildRun, r.scheme); err != nil {
build.Status.Reason = buildv1alpha1.BuildReasonPtr(buildv1alpha1.SetOwnerReferenceFailed)
build.Status.Message = ptr.To[string](fmt.Sprintf("unexpected error when trying to set the ownerreference: %v", err))
build.Status.Message = pointer.String(fmt.Sprintf("unexpected error when trying to set the ownerreference: %v", err))
if err := r.client.Status().Update(ctx, build); err != nil {
return reconcile.Result{}, err
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/reconciler/buildrun/buildrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/ptr"
"k8s.io/utils/pointer"
knativeapi "knative.dev/pkg/apis"
knativev1 "knative.dev/pkg/apis/duck/v1"
crc "sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -1177,8 +1177,8 @@ var _ = Describe("Reconcile BuildRun", func() {
// in the build
clientUpdateCalls := ctl.StubBuildUpdateOwnerReferences("Build",
buildName,
ptr.To[bool](true),
ptr.To[bool](true),
pointer.Bool(true),
pointer.Bool(true),
)
client.UpdateCalls(clientUpdateCalls)

Expand Down Expand Up @@ -1365,7 +1365,7 @@ var _ = Describe("Reconcile BuildRun", func() {
Spec: build.BuildRunSpec{
ParamValues: []build.ParamValue{{
Name: "foo",
SingleValue: &build.SingleValue{Value: ptr.To[string]("bar")},
SingleValue: &build.SingleValue{Value: pointer.String("bar")},
}},
BuildSpec: &build.BuildSpec{},
},
Expand Down Expand Up @@ -1421,8 +1421,8 @@ var _ = Describe("Reconcile BuildRun", func() {
Spec: build.BuildRunSpec{
BuildSpec: &build.BuildSpec{
Source: build.Source{
URL: ptr.To[string]("https://github.com/shipwright-io/sample-go.git"),
ContextDir: ptr.To[string]("source-build"),
URL: pointer.String("https://github.com/shipwright-io/sample-go.git"),
ContextDir: pointer.String("source-build"),
},
Strategy: build.Strategy{
Kind: &clusterBuildStrategy,
Expand All @@ -1433,7 +1433,7 @@ var _ = Describe("Reconcile BuildRun", func() {
},
},
ServiceAccount: &build.ServiceAccount{
Generate: ptr.To[bool](true),
Generate: pointer.Bool(true),
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/reconciler/buildrun/resources/credentials_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
. "github.com/onsi/gomega"

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

buildv1alpha1 "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
"github.com/shipwright-io/build/pkg/reconciler/buildrun/resources"
Expand All @@ -38,7 +38,7 @@ var _ = Describe("Credentials", func() {
build = &buildv1alpha1.Build{
Spec: buildv1alpha1.BuildSpec{
Source: buildv1alpha1.Source{
URL: ptr.To[string]("a/b/c"),
URL: pointer.String("a/b/c"),
Credentials: &corev1.LocalObjectReference{
Name: "secret_a",
},
Expand Down Expand Up @@ -94,7 +94,7 @@ var _ = Describe("Credentials", func() {
build = &buildv1alpha1.Build{
Spec: buildv1alpha1.BuildSpec{
Source: buildv1alpha1.Source{
URL: ptr.To[string]("a/b/c"),
URL: pointer.String("a/b/c"),
},
Output: buildv1alpha1.Image{
Credentials: &corev1.LocalObjectReference{
Expand Down Expand Up @@ -131,7 +131,7 @@ var _ = Describe("Credentials", func() {
build = &buildv1alpha1.Build{
Spec: buildv1alpha1.BuildSpec{
Source: buildv1alpha1.Source{
URL: ptr.To[string]("a/b/c"),
URL: pointer.String("a/b/c"),
Credentials: nil,
},
},
Expand Down
Loading

0 comments on commit 53e9df3

Please sign in to comment.