- .chainguard
- .github
- config
- docs
- examples
- hack
-
internal
-
cli
-
testdata
-
base_image
-
blobs
-
sha256
- 2580c204e7b254c8988c5cd1840cd58246afafb2479190b6cb3f448341003a5f
- 2ef91a9967f2e1759ea49a8c01cf6a45dd9f9af71fe09bcf2b86175bc4a71314
- 583625b6164fff3b017f62b9fcd60cb53fff18a7e89ee538212134a13fc29fb1
- 5a99438a9ced8193f1d71209d0b558fdc0b184aee5cf258e5f7aa9a6ab0f0671
- 65eba664f408f8a2b2cf6b190255c8b0e8cb16a85d773089ae184ac35d782464
- bf74ddaf55d32ec9672a0a40efc6cb1bf0a167763c18fc22586c8a301167822f
-
sha256
- metadata
- sboms
- index.json
- oci-layout
-
blobs
-
golden
-
blobs
-
sha256
- 18d41b1f595d19375dc45a14f87f64e736d577e618fc77707bb710a8e59842b1
- 26344c4399ce8d47eed8a16da31044b45634ab26a8e43493574a7c944ca35328
- 41b285b4a6870e47e59ef34f87d3637a202783f535d70d0152c53d80f57c90a2
- 5398671bcb1dc210cfb253a808be94fff70723d939d7ce6d8053a823f4720d57
- c4fba92e353f8a3be76c9feaa4763c3f9177697364fe54943eda3f51ec641d55
- e29f907eae193b71f82232ac873a7f2bbe3d5e3b841c729b6a58706750f01ce0
-
sha256
- sboms
- index.json
- oci-layout
-
blobs
- packages
- private_packages
-
top_image
-
blobs
-
sha256
- 149f310693ee8812c28e4e23ee1bf0b35141ac2c19e1a665ff5baadb3fd8a68e
- 1b8f0b6e368cf22d86aaeb2181defed3ffe4bed0383d7acf05b8850881b60a10
- 583625b6164fff3b017f62b9fcd60cb53fff18a7e89ee538212134a13fc29fb1
- 68daf87e56a0a846927c0535c9beaa4d90b7500739d79766b757b8253e7c84d7
- 97502a24c34c7cd4d1c3f29dbba3b123c4da15d2bd3bbe723bfddb949713342a
- a54af7ae5da36e1d6feaf559438cd1b84a27223cd4518f4c875de82bcdc31017
- bf74ddaf55d32ec9672a0a40efc6cb1bf0a167763c18fc22586c8a301167822f
- d509688b2e26be6f4c6e8eb1f8e3f1f1cc563712dfa095cc461d5c37a29057b0
-
sha256
- index.json
- oci-layout
-
blobs
- apko.lock.json
- apko.pre-0.13.lock.json
- apko.yaml
- base_image.apko.yaml
- image_on_top.apko.lock.json
- image_on_top.apko.yaml
- melange.rsa
- melange.rsa.pub
- pretend-baselayout.melange.yaml
- replayout.melange.yaml
-
base_image
- build-cpio.go
- build-minirootfs.go
- build.go
- build_test.go
- commands.go
- dot.go
- install-keys.go
- lock.go
- lock_test.go
- options.go
- publish.go
- publish_test.go
- show-config.go
- show-packages.go
-
testdata
- gen-jsonschema
- tools.go
-
cli
-
pkg
-
apk
-
apk
- testdata
- apkindex.go
- apkindex_test.go
- arch.go
- cache.go
- common.go
- common_test.go
- common_test_nonunix.go
- common_test_unix.go
- const.go
- errors.go
- executor.go
- implementation.go
- implementation_test.go
- index.go
- install.go
- install_test.go
- installed.go
- installed_test.go
- options.go
- package.go
- package_test.go
- releases.go
- repo.go
- repo_test.go
- repository.go
- repository_test.go
- resolveapk.go
- shameful_global_caches.go
- transport.go
- transport_test.go
- util.go
- version.go
- version_test.go
- world.go
- world_test.go
- auth
- client
- docs
- expandapk
- fs
- internal
- passwd
- signature
- tarball
- README.md
-
apk
- baseimg
- build
- cpio
- lock
- options
- passwd
- paths
- s6
- sbom
- tarfs
- vcs
- vfs
-
apk
- .editorconfig
- .gitignore
- .golangci.yml
- .goreleaser.yaml
- .ko.yaml
- CODE_OF_CONDUCT.md
- CONTRIBUTING.md
- LICENSE
- Makefile
- NEWS.md
- README.md
- apk.md
- go.mod
- go.sum
- header.tmpl
- main.go
- release.md
Explanation
This code tests the BuildImage function of the apko package.
Test Scenarios:
TestBuildImage:
It creates a new build context with the default configuration file (
apko.yaml) in thetestdatadirectory.It builds the image using
bc.BuildImage(ctx).It checks the installed packages by calling
bc.InstalledPackages().It asserts that the installed packages are
pretend-baselayout(version 1.0.0-r0) andreplayout(version 1.0.0-r0).TestBuildImageFromLockFile:
It creates a new build context with both the configuration file (
apko.yaml) and the lock file (apko.lock.json) in thetestdatadirectory.It builds the image.
It verifies that the installed packages are the same as in the previous test case.
This test demonstrates the ability to build the image based on the locked package dependencies.
TestBuildImageFromTooOldResolvedFile:
It creates a new build context with the configuration file and a lock file (
apko.pre-0.13.lock.json) that is incompatible with the currentapkoversion.It attempts to build the image.
The test expects an error message indicating that the lock file is too old and needs to be regenerated with a newer
apkoversion.This ensures that
apkogracefully handles outdated lock files.
Key Points:
- The
BuildImagefunction is the core functionality of the package, which is responsible for building the image based on the configuration provided. build.WithConfigandbuild.WithLockFileare options for customizing the build process by specifying configuration and lock file paths.- The test cases thoroughly cover the
BuildImagefunction, including scenarios with and without a lock file, and with an outdated lock file. - The
InstalledPackages()method is used to check the installed packages after building the image.
This code is a good example of unit testing for a package that involves building container images. It covers various use cases and verifies the expected behavior, providing confidence in the functionality of apko.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph