Commit Graph

24 Commits

Author SHA1 Message Date
Nalin Dahyabhai b6098a2c5c internal/mkcw/embed: cross-compile using Go
Use the Go toolchain to cross-compile the "This image is designed to be
run as a confidential workload using libkrun." entrypoint that we add to
confidential workload images.  It's bigger than it was before, but
easier to port and can be built from source every time when desired.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2025-11-06 10:46:23 -05:00
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
Patrick Stoeckle 9f809a88ff
chore(typos): fix typos
Signed-off-by: Patrick Stoeckle <patrick.stoeckle@siemens.com>
2025-06-30 15:45:47 +02:00
Kir Kolyshkin 195c6b0c9e internal/mkcw: disable ST1003 warnings
Disable warnings like this one:

> internal/mkcw/workload.go:34:2: ST1003: should not use ALL_CAPS in Go names; use CamelCase instead (staticcheck)
> 	SEV_NO_ES = types.SEV_NO_ES //revive:disable-line:var-naming
> 	^

(

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-04-07 13:01:56 -07: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
flouthoc aadfc5cf30
unit_test: use Parallel test where possible
Add `t.Parallel()` to unit tests whereever its possible without race.

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-02-04 11:07:15 -08:00
Daniel J Walsh adf54cde0e
Add support for --security-opt mask and unmask
Fixes: https://github.com/containers/buildah/issues/5881

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2025-01-07 08:46:48 -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
Giuseppe Scrivano 8bdd6a66d4
internal: use fileutils.(Le|E)xists
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-04-12 09:58:14 +02: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
openshift-merge-bot[bot] b535c90832
Merge pull request #5228 from rhatdan/compress
manifest: addCompression use default from containers.conf
2023-12-18 15:27:03 +00:00
Aditya R 4a9dba6472
manifest: addCompression use default from containers.conf
Replaces: https://github.com/containers/buildah/pull/5014

Signed-off-by: Aditya R <arajan@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-12-16 06:50:38 -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
Daniel J Walsh 471460018b
Ignore errors if label.Relabel returns ENOSUP
This is a common mistake by users and is ignored in some places
but not everywhere. This change will help this to be ignored everwhere.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-29 06:54:21 -05:00
Nalin Dahyabhai 3b795dd4bc internal/mkcw/embed/entrypoint.gz: rename to include the arch
Include the arch in the name of the static entrypoint binary, in case we
find ourselves needing to support other architectures in the same area
in the future.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-11-28 16:43:44 -05:00
Aditya R bbb55b8b81
buildah: add heredoc support for RUN, COPY and ADD
Following PR is a attempt to add `Heredoc` support to buildah.

Once this PR is merged buildah is supposed to honor heredoc syntax while
processing containerfiles

Expected syntax to work

```Dockerfile
FROM docker.io/library/python:latest
RUN <<EOF
echo "Hello" >> /hello
echo "World!" >> /hello
EOF

RUN python3 <<EOF
with open("/hello", "w") as f:
    print("Hello", file=f)
    print("Something", file=f)
EOF

RUN ls -a
RUN cat hello
```

Signed-off-by: Aditya R <arajan@redhat.com>
2023-11-17 21:17:52 +05:30
Daniel J Walsh 8f86c5784f
Update cirrus and version of golang
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-11-09 14:12:30 -06:00
Daniel J Walsh 3b96b1cafb
Use mask definitions from containers/common
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-10-27 13:10:18 -04:00
Valentin Rothberg 02f781b354 container.conf: support attributed string slices
All `[]string`s in containers.conf have now been migrated to attributed
string slices which require some adjustments in Buildah and Podman.

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-26 15:34:23 +02:00
Valentin Rothberg c536048cac vendor c/common: appendable containers.conf strings, Part 1
This change is the first step of integrating appendable string arrays
into containers.conf and starts with enabling the `Env`, `Mounts`, and
`Volumes` fields in the `[Containers]` table.

Both, Buildah and Podman, read (and sometimes write) the fields of the
`Config` struct at various places, so I decided to migrate the fields
step-by-step.  The ones in this change are most critical ones for
customers.  Once all string slices/arrays are migrated, the docs of
containers.conf will be updated.  The current changes are entirely
transparent to users.

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-24 17:00:38 +02:00
Aditya R 9c57af8d14
mkcw: remove entrypoint binaries
Remove generated binaries

[NO NEW TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
2023-10-06 13:19:34 +05:30
Nalin Dahyabhai 5bfc7d9a40 Update some comments related to confidential workload
Add siena and turin to the list of generations in a comment.
Drop a double-whitespace in the middle of a comment sentence.

[NO NEW TESTS NEEDED]

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2023-10-04 17:04:33 -04: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