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

Ensure golden images do not return digests #43

Open
wagoodman opened this issue Jun 22, 2020 · 4 comments
Open

Ensure golden images do not return digests #43

wagoodman opened this issue Jun 22, 2020 · 4 comments

Comments

@wagoodman
Copy link
Contributor

Currently the GetFixtureImage will return the build image intact, however, the digests should be stubbed out as they will always change (https://app.circleci.com/pipelines/github/anchore/imgbom/29/workflows/e36d826e-0885-4408-bdbc-a3413c2db023/jobs/70/steps)

@alfredodeza
Copy link
Contributor

alfredodeza commented Jun 22, 2020

The layer information is used in many outputs, so the digest (here on imgbom text ouput) changes:

         Layer:		 1
         Digest:	 sha256:9b437d7d61c48116592c57e0a646fed378641d5b09662a8172e168b7938cf3147af478720cdc9bd4
         Size:		 1876
         MediaType:	 application/vnd.docker.image.rootfs.diff.tar.gzip

The Image.Metadata.Digest contains the value that needs to be stubbed out:

	for _, l := range img.Layers {
		l.Metadata.Digest = "sha256:ad8ecdc058976c07e7e347cb89fa9ad86a294b5ceaae6d09713fb035f84115abf3c4a2388a4af3aa60f13b94f4c6846930bdf53"
	}

@alfredodeza
Copy link
Contributor

@wagoodman should these values always be stubbed out?

@wagoodman
Copy link
Contributor Author

fair question, I'm not certain. I know for images that are not committed to the repo, this will be an unstable field, thus, always useless. However, I think that GetGoldenFixtureImage uses GetFixtureImage, where the image is committed to the git repo, and the saved digest is relevant and stable.

When implementing this we'll have to keep this in mind, otherwise I think it is safe to assume that these fields should always be stubbed. Maybe provide another helper where this behavior is more apparent in the name?

@alfredodeza
Copy link
Contributor

Another helper does sound like the best path forward here, given that we can't have keyword arguments with defaults in Go.

@luhring luhring transferred this issue from anchore/go-testutils Sep 29, 2020
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

No branches or pull requests

2 participants