Skip to content

Commit

Permalink
cli: Rename to image copy-to-storage
Browse files Browse the repository at this point in the history
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
1 parent 6033b1e commit 83a6a15
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 35 deletions.
33 changes: 5 additions & 28 deletions lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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>,
Expand Down Expand Up @@ -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")]
Expand Down
8 changes: 3 additions & 5 deletions lib/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
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>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 83a6a15

Please sign in to comment.