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

WIP - Refactoring analyzer tests to use custom docker registry #685

Merged
merged 11 commits into from
Aug 23, 2021

Conversation

jjbustamante
Copy link
Member

References

  • This Pull Request is created after PR #646 was merged

Context

After merging PR #646 we agreed to refactor the analyzer tests and simplifying the number of docker registries we are using.

Description

  • The PR removes the authRegistry and the readOnlyRegistry and replaces them with just 1 testRegistry that uses the ImagePrivilges approach implemented in imgUtil repo PR #126 to configure the registry to handle the required behaviors.

Depends on

  • This PR depends on imgUtil repo PR #126

@jjbustamante jjbustamante requested a review from a team as a code owner July 28, 2021 21:27
Signed-off-by: Juan Bustamante <[email protected]>
@@ -1214,13 +1218,13 @@ func minifyMetadata(t *testing.T, path string, metadataStruct interface{}) strin
return string(flatMetadata)
}

func buildAuthRegistryImage(t *testing.T, repoName, context string, buildArgs ...string) (string, string) {
func buildAuthRegistryImage(t *testing.T, repoName, context string, registry *ih.DockerRegistry, buildArgs ...string) (string, string) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func buildAuthRegistryImage(t *testing.T, repoName, context string, registry *ih.DockerRegistry, buildArgs ...string) (string, string) {
func buildRegistryImage(t *testing.T, repoName, context string, registry *ih.DockerRegistry, buildArgs ...string) (string, string) {

I wonder if it still makes sense to have this function return the auth. Since we're only getting the auth one time... maybe we could just pull that out, and then we don't have to ignore the second return value every other time.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did the change, you can take a look and give me your thoughts

@natalieparellano
Copy link
Member

@jjbustamante this is looking good! There are a few places where we are explicitly testing the auth, so I don't think we want to pass images that are going to bypass basic auth for the registry. We'll probably need to create a couple extra fixtures that don't have permissions set.

@natalieparellano
Copy link
Member

Also it looks like there is a merge conflict now :( I hope it won't be too tedious to resolve. I am happy to pair on it if you'd like (I think the PR that introduced the conflict was mine).

…po after the depending PR was merged

Signed-off-by: Juan Bustamante <[email protected]>
@@ -1230,7 +1254,7 @@ func buildAuthRegistryImage(t *testing.T, repoName, context string, registry *ih
authConfig, err := auth.BuildEnvVar(authn.DefaultKeychain, regRepoName)
h.AssertNil(t, err)

return regRepoName, authConfig
return authConfig
Copy link
Member

Choose a reason for hiding this comment

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

Ahh I'm sorry, I think I was not clear in my earlier comment. I meant remove authConfig, and keep regRepoName!

Copy link
Member Author

Choose a reason for hiding this comment

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

Mmm... but I think we need the Credentials created for the registry. right? it is used only once because it is the same registry, but it still a required data to fill the fixture

Copy link
Member

Choose a reason for hiding this comment

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

Ohh you're right. The thing is, auth.BuildEnvVar - it expects to be called with a repo, but the auth is per registry, not per repo. Probably we should refactor auth.BuildEnvVar to just expect a registry, but that's another story...

In any case, I think you could call lines 1370+1371 outside of this function with the first repo that is created.

Copy link
Member

@natalieparellano natalieparellano left a comment

Choose a reason for hiding this comment

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

Looks good! buildAuthRegistryImage may be a bit weird now (apologies for not being clear before). I'd be happy to change it in a "polish" PR if you wish.

@jjbustamante
Copy link
Member Author

@natalieparellano I tried to fix the merging conflict, but now there are some tests failing, I think probably I missed something maybe we can try to check

Signed-off-by: Juan Bustamante <[email protected]>
@natalieparellano natalieparellano merged commit 5374e07 into buildpacks:main Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants