Skip to content

Commit

Permalink
refactor(manifest): unify naming of parsed values
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Jan 22, 2025
1 parent 86118b3 commit 5910287
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/docker-manifest/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let
craneExe = lib.getExe' crane "crane";
in

assert lib.assertMsg (cfg.uniqueTags != [ ]) "At least one `tag` must be set";
assert lib.assertMsg (cfg.parsedTags != [ ]) "At least one `tag` must be set";

assert lib.assertMsg (cfg.registries != { }) "At least one `registry` must be set";

Expand Down Expand Up @@ -59,7 +59,7 @@ writeShellScriptBin "docker-manifest" ''
--annotation "org.opencontainers.image.revision=$(${lib.getExe git} rev-parse HEAD)" \
${
lib.concatLines (
lib.mapAttrsToList (key: value: ''--annotation "${key}=${value}" \'') cfg.annotationLeaves
lib.mapAttrsToList (key: value: ''--annotation "${key}=${value}" \'') cfg.parsedAnnotations
)
} "${cfg.manifestName}" \
|| exit 1
Expand Down Expand Up @@ -96,14 +96,14 @@ writeShellScriptBin "docker-manifest" ''
--all \
--format ${cfg.format} \
"${cfg.manifestName}" \
"docker://${registryName}/${registryParams.repo}:${lib.head cfg.uniqueTags}" \
"docker://${registryName}/${registryParams.repo}:${lib.head cfg.parsedTags}" \
|| exit 1
${lib.concatMapStringsSep "\n" (tag: ''
${craneExe} tag \
"${registryName}/${registryParams.repo}:${lib.head cfg.uniqueTags}" \
"${registryName}/${registryParams.repo}:${lib.head cfg.parsedTags}" \
"${tag}"
'') (lib.tail cfg.uniqueTags)}
'') (lib.tail cfg.parsedTags)}
'') cfg.registries
)}
''
8 changes: 4 additions & 4 deletions src/docker-manifest/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ in
default = [ ];
description = "List of custom/additional tags to be added to the manifest.";
};
uniqueTags = mkOption {
parsedTags = mkOption {
type = types.listOf types.str;
readOnly = true;
internal = true;
Expand Down Expand Up @@ -143,7 +143,7 @@ in
Most `org.opencontainers.image` annotations are set automatically if the GitHub option is enabled.
'';
};
annotationLeaves = mkOption {
parsedAnnotations = mkOption {
type = types.attrsOf types.str;
readOnly = true;
internal = true;
Expand Down Expand Up @@ -232,11 +232,11 @@ in
{
parsedVersion =
if lib'.isNotEmpty config.version then lib.removePrefix "v" config.version else null;
uniqueTags = lib.unique (lib.filter lib'.isNotEmpty config.tags);
parsedTags = lib.unique (lib.filter lib'.isNotEmpty config.tags);
annotations.org.opencontainers.image = {
version = config.parsedVersion;
};
annotationLeaves = lib.mapAttrs escapeAnnotations (
parsedAnnotations = lib.mapAttrs escapeAnnotations (
lib.filterAttrs (name: value: lib'.isNotEmpty value) (lib'.getLeaves config.annotations)
);
tags = lib.concatLists [
Expand Down

0 comments on commit 5910287

Please sign in to comment.