healthcheck only works in Docker format, so when healthcheck is set in OCI format, warn user that it will be discarded
Signed-off-by: Ashley Cui <acui@redhat.com>
The image returned by UpdatedImage() doesn't have a reference, so
attempting to include the result's name in an error message causes a
crash. Assign it to a temporary variable first so that we can use the
name of the un-updated version in an error message.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #1960
Approved by: TomSweeneyRedHat
Do not check disk for existence of volume.
If volume that ends with `-` is set in config, remove it.
If not, add it into config.
Signed-off-by: Ashley Cui <ashleycui16@gmail.com>
Closes: #1767
Approved by: rhatdan
When using the --volume flag, ojects ending in "-" are checked if they exist on disk. If they exist on disk they are added as a volume. Otherwise, if the volume is already config'd, that volume is removed
examples:
if /testvol exists:
"--volume /testvol-" removes /testvol from the config.
if /testvol- exists:
"--volume /testvol-" adds /testvol- from the config.
Signed-off-by: Ashley Cui <ashleycui16@gmail.com>
Closes: #1670
Approved by: rhatdan
Skip our own attempt to expand variables in the SetEnv API, since we
need to let the Dockerfile parser be the only place that happens when
we're building using a Dockerfile.
Move the expansion logic to the CLI, and have it log an error when it
encounters a variable that it can't expand.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #1607
Approved by: TomSweeneyRedHat
We only need to expand the passed-in value once, not once for every variable
that is set in the environment.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #1607
Approved by: TomSweeneyRedHat
Add configuration methods for adding entries which will show up in a
committed image's history, both before and after the new layer that we
add while committing the image. Expose them from the CLI in the form of
a new --add-history option for the "add", "config", "copy", and "run"
commands.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #1300
Approved by: rhatdan
When we set the Hostname to match the container id, we don't want to print
the warning, since the user did not request the hostname being set.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Closes: #1253
Approved by: vrothberg
Handle healthcheck configuration that imagebuilder picks up, and add CLI
flags to `buildah config` that allow the values to be set on the command
line.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #943
Approved by: TomSweeneyRedHat
Make sure that when attempting to diagnose an error, if we encounter an
error during the diagnostic attempt, we return the original error rather
than the error encountered in trying to diagnose it. Log that one.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #1072
Approved by: rhatdan
Hostname should be set to a random name if not set.
Workdir should default to "" not to "/"
If Volumes and Entrypoint are not set they should return NULL not []
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Closes: #958
Approved by: TomSweeneyRedHat
Now that we have a types.Image available in Builder.initConfig, we can
let it do the heavy work of converting configs to the v2s2 and OCI formats.
This requires us to cheat a bit with c/image/types.InformationOnly, but it
works out fine.
AFAICS this should have equivalent effect to the previous implementation,
except:
- Conversion from OCI will no longer crash if "Created" timestamps are missing.
- Conversion from v2s2 to OCI only uses the Config field, not ContainerConfig.
Considering the Docker deamon only ever uses Config for populating the
configuration of newly created containers in (docker create), this seems
good enough. But, to be honest, I'm not quite clear on the purpose of the
Config/ContainerConfig distinction in v2s2.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #776
Approved by: rhatdan
When loading the manifest using a types.Image.Manifest,
we also get a manifest MIME type; don't just throw it away
and then guess as if the data was never available, just use it
directly (now that the loading is close enough for the throwing
away to be noticeable).
[Ultimately, this loads the manifest from a c/image/storage
backend, which calls manifest.GuessMIMEType anyway, so this
does not change behavior right now, but if the c/image/storage
backend ever changed to record MIME types, it would make a
difference. At the very least, we now run the heuristic once
instead of twice.]
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #776
Approved by: rhatdan
Both callers of initConfig contain exactly the same code
to load the manifest and config; move it inside initConfig
now that initConfig has the necessary types.Image available.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #776
Approved by: rhatdan
Both callers of initConfig use a types.Image to get a manifest and
config; so, preserve the types.Image and pass it to Builder.initConfig.
This does not change behavior (except for making the lifetime of
a types.Image a bit longer in one case), but it will allow moving the
manifest/config load into Builder.initConfig in the future.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #776
Approved by: rhatdan
Notably this will use the manifest mediaType field, instead of the
config docker_version field, to detect Docker v2s2 images; again,
docker_version is cleared by buildah itself, so it can't be relied
to decide on the image format.
Anyway, centralizing the tricky heuristic and using a single one
everywhere seems preferable for consistency.
This also allows only searching for OCI annotations on known OCI
images, and that in turn allows us not to silently ignore errors
when parsing OCI manifests.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #776
Approved by: rhatdan
... instead of silently ignoring failures to parse the manifest.
This does not change behavior, but it clearly delineates the
existing/scratch cases, and that which will allow us to better
handle errors in the future.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #776
Approved by: rhatdan
The code apparently intended to use the OCI data to generate
a v2s2 config, instead it only generates the v2s2 config
if OCI parsing fails (from the results of the failed parsing).
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #776
Approved by: rhatdan
Drop error returns from makeDockerV2S2Image and makeOCIv1Image, they
are always nil. Then drop the code which "handles" the errors
by silently ignoring them.
Right now that does not matter, but if make*Image ever did start
returning errors, the existing caller would silently ignore them
and record useless empty data.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #776
Approved by: rhatdan
buildah itself clears docker_version in Builder.fixupConfig; so,
buildah-created v2s1 images do not pass this test
(buildah from buildah-created-v2s1) creates an image with empty
history, which causes (buildah commit) to complain about the mismatch
between history and layer DiffID list.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #776
Approved by: rhatdan
Add options to "buildah config" for setting comment, domainname, and
hostname configuration bits, and the comment in history items which
describe layers that we add, and tests for them. Add a test for the
--shell option while we're at it.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #641
Approved by: rhatdan
Podman commit needs the ability to set a comment and stop signal
when committing a container to an image. Adding set/get functions
for each.
Signed-off-by: baude <bbaude@redhat.com>
Closes: #560
Approved by: nalind
Also vendor in the latest imagebuilder code and all the packages
that come with it.
Note: imagebuilder.NewBuilderForReader has been removed from imagebuilder
so I had to split the function up into two different calls.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Closes: #517
Approved by: rhatdan
When a v2s1 image is stored to disk, some of the layer blobs listed in
its manifest may be discarded as. Account for this.
Start treating a failure to decode v1compat information as a fatal error
instead of trying to fake it.
Tweak how we build the created-by field in history when generating one
from v2s1 information to better match what we see in v2s2 images.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #383
Approved by: rhatdan
Update to adjust to new types and method signatures in just-updated
vendored code.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #174
Approved by: rhatdan
Don't overwrite an image configuration's information about the source
image unless we're intending to create a new working container.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #141
Approved by: rhatdan
Add CommitOption option that to allow a caller to specify a creation
timestamp to use in images.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #141
Approved by: rhatdan
Use Errorf() from 'errors' rather than 'fmt' to help with stack traces.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #130
Approved by: rhatdan
Since V2S1 image manifests don't include a config blob, when we
initialize a builder using an image with a V2S1 manifest, try to dig
configuration information out of the manifest's layer history, and build
a V2S2 image configuration using the results.
Leave the diffID list unpopulated, because we compute the right values
when we push the image, and to prevent us from mistakes if we ever try
to use them before that in the future.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #118
Approved by: rhatdan
Import more manifest and schema variables and types, and rename some of
them to incorporate version numbers.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #118
Approved by: rhatdan
When we decode map elements, either from our own data, or when importing
from elsewhere, maps that don't contain any keys aren't created
automatically, so we need to check, and potentially create, maps when we
want to add something to them.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #114
Approved by: rhatdan
If we're building on an OCI image, initialize the Builder object's
annotations using the annotations from the source image.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #116
Approved by: rhatdan
Maintain the container configuration in multiple formats in the Buildah
object, initializing one based on the other, depending on which format
the source image used for its configuration.
Replace directly manipulated fields in the Buildah object (Annotations,
CreatedBy, OS, Architecture, Maintainer, User, Workdir, Env, Cmd,
Entrypoint, Expose, Labels, and Volumes) with accessor functions which
update both configurations and which read from whichever one we consider
to be authoritative. Drop Args because we weren't using them.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #102
Approved by: rhatdan
Internalize the type declaration of a Docker image, so that we don't
need to pull in code when we just want to know how to parse out a JSON
object. Carry a copy of the license that covered the sources from which
the definitions came.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #75
Approved by: nalind
Add a build-using-dockerfile command (alias: bud) which uses
openshift/imagebuilder to wrap parsing and dispatching, and runc (or
another OCI runtime) to handle RUN instructions.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Closes: #59
Approved by: rhatdan
Pull most of the core logic from the CLI into a package that should be
easier to consume as a library. Add a "config" command that updates the
builder object's configuration.
Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>