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

Accurate architectures and image matching #198

Merged
merged 11 commits into from Nov 18, 2022

Conversation

Szubie
Copy link
Collaborator

@Szubie Szubie commented Nov 18, 2022

Image architectures

This PR changes the way bravetools stores image architectures to align with the architectures reported by the build LXD server. This also addresses issues caused when using a remote build server that is a different architecture than the bravetools host.

Prior to this change, image architectures would be dervied from the runtime.GOARCH. For example: amd64/arm64.

After this change the LXD server reported value will be used. For example: x86_64/armv6l.

Image version "untagged" by default

Previously bravetools used version "1.0" as a default, but this was arbitrary and could be confusing if the user actually specified 1.0 themselves. The "untagged" version makes it clearer that it is not user-provided and avoids potential conflicts.

Image matching

This PR also adds image matching where partially defined images will be matched in certain cases. This allows the user to specify images via shorthand by excluding the version/architecture field. So long as only one possible image matches the image description the image will be matched. In cases where there are multiple possible matching images an error will be raised.

For example:

brave images

IMAGE                       VERSION         ARCH    CREATED         SIZE    HASH
python                      1.0             x86_64  4 days ago      3MB     d74509498411e8aca47573f9984568af

brave remove -i python   // Works - python/1.0 will be removed

...  // Adding new images

brave images

IMAGE                           VERSION         ARCH    CREATED         SIZE    HASH
python-api                      1.0             x86_64  4 days ago      3MB     baa79a888963493466be56636a33e3fd
python-api                      untagged        x86_64  4 days ago      3MB     9cec55982dbcfea4dc30e8e344610f13

brave remove -i python-api   // Fails, matches multiple images
2022/11/18 16:08:05 multiple matches for image "python-api" in image store - specify version and/or architecture.
Matches:

python-api/1.0/x86_64
python-api/untagged/x86_64

reported arch will now be the arch stored by bravetools going forwards
rather than the reported GOARCH of bravetools host machine.

This improves compatability with LXD and fixes issues when using
remote machines with a different arch to build images.
…ry provided field and only resort to * when the field is missing. In addition, `ToBasename` returns to a simple string join of all fields to preserve all info when creating a new image
…matching the (potentially incomplete) image definition. Sometimes you need the exact result and other times you want any potential match
…tag whenever creating/importing a new image (not when querying for existing images). Fixes issues with inability to specifically select images with an empty string in version field if another image exists - empty strings would be replaced with stars and match all images with that name. Also cleanup field handling in `TransferImage` to match `buildImage` and do a specific check for image filename first before resorting to glob matching.
…ould result in an empty name field for imported image
…en attempting to parse using legacy Bravefile syntax - fixes image deletion and local image retrieval
…itecture for image (for when arch is not specified)
@idroz idroz merged commit 8fc6e16 into bravetools:master Nov 18, 2022
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.

None yet

2 participants