Skip to content

fix: clarifies message error regards service account #174

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

Merged
merged 2 commits into from
Nov 17, 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
6 changes: 5 additions & 1 deletion pkg/validation/internal/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ func validateServiceAccounts(bundle *manifests.Bundle) []errors.Error {
sa := v1.ServiceAccount{}
if err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &sa); err == nil {
if _, ok := saNamesFromCSV[sa.Name]; ok {
errs = append(errs, errors.ErrInvalidBundle("invalid service account found in bundle. sa name cannot match service account defined for deployment spec in CSV", sa.Name))
errs = append(errs, errors.ErrInvalidBundle(fmt.Sprintf("invalid service account found in bundle. " +
"This service account %s in your bundle is not valid, because a service account with the same name " +
"was already specified in your CSV. If this was unintentional, please remove the service account " +
"manifest from your bundle. If it was intentional to specify a separate service account, " +
"please rename the SA in either the bundle manifest or the CSV.",sa.Name), sa.Name))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/validation/internal/bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestValidateBundle(t *testing.T) {
description: "invalid bundle service account can't match sa in csv",
directory: "./testdata/invalid_bundle_sa",
hasError: true,
errString: `invalid service account found in bundle. sa name cannot match service account defined for deployment spec in CSV`,
errString: `invalid service account found in bundle. This service account etcd-operator in your bundle is not valid, because a service account with the same name was already specified in your CSV. If this was unintentional, please remove the service account manifest from your bundle. If it was intentional to specify a separate service account, please rename the SA in either the bundle manifest or the CSV.`,
},
}

Expand Down Expand Up @@ -141,7 +141,7 @@ func TestValidateServiceAccount(t *testing.T) {
},
},
hasError: true,
errString: `invalid service account found in bundle. sa name cannot match service account defined for deployment spec in CSV`,
errString: `invalid service account found in bundle. This service account foo in your bundle is not valid, because a service account with the same name was already specified in your CSV. If this was unintentional, please remove the service account manifest from your bundle. If it was intentional to specify a separate service account, please rename the SA in either the bundle manifest or the CSV.`,
},
}

Expand Down