Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ServiceAccountName field on the Builder resource #861

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/apis/build/v1alpha2/builder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ type BuilderSpec struct {

// +k8s:openapi-gen=true
type NamespacedBuilderSpec struct {
BuilderSpec `json:",inline"`
ServiceAccount string `json:"serviceAccount,omitempty"`
BuilderSpec `json:",inline"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}

// +k8s:openapi-gen=true
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/build/v1alpha2/builder_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
)

func (cb *Builder) SetDefaults(context.Context) {
if cb.Spec.ServiceAccount == "" {
cb.Spec.ServiceAccount = "default"
if cb.Spec.ServiceAccountName == "" {
cb.Spec.ServiceAccountName = "default"
}
if cb.Spec.Stack.Kind == "" {
cb.Spec.Stack.Kind = ClusterStackKind
Expand All @@ -34,7 +34,7 @@ func (s *BuilderSpec) Validate(ctx context.Context) *apis.FieldError {

func (s *NamespacedBuilderSpec) Validate(ctx context.Context) *apis.FieldError {
return s.BuilderSpec.Validate(ctx).
Also(validate.FieldNotEmpty(s.ServiceAccount, "serviceAccount"))
Also(validate.FieldNotEmpty(s.ServiceAccountName, "serviceAccount"))
}

func validateStack(stack v1.ObjectReference) *apis.FieldError {
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/build/v1alpha2/builder_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func testBuilderValidation(t *testing.T, when spec.G, it spec.S) {
},
Order: nil, // No order validation
},
ServiceAccount: "some-service-account",
ServiceAccountName: "some-service-account",
},
}

Expand All @@ -47,9 +47,9 @@ func testBuilderValidation(t *testing.T, when spec.G, it spec.S) {
})

it("defaults service account to default", func() {
builder.Spec.ServiceAccount = ""
builder.Spec.ServiceAccountName = ""
builder.SetDefaults(context.TODO())
assert.Equal(t, builder.Spec.ServiceAccount, "default")
assert.Equal(t, builder.Spec.ServiceAccountName, "default")
})

it("defaults stack.kind to ClusterStack", func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (c *Reconciler) reconcileBuilder(ctx context.Context, builder *buildapi.Bui
}

keychain, err := c.KeychainFactory.KeychainForSecretRef(ctx, registry.SecretRef{
ServiceAccount: builder.Spec.ServiceAccount,
ServiceAccount: builder.Spec.ServiceAccountName,
Namespace: builder.Namespace,
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,12 @@ func testBuilderReconciler(t *testing.T, when spec.G, it spec.S) {
},
},
},
ServiceAccount: "some-service-account",
ServiceAccountName: "some-service-account",
},
}

secretRef := registry.SecretRef{
ServiceAccount: builder.Spec.ServiceAccount,
ServiceAccount: builder.Spec.ServiceAccountName,
Namespace: builder.Namespace,
}

Expand Down