From 55f7420449c2e0f9dbf1334a3a3b497382a10faf Mon Sep 17 00:00:00 2001 From: Yoann Date: Wed, 19 Jul 2023 12:26:32 +0200 Subject: [PATCH] fix error when containerPort misses protocol --- modules/generated/v1.19.nix | 13 ++++++++++--- modules/generated/v1.20.nix | 13 ++++++++++--- modules/generated/v1.21.nix | 13 ++++++++++--- modules/generated/v1.22.nix | 13 ++++++++++--- modules/generated/v1.23.nix | 13 ++++++++++--- modules/generated/v1.24.nix | 13 ++++++++++--- modules/generated/v1.25.nix | 13 ++++++++++--- modules/generated/v1.26.nix | 13 ++++++++++--- modules/generated/v1.27.nix | 13 ++++++++++--- pkgs/generators/k8s/default.nix | 11 ++++++++--- 10 files changed, 98 insertions(+), 30 deletions(-) diff --git a/modules/generated/v1.19.nix b/modules/generated/v1.19.nix index 8fdfee1..d2ddb37 100644 --- a/modules/generated/v1.19.nix +++ b/modules/generated/v1.19.nix @@ -79,9 +79,16 @@ let # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.${key} - then toString value.${key}.content - else (toString value.${key}) + # set key to default value if unset. + let + value' = + if (!(value ? key) && key == "protocol") + then value // { protocol = "TCP"; } + else value; + in + if isAttrs value'.${key} + then toString value'.${key}.content + else (toString value'.${key}) ) listMergeKeys)) ) diff --git a/modules/generated/v1.20.nix b/modules/generated/v1.20.nix index 34c8282..1d87018 100644 --- a/modules/generated/v1.20.nix +++ b/modules/generated/v1.20.nix @@ -79,9 +79,16 @@ let # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.${key} - then toString value.${key}.content - else (toString value.${key}) + # set key to default value if unset. + let + value' = + if (!(value ? key) && key == "protocol") + then value // { protocol = "TCP"; } + else value; + in + if isAttrs value'.${key} + then toString value'.${key}.content + else (toString value'.${key}) ) listMergeKeys)) ) diff --git a/modules/generated/v1.21.nix b/modules/generated/v1.21.nix index b52ea1c..5e026fa 100644 --- a/modules/generated/v1.21.nix +++ b/modules/generated/v1.21.nix @@ -79,9 +79,16 @@ let # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.${key} - then toString value.${key}.content - else (toString value.${key}) + # set key to default value if unset. + let + value' = + if (!(value ? key) && key == "protocol") + then value // { protocol = "TCP"; } + else value; + in + if isAttrs value'.${key} + then toString value'.${key}.content + else (toString value'.${key}) ) listMergeKeys)) ) diff --git a/modules/generated/v1.22.nix b/modules/generated/v1.22.nix index ee35d56..4c69065 100644 --- a/modules/generated/v1.22.nix +++ b/modules/generated/v1.22.nix @@ -79,9 +79,16 @@ let # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.${key} - then toString value.${key}.content - else (toString value.${key}) + # set key to default value if unset. + let + value' = + if (!(value ? key) && key == "protocol") + then value // { protocol = "TCP"; } + else value; + in + if isAttrs value'.${key} + then toString value'.${key}.content + else (toString value'.${key}) ) listMergeKeys)) ) diff --git a/modules/generated/v1.23.nix b/modules/generated/v1.23.nix index cdcf11f..300704e 100644 --- a/modules/generated/v1.23.nix +++ b/modules/generated/v1.23.nix @@ -79,9 +79,16 @@ let # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.${key} - then toString value.${key}.content - else (toString value.${key}) + # set key to default value if unset. + let + value' = + if (!(value ? key) && key == "protocol") + then value // { protocol = "TCP"; } + else value; + in + if isAttrs value'.${key} + then toString value'.${key}.content + else (toString value'.${key}) ) listMergeKeys)) ) diff --git a/modules/generated/v1.24.nix b/modules/generated/v1.24.nix index a8b52f9..8b22ef3 100644 --- a/modules/generated/v1.24.nix +++ b/modules/generated/v1.24.nix @@ -79,9 +79,16 @@ let # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.${key} - then toString value.${key}.content - else (toString value.${key}) + # set key to default value if unset. + let + value' = + if (!(value ? key) && key == "protocol") + then value // { protocol = "TCP"; } + else value; + in + if isAttrs value'.${key} + then toString value'.${key}.content + else (toString value'.${key}) ) listMergeKeys)) ) diff --git a/modules/generated/v1.25.nix b/modules/generated/v1.25.nix index 2f0422d..c02509a 100644 --- a/modules/generated/v1.25.nix +++ b/modules/generated/v1.25.nix @@ -79,9 +79,16 @@ let # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.${key} - then toString value.${key}.content - else (toString value.${key}) + # set key to default value if unset. + let + value' = + if (!(value ? key) && key == "protocol") + then value // { protocol = "TCP"; } + else value; + in + if isAttrs value'.${key} + then toString value'.${key}.content + else (toString value'.${key}) ) listMergeKeys)) ) diff --git a/modules/generated/v1.26.nix b/modules/generated/v1.26.nix index 4fb86a2..eb2e431 100644 --- a/modules/generated/v1.26.nix +++ b/modules/generated/v1.26.nix @@ -79,9 +79,16 @@ let # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.${key} - then toString value.${key}.content - else (toString value.${key}) + # set key to default value if unset. + let + value' = + if (!(value ? key) && key == "protocol") + then value // { protocol = "TCP"; } + else value; + in + if isAttrs value'.${key} + then toString value'.${key}.content + else (toString value'.${key}) ) listMergeKeys)) ) diff --git a/modules/generated/v1.27.nix b/modules/generated/v1.27.nix index 18ad35b..bb04db1 100644 --- a/modules/generated/v1.27.nix +++ b/modules/generated/v1.27.nix @@ -79,9 +79,16 @@ let # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.${key} - then toString value.${key}.content - else (toString value.${key}) + # set key to default value if unset. + let + value' = + if (!(value ? key) && key == "protocol") + then value // { protocol = "TCP"; } + else value; + in + if isAttrs value'.${key} + then toString value'.${key}.content + else (toString value'.${key}) ) listMergeKeys)) ) diff --git a/pkgs/generators/k8s/default.nix b/pkgs/generators/k8s/default.nix index b5d088c..4c9d23c 100644 --- a/pkgs/generators/k8s/default.nix +++ b/pkgs/generators/k8s/default.nix @@ -399,9 +399,14 @@ with lib; let else # generate merge key for list elements if it's not present "__kubenix_list_merge_key_" + (concatStringsSep "" (map (key: - if isAttrs value.''${key} - then toString value.''${key}.content - else (toString value.''${key}) + # set key to default value if unset. + let + value' = if (!(value ? key) && key == "protocol") + then value // {protocol = "TCP";} + else value; + in if isAttrs value'.''${key} + then toString value'.''${key}.content + else (toString value'.''${key}) ) listMergeKeys)) ) (value // { _priority = i; })) values);