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

verify that SA secrets refs are not deleted #767

Conversation

MatousJobanek
Copy link
Collaborator

@sonarcloud
Copy link

sonarcloud bot commented Aug 3, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

No Coverage information No Coverage information
6.7% 6.7% Duplication

Copy link
Contributor

@mfrancisc mfrancisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job 👏

I've added few comments only.

Comment on lines 21 to 22
// Skipping the TestDoNotOverrideServiceAccount test instead of deleting it because we will need to create SAs as part
// of the environment sub-workspaces so the test & logic will be useful to keep.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could drop those now

Suggested change
// Skipping the TestDoNotOverrideServiceAccount test instead of deleting it because we will need to create SAs as part
// of the environment sub-workspaces so the test & logic will be useful to keep.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed in #768

Comment on lines +71 to +80
secrets:
for j := 0; j < i; j++ {
expName := fmt.Sprintf("dummy-secret-%d", j)
for _, secretRef := range sa.Secrets {
if secretRef.Name == fmt.Sprintf("dummy-secret-%d", j) {
continue secrets
}
}
assert.Fail(t, fmt.Sprintf("secret '%s' not found", expName))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just trying to understand - when i is 0 this check will be skipped (ok it will be checked once i>0).
But why do we need to start from secrets again every time we find a secret?

Could we check that all the expected number of secrets (j) are there , and fail the the first one that is missing ?

something like:

	for j := 0; j <= i; j++ {
		expName := fmt.Sprintf("dummy-secret-%d", j)
		found := false
		for _, secretRef := range sa.Secrets {
			if secretRef.Name == fmt.Sprintf("dummy-secret-%d", j) {
			        found = true
				break
			}
		}
		if !found {
			assert.Fail(t, fmt.Sprintf("secret '%s' not found", expName))
		}
	}

and remove the secrets tag and continue statement ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just trying to understand - when i is 0 this check will be skipped (ok it will be checked once i>0).

right - bad copy-paste from the for i line :-)

as for your version - isn't it the same?
the only benefit would be that I could combine secrets & pullSecrets together

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken is not the same because:

  1. you can combine them right
  2. you are not starting from j=0 every time you find a secret, but you validate them in one single loop, because the current continue secrets exists the outer loop as well right ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in #768

MatousJobanek added a commit to MatousJobanek/toolchain-e2e that referenced this pull request Aug 3, 2023
Copy link
Contributor

@mfrancisc mfrancisc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot! Impressive work 🚀 🥇

I'll have a look at the other PR!

@openshift-ci
Copy link

openshift-ci bot commented Aug 3, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MatousJobanek, mfrancisc

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@MatousJobanek MatousJobanek merged commit a51db2d into codeready-toolchain:master Aug 3, 2023
6 checks passed
MatousJobanek added a commit to MatousJobanek/toolchain-e2e that referenced this pull request Aug 3, 2023
MatousJobanek added a commit that referenced this pull request Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants