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

cli: Add a new bootc image subcommand #620

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
cli: Rename to image copy-to-storage
Drop the transport support; we only support copying to
`containers-storage`. Anyone who wants to push directly
to a remote registry can do so by first copying to
containers-storage and then pushing via e.g. `podman` or `skopeo`.

Signed-off-by: Colin Walters <walters@verbum.org>
  • Loading branch information
cgwalters committed Jun 28, 2024
commit 83a6a1525ccb3c76ef6fecbbfa98ce770d4fce34
33 changes: 5 additions & 28 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
@@ -199,25 +199,13 @@ pub(crate) enum ImageOpts {
///
/// Note that these are distinct from images stored via e.g. `podman`.
List,
/// Copy a container image from the bootc storage to a target.
///
/// ## Copying the booted container image to containers-storage: (podman)
/// Copy a container image from the bootc storage to `containers-storage:`.
///
/// The source and target are both optional; if both are left unspecified,
/// via a simple invocation of `bootc image push`, then the default is to
/// via a simple invocation of `bootc image copy-to-storage`, then the default is to
/// push the currently booted image to `containers-storage` (as used by podman, etc.)
/// and tagged with the image name `localhost/bootc`,
///
/// ## Copying the booted container image to a remote registry
///
/// Aside from the special case above, default transport is `registry`. This
/// means that an invocation of
///
/// `bootc image push --target quay.io/example/someimage:latest` will push the
/// booted container image to the target registry. This will be done via an
/// invocation equivalent to `skopeo copy`, and hence the defaults for that apply.
/// For example, the default registry authentication file applies.
///
/// ## Copying a non-default container image
///
/// It is also possible to copy an image other than the currently booted one by
@@ -227,13 +215,7 @@ pub(crate) enum ImageOpts {
///
/// At the current time there is no explicit support for pulling images other than indirectly
/// via e.g. `bootc switch` or `bootc upgrade`.
Push {
/// The transport; e.g. oci, oci-archive, containers-storage. Defaults to `registry`.
///
/// For more information, see `man containers-transports`.
#[clap(long, default_value = "registry")]
transport: String,

CopyToStorage {
#[clap(long)]
/// The source image; if not specified, the booted image will be used.
source: Option<String>,
@@ -794,13 +776,8 @@ async fn run_from_opt(opt: Opt) -> Result<()> {
},
Opt::Image(opts) => match opts {
ImageOpts::List => crate::image::list_entrypoint().await,
ImageOpts::Push {
transport,
source,
target,
} => {
let transport = Transport::try_from(transport.as_str())?;
crate::image::push_entrypoint(transport, source.as_deref(), target.as_deref()).await
ImageOpts::CopyToStorage { source, target } => {
crate::image::push_entrypoint(source.as_deref(), target.as_deref()).await
}
},
#[cfg(feature = "install")]
8 changes: 3 additions & 5 deletions lib/src/image.rs
Original file line number Diff line number Diff line change
@@ -22,12 +22,10 @@ pub(crate) async fn list_entrypoint() -> Result<()> {
Ok(())
}

/// Implementation of `bootc image push-to-storage`.
#[context("Pushing image")]
pub(crate) async fn push_entrypoint(
transport: Transport,
source: Option<&str>,
target: Option<&str>,
) -> Result<()> {
pub(crate) async fn push_entrypoint(source: Option<&str>, target: Option<&str>) -> Result<()> {
let transport = Transport::ContainerStorage;
let sysroot = crate::cli::get_locked_sysroot().await?;

let repo = &sysroot.repo();
4 changes: 2 additions & 2 deletions tests/booted/002-test-image-pushpull-upgrade.nu
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This test does:
# bootc image push
# bootc image copy-to-storage
# podman build <from that image>
# bootc switch <to the local image>
# <verify booted state>
@@ -32,7 +32,7 @@ def initial_build [] {
cd $td

do --ignore-errors { podman image rm localhost/bootc o+e>| ignore }
bootc image push
bootc image copy-to-storage
let img = podman image inspect localhost/bootc | from json

mkdir usr/lib/bootc/kargs.d
Loading