From ddc78486b6d43043a1a3f0ff589fa46996b49472 Mon Sep 17 00:00:00 2001 From: Matthew McNew Date: Mon, 27 Sep 2021 21:29:26 -0500 Subject: [PATCH] Migrate ServiceAccount to ServiceAccountName in v1alpha2 --- api/openapi-spec/swagger.json | 4 +- pkg/apis/build/v1alpha2/build.go | 2 +- pkg/apis/build/v1alpha2/build_conversion.go | 4 +- .../build/v1alpha2/build_conversion_test.go | 2 +- pkg/apis/build/v1alpha2/build_pod.go | 6 +- pkg/apis/build/v1alpha2/build_pod_test.go | 8 +-- pkg/apis/build/v1alpha2/build_types.go | 10 ++-- pkg/apis/build/v1alpha2/build_validation.go | 4 +- .../build/v1alpha2/build_validation_test.go | 6 +- pkg/apis/build/v1alpha2/image_builds.go | 6 +- pkg/apis/build/v1alpha2/image_builds_test.go | 10 ++-- pkg/apis/build/v1alpha2/image_conversion.go | 4 +- .../build/v1alpha2/image_conversion_test.go | 6 +- pkg/apis/build/v1alpha2/image_types.go | 2 +- pkg/apis/build/v1alpha2/image_validation.go | 4 +- .../build/v1alpha2/image_validation_test.go | 6 +- .../build/v1alpha2/source_resolver_types.go | 4 +- pkg/cnb/cnb_metadata.go | 4 +- pkg/cnb/cnb_metadata_test.go | 8 +-- pkg/git/resolver.go | 2 +- pkg/openapi/openapi_generated.go | 7 +-- pkg/reconciler/build/build_test.go | 4 +- pkg/reconciler/image/build_required_test.go | 14 ++--- pkg/reconciler/image/image_test.go | 60 +++++++++---------- .../sourceresolver/sourceresolver_test.go | 6 +- test/execute_build_test.go | 10 ++-- 26 files changed, 101 insertions(+), 102 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 05a022044..93708d446 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -5543,7 +5543,7 @@ "schedulerName": { "type": "string" }, - "serviceAccount": { + "serviceAccountName": { "type": "string" }, "services": { @@ -6260,7 +6260,7 @@ "projectDescriptorPath": { "type": "string" }, - "serviceAccount": { + "serviceAccountName": { "type": "string" }, "source": { diff --git a/pkg/apis/build/v1alpha2/build.go b/pkg/apis/build/v1alpha2/build.go index 980675996..18ae4a0ac 100644 --- a/pkg/apis/build/v1alpha2/build.go +++ b/pkg/apis/build/v1alpha2/build.go @@ -20,7 +20,7 @@ func (b *Build) Tag() string { } func (b *Build) ServiceAccount() string { - return b.Spec.ServiceAccount + return b.Spec.ServiceAccountName } func (b *Build) BuilderSpec() corev1alpha1.BuildBuilderSpec { diff --git a/pkg/apis/build/v1alpha2/build_conversion.go b/pkg/apis/build/v1alpha2/build_conversion.go index 92b1680a1..00dd29cb3 100644 --- a/pkg/apis/build/v1alpha2/build_conversion.go +++ b/pkg/apis/build/v1alpha2/build_conversion.go @@ -48,7 +48,7 @@ func (bs *BuildSpec) convertTo(to *v1alpha1.BuildSpec) { StackId: bs.LastBuild.StackId, } } - to.ServiceAccount = bs.ServiceAccount + to.ServiceAccount = bs.ServiceAccountName to.Builder = bs.Builder to.Notary = bs.Notary to.Bindings = bs.CNBBindings @@ -72,7 +72,7 @@ func (bs *BuildSpec) convertFrom(from *v1alpha1.BuildSpec) { StackId: from.LastBuild.StackId, } } - bs.ServiceAccount = from.ServiceAccount + bs.ServiceAccountName = from.ServiceAccount bs.Builder = from.Builder bs.Notary = from.Notary bs.CNBBindings = from.Bindings diff --git a/pkg/apis/build/v1alpha2/build_conversion_test.go b/pkg/apis/build/v1alpha2/build_conversion_test.go index 5890b29f8..2a719b112 100644 --- a/pkg/apis/build/v1alpha2/build_conversion_test.go +++ b/pkg/apis/build/v1alpha2/build_conversion_test.go @@ -32,7 +32,7 @@ func testBuildConversion(t *testing.T, when spec.G, it spec.S) { Name: "secret", }}, }, - ServiceAccount: "default", + ServiceAccountName: "default", Cache: &BuildCacheConfig{ Volume: &BuildPersistentVolumeCache{ ClaimName: "some-claim-name", diff --git a/pkg/apis/build/v1alpha2/build_pod.go b/pkg/apis/build/v1alpha2/build_pod.go index d7ef27042..620c1d2cb 100644 --- a/pkg/apis/build/v1alpha2/build_pod.go +++ b/pkg/apis/build/v1alpha2/build_pod.go @@ -440,7 +440,7 @@ func (b *Build) BuildPod(images BuildPodImages, secrets []corev1.Secret, config )..., ) }), - ServiceAccountName: b.Spec.ServiceAccount, + ServiceAccountName: b.Spec.ServiceAccountName, NodeSelector: b.nodeSelector(config.OS), Tolerations: b.Spec.Tolerations, Affinity: b.Spec.Affinity, @@ -586,7 +586,7 @@ func (b *Build) rebasePod(secrets []corev1.Secret, images BuildPodImages, config }, }, Spec: corev1.PodSpec{ - ServiceAccountName: b.Spec.ServiceAccount, + ServiceAccountName: b.Spec.ServiceAccountName, NodeSelector: b.nodeSelector("linux"), Tolerations: b.Spec.Tolerations, Affinity: b.Spec.Affinity, @@ -842,7 +842,7 @@ func setupBindingVolumesAndMounts(bindings []ServiceBinding) ([]corev1.Volume, [ ) } default: - return nil,nil, errors.Errorf("unsupported binding type: %T", b) + return nil, nil, errors.Errorf("unsupported binding type: %T", b) } } diff --git a/pkg/apis/build/v1alpha2/build_pod_test.go b/pkg/apis/build/v1alpha2/build_pod_test.go index bd716597d..c8cd05dd9 100644 --- a/pkg/apis/build/v1alpha2/build_pod_test.go +++ b/pkg/apis/build/v1alpha2/build_pod_test.go @@ -61,9 +61,9 @@ func testBuildPod(t *testing.T, when spec.G, it spec.S) { CreationTimestamp: metav1.Date(1944, 6, 6, 13, 30, 0, 0, time.UTC), }, Spec: buildapi.BuildSpec{ - Tags: []string{"someimage/name", "someimage/name:tag2", "someimage/name:tag3"}, - Builder: builderImageRef, - ServiceAccount: serviceAccount, + Tags: []string{"someimage/name", "someimage/name:tag2", "someimage/name:tag3"}, + Builder: builderImageRef, + ServiceAccountName: serviceAccount, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "giturl.com/git.git", @@ -1097,7 +1097,7 @@ func testBuildPod(t *testing.T, when spec.G, it spec.S) { }) require.Equal(t, corev1.PodSpec{ - ServiceAccountName: build.Spec.ServiceAccount, + ServiceAccountName: build.Spec.ServiceAccountName, NodeSelector: map[string]string{ "kubernetes.io/os": "linux", "foo": "bar", diff --git a/pkg/apis/build/v1alpha2/build_types.go b/pkg/apis/build/v1alpha2/build_types.go index cdaca8ddd..a7d0a116f 100644 --- a/pkg/apis/build/v1alpha2/build_types.go +++ b/pkg/apis/build/v1alpha2/build_types.go @@ -46,11 +46,11 @@ var ( // +k8s:openapi-gen=true type BuildSpec struct { // +listType - Tags []string `json:"tags,omitempty"` - Builder corev1alpha1.BuildBuilderSpec `json:"builder,omitempty"` - ServiceAccount string `json:"serviceAccount,omitempty"` - Source corev1alpha1.SourceConfig `json:"source"` - Cache *BuildCacheConfig `json:"cache,omitempty"` + Tags []string `json:"tags,omitempty"` + Builder corev1alpha1.BuildBuilderSpec `json:"builder,omitempty"` + ServiceAccountName string `json:"serviceAccountName,omitempty"` + Source corev1alpha1.SourceConfig `json:"source"` + Cache *BuildCacheConfig `json:"cache,omitempty"` // +listType Services Services `json:"services,omitempty"` // +listType diff --git a/pkg/apis/build/v1alpha2/build_validation.go b/pkg/apis/build/v1alpha2/build_validation.go index 65468dafe..1d5b7c644 100644 --- a/pkg/apis/build/v1alpha2/build_validation.go +++ b/pkg/apis/build/v1alpha2/build_validation.go @@ -15,8 +15,8 @@ import ( const kpackControllerServiceAccountUsername = "system:serviceaccount:kpack:controller" func (b *Build) SetDefaults(ctx context.Context) { - if b.Spec.ServiceAccount == "" { - b.Spec.ServiceAccount = "default" + if b.Spec.ServiceAccountName == "" { + b.Spec.ServiceAccountName = "default" } } diff --git a/pkg/apis/build/v1alpha2/build_validation_test.go b/pkg/apis/build/v1alpha2/build_validation_test.go index 07e3a4ee8..c467c29b4 100644 --- a/pkg/apis/build/v1alpha2/build_validation_test.go +++ b/pkg/apis/build/v1alpha2/build_validation_test.go @@ -29,7 +29,7 @@ func testBuildValidation(t *testing.T, when spec.G, it spec.S) { Image: "builder/bionic-builder@sha256:e431a4f94fb84854fd081da62762192f36fd093fdfb85ad3bc009b9309524e2d", ImagePullSecrets: nil, }, - ServiceAccount: "some/service-account", + ServiceAccountName: "some/service-account", Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "http://github.com/repo", @@ -47,11 +47,11 @@ func testBuildValidation(t *testing.T, when spec.G, it spec.S) { }) it("defaults service account to default", func() { - build.Spec.ServiceAccount = "" + build.Spec.ServiceAccountName = "" build.SetDefaults(context.TODO()) - assert.Equal(t, build.Spec.ServiceAccount, "default") + assert.Equal(t, build.Spec.ServiceAccountName, "default") }) }) diff --git a/pkg/apis/build/v1alpha2/image_builds.go b/pkg/apis/build/v1alpha2/image_builds.go index a0c4ee99b..73fa7568f 100644 --- a/pkg/apis/build/v1alpha2/image_builds.go +++ b/pkg/apis/build/v1alpha2/image_builds.go @@ -54,7 +54,7 @@ func (im *Image) Build(sourceResolver *SourceResolver, builder BuilderResource, Spec: BuildSpec{ Tags: im.generateTags(buildNumber), Builder: builder.BuildBuilderSpec(), - ServiceAccount: im.Spec.ServiceAccount, + ServiceAccountName: im.Spec.ServiceAccountName, Source: sourceResolver.SourceConfig(), Cache: im.getBuildCacheConfig(), Services: im.Services(), @@ -224,8 +224,8 @@ func (im *Image) SourceResolver() *SourceResolver { Labels: im.Labels, }, Spec: SourceResolverSpec{ - ServiceAccount: im.Spec.ServiceAccount, - Source: im.Spec.Source, + ServiceAccountName: im.Spec.ServiceAccountName, + Source: im.Spec.Source, }, } } diff --git a/pkg/apis/build/v1alpha2/image_builds_test.go b/pkg/apis/build/v1alpha2/image_builds_test.go index b3e44dc25..d0d2867be 100644 --- a/pkg/apis/build/v1alpha2/image_builds_test.go +++ b/pkg/apis/build/v1alpha2/image_builds_test.go @@ -29,8 +29,8 @@ func testImageBuilds(t *testing.T, when spec.G, it spec.S) { }, }, Spec: ImageSpec{ - Tag: "some/image", - ServiceAccount: "some/service-account", + Tag: "some/image", + ServiceAccountName: "some/service-account", Builder: corev1.ObjectReference{ Kind: "Builder", Name: "builder-name", @@ -67,9 +67,9 @@ func testImageBuilds(t *testing.T, when spec.G, it spec.S) { Name: "image-name", }, Spec: BuildSpec{ - Tags: []string{"some/image"}, - Builder: builder.BuildBuilderSpec(), - ServiceAccount: "some/serviceaccount", + Tags: []string{"some/image"}, + Builder: builder.BuildBuilderSpec(), + ServiceAccountName: "some/serviceaccount", }, Status: BuildStatus{ Status: corev1alpha1.Status{ diff --git a/pkg/apis/build/v1alpha2/image_conversion.go b/pkg/apis/build/v1alpha2/image_conversion.go index aec7017c2..02d22a505 100644 --- a/pkg/apis/build/v1alpha2/image_conversion.go +++ b/pkg/apis/build/v1alpha2/image_conversion.go @@ -37,7 +37,7 @@ func (i *Image) ConvertFrom(_ context.Context, from apis.Convertible) error { func (is *ImageSpec) convertTo(to *v1alpha1.ImageSpec) { to.Tag = is.Tag to.Builder = is.Builder - to.ServiceAccount = is.ServiceAccount + to.ServiceAccount = is.ServiceAccountName if is.Cache != nil && is.Cache.Volume != nil { to.CacheSize = is.Cache.Volume.Size } @@ -58,7 +58,7 @@ func (is *ImageSpec) convertTo(to *v1alpha1.ImageSpec) { func (is *ImageSpec) convertFrom(from *v1alpha1.ImageSpec) { is.Tag = from.Tag is.Builder = from.Builder - is.ServiceAccount = from.ServiceAccount + is.ServiceAccountName = from.ServiceAccount is.Source = from.Source if from.CacheSize != nil { is.Cache = &ImageCacheConfig{ diff --git a/pkg/apis/build/v1alpha2/image_conversion_test.go b/pkg/apis/build/v1alpha2/image_conversion_test.go index 3857c631f..8761c587a 100644 --- a/pkg/apis/build/v1alpha2/image_conversion_test.go +++ b/pkg/apis/build/v1alpha2/image_conversion_test.go @@ -28,9 +28,9 @@ func testImageConversion(t *testing.T, when spec.G, it spec.S) { Name: "my-super-convertable-image", }, Spec: ImageSpec{ - Tag: "my-tag", - Builder: corev1.ObjectReference{}, - ServiceAccount: "service-account", + Tag: "my-tag", + Builder: corev1.ObjectReference{}, + ServiceAccountName: "service-account", Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "https://my-github.com/git", diff --git a/pkg/apis/build/v1alpha2/image_types.go b/pkg/apis/build/v1alpha2/image_types.go index dd1f51885..fe19dac8d 100644 --- a/pkg/apis/build/v1alpha2/image_types.go +++ b/pkg/apis/build/v1alpha2/image_types.go @@ -42,7 +42,7 @@ type Image struct { type ImageSpec struct { Tag string `json:"tag"` Builder corev1.ObjectReference `json:"builder,omitempty"` - ServiceAccount string `json:"serviceAccount,omitempty"` + ServiceAccountName string `json:"serviceAccountName,omitempty"` Source corev1alpha1.SourceConfig `json:"source"` Cache *ImageCacheConfig `json:"cache,omitempty"` FailedBuildHistoryLimit *int64 `json:"failedBuildHistoryLimit,omitempty"` diff --git a/pkg/apis/build/v1alpha2/image_validation.go b/pkg/apis/build/v1alpha2/image_validation.go index b68cbf115..dd48d2378 100644 --- a/pkg/apis/build/v1alpha2/image_validation.go +++ b/pkg/apis/build/v1alpha2/image_validation.go @@ -33,8 +33,8 @@ func init() { } func (i *Image) SetDefaults(ctx context.Context) { - if i.Spec.ServiceAccount == "" { - i.Spec.ServiceAccount = "default" + if i.Spec.ServiceAccountName == "" { + i.Spec.ServiceAccountName = "default" } if i.Spec.ImageTaggingStrategy == "" { diff --git a/pkg/apis/build/v1alpha2/image_validation_test.go b/pkg/apis/build/v1alpha2/image_validation_test.go index ffbddb349..d6352a405 100644 --- a/pkg/apis/build/v1alpha2/image_validation_test.go +++ b/pkg/apis/build/v1alpha2/image_validation_test.go @@ -33,7 +33,7 @@ func testImageValidation(t *testing.T, when spec.G, it spec.S) { Kind: "ClusterBuilder", Name: "builder-name", }, - ServiceAccount: "some/service-account", + ServiceAccountName: "some/service-account", Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "http://github.com/repo", @@ -72,11 +72,11 @@ func testImageValidation(t *testing.T, when spec.G, it spec.S) { }) it("defaults service account to default", func() { - image.Spec.ServiceAccount = "" + image.Spec.ServiceAccountName = "" image.SetDefaults(ctx) - assert.Equal(t, image.Spec.ServiceAccount, "default") + assert.Equal(t, image.Spec.ServiceAccountName, "default") }) it("defaults ImageTaggingStrategy to BuildNumber", func() { diff --git a/pkg/apis/build/v1alpha2/source_resolver_types.go b/pkg/apis/build/v1alpha2/source_resolver_types.go index 9a1a8935f..6b8876293 100644 --- a/pkg/apis/build/v1alpha2/source_resolver_types.go +++ b/pkg/apis/build/v1alpha2/source_resolver_types.go @@ -20,8 +20,8 @@ type SourceResolver struct { // +k8s:openapi-gen=true type SourceResolverSpec struct { - ServiceAccount string `json:"serviceAccount,omitempty"` - Source corev1alpha1.SourceConfig `json:"source"` + ServiceAccountName string `json:"serviceAccount,omitempty"` + Source corev1alpha1.SourceConfig `json:"source"` } // +k8s:openapi-gen=true diff --git a/pkg/cnb/cnb_metadata.go b/pkg/cnb/cnb_metadata.go index 97cd97d64..df32925a3 100644 --- a/pkg/cnb/cnb_metadata.go +++ b/pkg/cnb/cnb_metadata.go @@ -38,7 +38,7 @@ type RemoteMetadataRetriever struct { func (r *RemoteMetadataRetriever) GetBuiltImage(ctx context.Context, build *buildapi.Build) (BuiltImage, error) { keychain, err := r.KeychainFactory.KeychainForSecretRef(ctx, registry.SecretRef{ - ServiceAccount: build.Spec.ServiceAccount, + ServiceAccount: build.Spec.ServiceAccountName, Namespace: build.Namespace, }) if err != nil { @@ -59,7 +59,7 @@ func (r *RemoteMetadataRetriever) GetCacheImage(ctx context.Context, build *buil } keychain, err := r.KeychainFactory.KeychainForSecretRef(ctx, registry.SecretRef{ - ServiceAccount: build.Spec.ServiceAccount, + ServiceAccount: build.Spec.ServiceAccountName, Namespace: build.Namespace, }) diff --git a/pkg/cnb/cnb_metadata_test.go b/pkg/cnb/cnb_metadata_test.go index 3c797048a..ab6c68ca4 100644 --- a/pkg/cnb/cnb_metadata_test.go +++ b/pkg/cnb/cnb_metadata_test.go @@ -36,8 +36,8 @@ func testMetadataRetriever(t *testing.T, when spec.G, it spec.S) { Namespace: "namespace-name", }, Spec: buildapi.BuildSpec{ - Tags: []string{"reg.io/appimage/name"}, - ServiceAccount: "service-account", + Tags: []string{"reg.io/appimage/name"}, + ServiceAccountName: "service-account", }, Status: buildapi.BuildStatus{}, } @@ -46,7 +46,7 @@ func testMetadataRetriever(t *testing.T, when spec.G, it spec.S) { it("retrieves the metadata from the registry", func() { appImageSecretRef := registry.SecretRef{ - ServiceAccount: build.Spec.ServiceAccount, + ServiceAccount: build.Spec.ServiceAccountName, Namespace: build.Namespace, } appImageKeychain := ®istryfakes.FakeKeychain{} @@ -101,7 +101,7 @@ func testMetadataRetriever(t *testing.T, when spec.G, it spec.S) { it("retrieves the metadata from the registry", func() { appImageSecretRef := registry.SecretRef{ - ServiceAccount: build.Spec.ServiceAccount, + ServiceAccount: build.Spec.ServiceAccountName, Namespace: build.Namespace, } appImageKeychain := ®istryfakes.FakeKeychain{} diff --git a/pkg/git/resolver.go b/pkg/git/resolver.go index a6bb518a9..948ffccbb 100644 --- a/pkg/git/resolver.go +++ b/pkg/git/resolver.go @@ -22,7 +22,7 @@ func NewResolver(k8sClient k8sclient.Interface) *Resolver { } func (r *Resolver) Resolve(ctx context.Context, sourceResolver *buildapi.SourceResolver) (corev1alpha1.ResolvedSourceConfig, error) { - keychain, err := r.gitKeychain.KeychainForServiceAccount(ctx, sourceResolver.Namespace, sourceResolver.Spec.ServiceAccount) + keychain, err := r.gitKeychain.KeychainForServiceAccount(ctx, sourceResolver.Namespace, sourceResolver.Spec.ServiceAccountName) if err != nil { return corev1alpha1.ResolvedSourceConfig{}, err } diff --git a/pkg/openapi/openapi_generated.go b/pkg/openapi/openapi_generated.go index 294a87369..e570cead9 100644 --- a/pkg/openapi/openapi_generated.go +++ b/pkg/openapi/openapi_generated.go @@ -1,4 +1,3 @@ -//go:build !ignore_autogenerated // +build !ignore_autogenerated /* @@ -2002,7 +2001,7 @@ func schema_pkg_apis_build_v1alpha2_BuildSpec(ref common.ReferenceCallback) comm Ref: ref("github.com/pivotal/kpack/pkg/apis/core/v1alpha1.BuildBuilderSpec"), }, }, - "serviceAccount": { + "serviceAccountName": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", @@ -3456,7 +3455,7 @@ func schema_pkg_apis_build_v1alpha2_ImageSpec(ref common.ReferenceCallback) comm Ref: ref("k8s.io/api/core/v1.ObjectReference"), }, }, - "serviceAccount": { + "serviceAccountName": { SchemaProps: spec.SchemaProps{ Type: []string{"string"}, Format: "", @@ -4247,7 +4246,7 @@ func schema_pkg_apis_core_v1alpha1_Condition(ref common.ReferenceCallback) commo "lastTransitionTime": { SchemaProps: spec.SchemaProps{ Description: "LastTransitionTime is the last time the condition transitioned from one status to another. We use VolatileTime in place of metav1.Time to exclude this from creating equality.Semantic differences (all other things held constant).", - Type: []string{"string"}, Format: "", + Type: []string{"string"}, Format: "", }, }, "reason": { diff --git a/pkg/reconciler/build/build_test.go b/pkg/reconciler/build/build_test.go index 30a74b249..1cb6d0e51 100644 --- a/pkg/reconciler/build/build_test.go +++ b/pkg/reconciler/build/build_test.go @@ -86,8 +86,8 @@ func testBuildReconciler(t *testing.T, when spec.G, it spec.S) { Generation: originalGeneration, }, Spec: buildapi.BuildSpec{ - Tags: []string{"someimage/name", "someimage/name:tag2", "someimage/name:tag3"}, - ServiceAccount: serviceAccountName, + Tags: []string{"someimage/name", "someimage/name:tag2", "someimage/name:tag3"}, + ServiceAccountName: serviceAccountName, Builder: corev1alpha1.BuildBuilderSpec{ Image: "somebuilder/123@sha256:12334563ad", ImagePullSecrets: []corev1.LocalObjectReference{ diff --git a/pkg/reconciler/image/build_required_test.go b/pkg/reconciler/image/build_required_test.go index 4b5999bcb..8ef66b1a8 100644 --- a/pkg/reconciler/image/build_required_test.go +++ b/pkg/reconciler/image/build_required_test.go @@ -32,8 +32,8 @@ func testImageBuilds(t *testing.T, when spec.G, it spec.S) { }, }, Spec: buildapi.ImageSpec{ - Tag: "some/image", - ServiceAccount: "some/service-account", + Tag: "some/image", + ServiceAccountName: "some/service-account", Builder: corev1.ObjectReference{ Kind: "Builder", Name: "builder-name", @@ -70,9 +70,9 @@ func testImageBuilds(t *testing.T, when spec.G, it spec.S) { Name: "image-name", }, Spec: buildapi.BuildSpec{ - Tags: []string{"some/image"}, - Builder: builder.BuildBuilderSpec(), - ServiceAccount: "some/serviceaccount", + Tags: []string{"some/image"}, + Builder: builder.BuildBuilderSpec(), + ServiceAccountName: "some/serviceaccount", }, Status: buildapi.BuildStatus{ Status: corev1alpha1.Status{ @@ -119,7 +119,7 @@ func testImageBuilds(t *testing.T, when spec.G, it spec.S) { }) it("false for different ServiceAccount", func() { - image.Spec.ServiceAccount = "different" + image.Spec.ServiceAccountName = "different" result, err := isBuildRequired(image, latestBuild, sourceResolver, builder) assert.NoError(t, err) @@ -218,7 +218,7 @@ func testImageBuilds(t *testing.T, when spec.G, it spec.S) { it("true if build cnb bindings changes", func() { latestBuild.Spec.CNBBindings = corev1alpha1.CNBBindings{ { - Name: "some-value", + Name: "some-value", }, } diff --git a/pkg/reconciler/image/image_test.go b/pkg/reconciler/image/image_test.go index 68ee6295c..cbae95269 100644 --- a/pkg/reconciler/image/image_test.go +++ b/pkg/reconciler/image/image_test.go @@ -91,7 +91,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Kind: "Builder", Name: builderName, }, - ServiceAccount: serviceAccount, + ServiceAccountName: serviceAccount, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "https://some.git/url", @@ -279,8 +279,8 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { }, }, Spec: buildapi.SourceResolverSpec{ - ServiceAccount: image.Spec.ServiceAccount, - Source: image.Spec.Source, + ServiceAccountName: image.Spec.ServiceAccountName, + Source: image.Spec.Source, }, }, }, @@ -317,7 +317,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { }, }, Spec: buildapi.SourceResolverSpec{ - ServiceAccount: "old-account", + ServiceAccountName: "old-account", Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "old-url", @@ -342,8 +342,8 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { }, }, Spec: buildapi.SourceResolverSpec{ - ServiceAccount: image.Spec.ServiceAccount, - Source: image.Spec.Source, + ServiceAccountName: image.Spec.ServiceAccountName, + Source: image.Spec.Source, }, }, }, @@ -379,8 +379,8 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { }, }, Spec: buildapi.SourceResolverSpec{ - ServiceAccount: image.Spec.ServiceAccount, - Source: image.Spec.Source, + ServiceAccountName: image.Spec.ServiceAccountName, + Source: image.Spec.Source, }, }, }, @@ -716,8 +716,8 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, - Cache: &buildapi.BuildCacheConfig{}, + ServiceAccountName: image.Spec.ServiceAccountName, + Cache: &buildapi.BuildCacheConfig{}, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -806,8 +806,8 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: clusterBuilder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, - Cache: &buildapi.BuildCacheConfig{}, + ServiceAccountName: image.Spec.ServiceAccountName, + Cache: &buildapi.BuildCacheConfig{}, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -896,8 +896,8 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, - Cache: &buildapi.BuildCacheConfig{}, + ServiceAccountName: image.Spec.ServiceAccountName, + Cache: &buildapi.BuildCacheConfig{}, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -987,8 +987,8 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: clusterBuilder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, - Cache: &buildapi.BuildCacheConfig{}, + ServiceAccountName: image.Spec.ServiceAccountName, + Cache: &buildapi.BuildCacheConfig{}, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -1080,7 +1080,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -1145,7 +1145,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: "old-service-account", + ServiceAccountName: "old-service-account", Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "out-of-date-git-url", @@ -1226,7 +1226,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -1302,7 +1302,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: image.Spec.Source.Git.URL, @@ -1352,7 +1352,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -1444,7 +1444,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: updatedBuilderImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -1512,7 +1512,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: updatedBuilderImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -1604,7 +1604,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: updatedBuilderImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -1667,7 +1667,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: updatedBuilderImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -1732,7 +1732,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: "old-service-account", + ServiceAccountName: "old-service-account", Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "out-of-date-git-url", @@ -1812,7 +1812,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -1876,7 +1876,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: "old-service-account", + ServiceAccountName: "old-service-account", Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "out-of-date-git-url", @@ -1931,7 +1931,7 @@ func testImageReconciler(t *testing.T, when spec.G, it spec.S) { Builder: corev1alpha1.BuildBuilderSpec{ Image: builder.Status.LatestImage, }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, @@ -2258,7 +2258,7 @@ func builds(image *buildapi.Image, sourceResolver *buildapi.SourceResolver, coun Builder: corev1alpha1.BuildBuilderSpec{ Image: "builder-image/foo@sha256:112312", }, - ServiceAccount: image.Spec.ServiceAccount, + ServiceAccountName: image.Spec.ServiceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: sourceResolver.Status.Source.Git.URL, diff --git a/pkg/reconciler/sourceresolver/sourceresolver_test.go b/pkg/reconciler/sourceresolver/sourceresolver_test.go index 921d58a03..439a93463 100644 --- a/pkg/reconciler/sourceresolver/sourceresolver_test.go +++ b/pkg/reconciler/sourceresolver/sourceresolver_test.go @@ -74,7 +74,7 @@ func testSourceResolver(t *testing.T, when spec.G, it spec.S) { Generation: originalGeneration, }, Spec: buildapi.SourceResolverSpec{ - ServiceAccount: serviceAccount, + ServiceAccountName: serviceAccount, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "https://github.com/build-me", @@ -332,7 +332,7 @@ func testSourceResolver(t *testing.T, when spec.G, it spec.S) { Generation: originalGeneration, }, Spec: buildapi.SourceResolverSpec{ - ServiceAccount: serviceAccount, + ServiceAccountName: serviceAccount, Source: corev1alpha1.SourceConfig{ Blob: &corev1alpha1.Blob{ URL: "https://some-blobstore.example.com/some-blob", @@ -397,7 +397,7 @@ func testSourceResolver(t *testing.T, when spec.G, it spec.S) { Generation: originalGeneration, }, Spec: buildapi.SourceResolverSpec{ - ServiceAccount: serviceAccount, + ServiceAccountName: serviceAccount, Source: corev1alpha1.SourceConfig{ Registry: &corev1alpha1.Registry{ Image: "some-registry.io/some-image@sha256:abcdef123456", diff --git a/test/execute_build_test.go b/test/execute_build_test.go index 76d626f22..0d4313628 100644 --- a/test/execute_build_test.go +++ b/test/execute_build_test.go @@ -337,10 +337,10 @@ func testCreateImage(t *testing.T, when spec.G, it spec.S) { Name: imageName, }, Spec: buildapi.ImageSpec{ - Tag: imageTag, - Builder: builder, - ServiceAccount: serviceAccountName, - Source: source, + Tag: imageTag, + Builder: builder, + ServiceAccountName: serviceAccountName, + Source: source, Cache: &buildapi.ImageCacheConfig{ Volume: &buildapi.ImagePersistentVolumeCache{ Size: &cacheSize, @@ -408,7 +408,7 @@ func generateRebuild(ctx *context.Context, t *testing.T, cfg config, clients *cl Kind: buildapi.ClusterBuilderKind, Name: clusterBuilderName, }, - ServiceAccount: serviceAccountName, + ServiceAccountName: serviceAccountName, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ URL: "https://github.com/cloudfoundry-samples/cf-sample-app-nodejs",