-
Notifications
You must be signed in to change notification settings - Fork 111
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
Replace print with logger in image_cache.go, fixes formatting #1012
Replace print with logger in image_cache.go, fixes formatting #1012
Conversation
Signed-off-by: Harshal Mittal <[email protected]>
Hi @harshalmittal4 thanks for working on this! Taking a look, I think maybe you can try mocking the origImage imgutil.Image. You need the type fakeErrorImage struct {
imgutil.Image
}
func newFakeImageErrIdentifier(origImage imgutil.Image) *fakeErrorImage {
return &fakeErrorImage{Image: origImage}
}
func (f *fakeErrorImage) Identifier() (imgutil.Identifier, error) {
return nil, errors.New("error deleting original image")
} Then in your test case: var fakeErrorImage *fakeErrorImage
it.Before(func() {
fakeOriginalImage = fakes.NewImage("fake-image", "", local.IDIdentifier{ImageID: "fakeOrigImage"})
// wrap your fake image into the one that throws the error you need
fakeErrorImage = newFakeImageErrIdentifier(fakeOriginalImage)
// ... more code
}) That should help you to go into your warning message, also provide a mock logger to record the method was called and you can do some assert in the test |
@harshalmittal4 this looks good! I think we also need to update the function call here: lifecycle/acceptance/exporter_test.go Line 259 in 3be3585
|
Signed-off-by: Harshal Mittal <[email protected]>
Thanks a lot @jjbustamante , @natalieparellano ! I've updated the PR including both the comments, please take a look. |
Unrelated to this, can you also please take a look at this issue when running acceptance tests -
So is there a way to run these on M1 mac? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good!
As far as running the acceptance tests on m1 - I have not tried it myself as I don't yet have an arm machine. Maybe someone else can advise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job @harshalmittal4! Thanks a lot for helping us on this. ❤️
Thanks much @jjbustamante , @natalieparellano for all the help! I'm an open-source beginner and really glad to be able to contribute 😃 |
Awesome work @harshalmittal4! |
* Make a single constructor for lifecycle inputs - The logic to update the default path for TOML files was repeated across phases - In general it is safe to provide default values for inputs that might not be relevant to the current phase, as these will be ignored when constructing a new service for the phase; e.g., platform.LifecycleInputs.OrderPath will be ignored when constructing a lifecycle.Exporter - As more inputs are shared across phases (e.g., analyzed.toml is now an input to the detect phase), duplicating the logic for providing default values is becoming more cumbersome Signed-off-by: Natalie Arellano <[email protected]> * Read values from environment Signed-off-by: Natalie Arellano <[email protected]> * Buildpack API: run.Dockerfiles are allowed instructions on versions >= 0.10 Signed-off-by: Natalie Arellano <[email protected]> * Platform API: the detector accepts a new -run flag Signed-off-by: Natalie Arellano <[email protected]> * Move responsibility for validating Dockerfiles into the buildpack package Signed-off-by: Natalie Arellano <[email protected]> * When verifying Dockerfiles, return the new base image name if necessary Signed-off-by: Natalie Arellano <[email protected]> * When determining the new runtime base image, use criteria outlined in the platform spec Signed-off-by: Natalie Arellano <[email protected]> * Platform API: the schema of analyzed.toml is updated to include run-image.extend = <true or false, default false> Signed-off-by: Natalie Arellano <[email protected]> * TESTME: Update analyzed.toml with new run image if needed Signed-off-by: Natalie Arellano <[email protected]> * If extensions are used to switch the runtime base image, the detector should fail if the selected base image is not found in run.toml. Signed-off-by: Natalie Arellano <[email protected]> * Add fixture to test re-writing of analyzed.toml Signed-off-by: Natalie Arellano <[email protected]> * Move updating analyzed.toml into lifecycle package for easier testing Signed-off-by: Natalie Arellano <[email protected]> * Fix acceptance Signed-off-by: Natalie Arellano <[email protected]> * Don't redefine -layers Signed-off-by: Natalie Arellano <[email protected]> * Revert "Replace print with logger in image_cache.go, fixes formatting (#1012)" This reverts commit 6a10b63. * Revert "Revert "Replace print with logger in image_cache.go, fixes formatting (#1012)"" This reverts commit 5780910. * Rename image -> images in run.toml We pluralize all other list elements Signed-off-by: Natalie Arellano <[email protected]> * Don't enforce constraints for older extensions Signed-off-by: Natalie Arellano <[email protected]> * Rename function for clarity Signed-off-by: Natalie Arellano <[email protected]> --------- Signed-off-by: Natalie Arellano <[email protected]>
* Replace print with logger in image_cache.go, fixes formatting Signed-off-by: Harshal Mittal <[email protected]> * Add tests for image_cache logger Signed-off-by: Harshal Mittal <[email protected]> --------- Signed-off-by: Harshal Mittal <[email protected]>
* Fix log message when run image not found (#1004) Before: "Previous image with name <run image name> not found" After: "Image with name <run image name> not found" Signed-off-by: Natalie Arellano <[email protected]> * Bump containerd (#1015) Signed-off-by: Natalie Arellano <[email protected]> * Replace print with logger in image_cache.go, fixes formatting (#1012) * Replace print with logger in image_cache.go, fixes formatting Signed-off-by: Harshal Mittal <[email protected]> * Add tests for image_cache logger Signed-off-by: Harshal Mittal <[email protected]> --------- Signed-off-by: Harshal Mittal <[email protected]> * Bump golang.org/x/net from 0.5.0 to 0.7.0 (#1017) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.5.0 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](golang/net@v0.5.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Merge pull request #1036 from benri/bl/archive-pax-global-header Ignore pax global header in tar extract * Bump golang.org/x/sys from 0.5.0 to 0.6.0 (#1029) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.5.0 to 0.6.0. - [Release notes](https://github.com/golang/sys/releases) - [Commits](golang/sys@v0.5.0...v0.6.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump github.com/containerd/containerd from 1.6.18 to 1.6.19 (#1040) * Bump github.com/containerd/containerd from 1.6.18 to 1.7.0 Signed-off-by: Natalie Arellano <[email protected]> * Only bump to 1.6.19 instead of 1.7.x until we can upgrade docker/docker docker/docker 20.10.23 is incompatible with containerd 1.7.x+ due to the removal of sys/userns_deprecated.go (upgrading containerd results in lifecycle compile errors like go/pkg/mod/github.com/docker/[email protected]+incompatible/pkg/archive/archive_unix.go:96:42: undefined: sys.RunningInUserNS) Signed-off-by: Natalie Arellano <[email protected]> --------- Signed-off-by: Natalie Arellano <[email protected]> --------- Signed-off-by: Natalie Arellano <[email protected]> Signed-off-by: Harshal Mittal <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Harshal Mittal <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jesse Brown <[email protected]>
#1049) * Ready release/0.16.1 (#1041) * Fix log message when run image not found (#1004) Before: "Previous image with name <run image name> not found" After: "Image with name <run image name> not found" Signed-off-by: Natalie Arellano <[email protected]> * Bump containerd (#1015) Signed-off-by: Natalie Arellano <[email protected]> * Replace print with logger in image_cache.go, fixes formatting (#1012) * Replace print with logger in image_cache.go, fixes formatting Signed-off-by: Harshal Mittal <[email protected]> * Add tests for image_cache logger Signed-off-by: Harshal Mittal <[email protected]> --------- Signed-off-by: Harshal Mittal <[email protected]> * Bump golang.org/x/net from 0.5.0 to 0.7.0 (#1017) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.5.0 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](golang/net@v0.5.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Merge pull request #1036 from benri/bl/archive-pax-global-header Ignore pax global header in tar extract * Bump golang.org/x/sys from 0.5.0 to 0.6.0 (#1029) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.5.0 to 0.6.0. - [Release notes](https://github.com/golang/sys/releases) - [Commits](golang/sys@v0.5.0...v0.6.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump github.com/containerd/containerd from 1.6.18 to 1.6.19 (#1040) * Bump github.com/containerd/containerd from 1.6.18 to 1.7.0 Signed-off-by: Natalie Arellano <[email protected]> * Only bump to 1.6.19 instead of 1.7.x until we can upgrade docker/docker docker/docker 20.10.23 is incompatible with containerd 1.7.x+ due to the removal of sys/userns_deprecated.go (upgrading containerd results in lifecycle compile errors like go/pkg/mod/github.com/docker/[email protected]+incompatible/pkg/archive/archive_unix.go:96:42: undefined: sys.RunningInUserNS) Signed-off-by: Natalie Arellano <[email protected]> --------- Signed-off-by: Natalie Arellano <[email protected]> --------- Signed-off-by: Natalie Arellano <[email protected]> Signed-off-by: Harshal Mittal <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Harshal Mittal <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jesse Brown <[email protected]> * Add sleep to "publish images" workflow (#1042) It takes a few seconds for the image to be available Signed-off-by: Natalie Arellano <[email protected]> * Fix buildpacksio/lifecycle manifest create (#1043) * Force lifecycle images to have docker media types Signed-off-by: Natalie Arellano <[email protected]> * Update go.mod to use latest imgutil Signed-off-by: Natalie Arellano <[email protected]> --------- Signed-off-by: Natalie Arellano <[email protected]> * Bump kaniko & docker and unpin deps (#1045) * Update kaniko & docker, unpin deps Signed-off-by: Natalie Arellano <[email protected]> * Update containerd Signed-off-by: Natalie Arellano <[email protected]> * Remove CVE ignores now that runc is unpinned Signed-off-by: Natalie Arellano <[email protected]> * Update to released kaniko Signed-off-by: Natalie Arellano <[email protected]> --------- Signed-off-by: Natalie Arellano <[email protected]> * Ignore non-impactful runc CVE (#1047) Signed-off-by: Natalie Arellano <[email protected]> * Fix unit Signed-off-by: Natalie Arellano <[email protected]> --------- Signed-off-by: Natalie Arellano <[email protected]> Signed-off-by: Harshal Mittal <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Harshal Mittal <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jesse Brown <[email protected]>
This attempts to fix #880 by using a logger
Hey @jjbustamante, @natalieparellano,
For testing, the invocation of
logger.Warnf()
inimage_cache.go
requiresc.DeleteOrigImage()
to return a non-nil error. I tried simulating it using a spy forImageCache
and mock methodDeleteOrigImage()
that returns an error but it did not help -Could you please suggest how can it be tested and review other changes