Commit Graph

7 Commits

Author SHA1 Message Date
Nalin Dahyabhai 16680a4dfd modernize: use strings.CutPrefix/SplitSeq/FieldsSeq
Use the CutPrefix(), SplitSeq(), and FieldsSeq() functions from the
strings package when chopping up or iterating over parts of strings, per
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-09-10 13:11:00 -04:00
Jan Kaluza a0a9ac6380 Switch common, storage and image to monorepo.
Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-08-29 15:04:28 +02:00
Nalin Dahyabhai 264f557dbe internal/mkcw.Archive(): use github.com/containers/storage/pkg/ioutils
Use the AtomicWriteFile() from github.com/containers/storage/pkg/ioutils
instead of the one from github.com/docker/docker/pkg/ioutils.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-03-05 10:54:36 -05:00
Nalin Dahyabhai fdf1c75cd3 linters: unused arguments shouldn't have names
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-08-07 10:10:35 -04:00
Nalin Dahyabhai 89f50af211 internal/mkcw.Archive(): handle extra image content
When we have extra files to add to the image, handle them by adding them
to the upper overlay layer before creating the plaintext filesystem
image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-01-15 09:51:13 -05:00
Nalin Dahyabhai 81435aadcb mkcw: populate the rootfs using an overlay
When using the working container's rootfs to populate a plaintext disk
image with mkfs, instead of writing .krun_config.json to the rootfs and
then removing it afterward (since we don't want it to show up if the
same working container is later committed to non confidential-workload
image), mount an overlay filesystem using a temporary directory as the
upper and the rootfs as the lower, create the .krun_config.json file in
the overlay filesystem, and use the overlay filesystem as the source
directory for mkfs.

Add the necessary stubs to allow pkg/overlay to at least compile on
non-Linux systems.  Change the naming scheme for a test so that the path
names it uses for temporary directories don't include "," or "=", which
can confuse the kernel.

Creating confidential workload images will now only be possible on Linux
systems, but we exec'd out to sevctl to read platform certificates, and
that requires kernel support with vendor firmware, so I don't know that
anyone will actually be impacted by the change.

Teach pkg/overlay.MountWithOptions() to accept `nil` as a pointer to a
struct parameter that is otherwise optional.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-12-13 14:06:59 -05:00
Nalin Dahyabhai e89fac6c9b Add `buildah mkcw`, add `--cw` to `buildah commit` and `buildah build`
Add a --cw option to `buildah build` and `buildah commit`, which takes a
comma-separated list of arguments and produces an image laid out for use
as a confidential workload:
  type: sev or snp
  attestation_url: location of a key broker server
  cpus: expected number of virtual CPUs to run with
  memory: expected megabytes of memory to run with
  workload_id: a distinguishing identifier for the key broker server
  ignore_attestation_errors: ignore errors registering the workload
  passphrase: for encrypting the disk image
  slop: extra space to allocate for the disk image

At least one of attestation_url and passphrase must be specified in
order for the encrypted disk image to be decryptable at run-time.  Other
arguments can be omitted.  ignore_attestation_errors is intentionally
undocumented, as it's mainly used to permit some amount of testing on
systems which don't have the required hardware.

Add an `mkcw` top-level command, for converting directly from an image
to a confidential workload.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-09-07 14:05:10 -04:00