Regc.Mutate.Config (regc v0.0.2)

View Source

Immutable OCI/Docker image-config transformations.

Labels, volumes, exposed ports, and timestamps are changed in the config document only. Regc.Mutate.finalize/2 computes the new config blob descriptor and propagates it into the image manifest.

Summary

Functions

Adds an exposed-port key such as "8080" or "8080/tcp".

Adds a volume path to the runtime config.

Removes a config label.

Normalizes existing config and history timestamps.

Reads an RFC 3339 timestamp from a config label and normalizes timestamps.

Sets a config label. A nil value removes the label.

Removes an exposed-port key.

Removes a volume path from the runtime config.

Functions

add_exposed_port(mutation, port)

@spec add_exposed_port(Regc.Mutate.Image.t(), String.t()) ::
  {:ok, Regc.Mutate.Image.t()} | {:error, Regc.Error.t()}

Adds an exposed-port key such as "8080" or "8080/tcp".

add_volume(mutation, path)

@spec add_volume(Regc.Mutate.Image.t(), String.t()) ::
  {:ok, Regc.Mutate.Image.t()} | {:error, Regc.Error.t()}

Adds a volume path to the runtime config.

delete_label(mutation, name)

@spec delete_label(Regc.Mutate.Image.t(), String.t()) ::
  {:ok, Regc.Mutate.Image.t()} | {:error, Regc.Error.t()}

Removes a config label.

normalize_timestamps(mutation, timestamp, opts \\ [])

@spec normalize_timestamps(
  Regc.Mutate.Image.t(),
  DateTime.t() | String.t(),
  keyword()
) ::
  {:ok, Regc.Mutate.Image.t()} | {:error, Regc.Error.t()}

Normalizes existing config and history timestamps.

Options:

  • :mode - :set replaces every selected timestamp; :max only caps timestamps after the supplied value (default :max).
  • :base_layers - leaves history belonging to this many leading non-empty base layers unchanged. The top-level config created field is still normalized (default 0).

The timestamp may be a DateTime or an RFC 3339 string and is emitted in canonical UTC form when a field changes.

normalize_timestamps_from_label(mutation, label, opts \\ [])

@spec normalize_timestamps_from_label(Regc.Mutate.Image.t(), String.t(), keyword()) ::
  {:ok, Regc.Mutate.Image.t()} | {:error, Regc.Error.t()}

Reads an RFC 3339 timestamp from a config label and normalizes timestamps.

put_label(mutation, name, value)

@spec put_label(Regc.Mutate.Image.t(), String.t(), String.t() | nil) ::
  {:ok, Regc.Mutate.Image.t()} | {:error, Regc.Error.t()}

Sets a config label. A nil value removes the label.

remove_exposed_port(mutation, port)

@spec remove_exposed_port(Regc.Mutate.Image.t(), String.t()) ::
  {:ok, Regc.Mutate.Image.t()} | {:error, Regc.Error.t()}

Removes an exposed-port key.

remove_volume(mutation, path)

@spec remove_volume(Regc.Mutate.Image.t(), String.t()) ::
  {:ok, Regc.Mutate.Image.t()} | {:error, Regc.Error.t()}

Removes a volume path from the runtime config.