mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 08:00:06 +01:00
feat(k8s): allow to specify custom defaults condition, add test
This commit is contained in:
parent
8536b03151
commit
bae2b8d3e6
11 changed files with 79 additions and 18 deletions
|
|
@ -31,6 +31,7 @@ let
|
|||
./k8s/crd.nix
|
||||
./k8s/1.13/crd.nix
|
||||
./k8s/submodule.nix
|
||||
./k8s/defaults.nix
|
||||
./submodules/simple.nix
|
||||
./submodules/defaults.nix
|
||||
];
|
||||
|
|
|
|||
51
tests/k8s/defaults.nix
Normal file
51
tests/k8s/defaults.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{ config, lib, test, kubenix, k8s, ... }:
|
||||
|
||||
with lib;
|
||||
with k8s;
|
||||
|
||||
let
|
||||
pod1 = config.kubernetes.api.pods.pod1;
|
||||
pod2 = config.kubernetes.api.pods.pod2;
|
||||
in {
|
||||
imports = [
|
||||
kubenix.k8s
|
||||
];
|
||||
|
||||
test = {
|
||||
name = "k8s-defaults";
|
||||
description = "Simple k8s testing wheter name, apiVersion and kind are preset";
|
||||
assertions = [{
|
||||
message = "Should have label set with resource";
|
||||
assertion = pod1.metadata.labels.resource-label == "value";
|
||||
} {
|
||||
message = "Should have default label set with group, version, kind";
|
||||
assertion = pod1.metadata.labels.gvk-label == "value";
|
||||
} {
|
||||
message = "Should have conditional annotation set";
|
||||
assertion = pod2.metadata.annotations.conditional-annotation == "value";
|
||||
}];
|
||||
};
|
||||
|
||||
kubernetes.api.pods.pod1 = {};
|
||||
|
||||
kubernetes.api.pods.pod2 = {
|
||||
metadata.labels.custom-label = "value";
|
||||
};
|
||||
|
||||
kubernetes.api.defaults = [{
|
||||
resource = "pods";
|
||||
default.metadata.labels.resource-label = "value";
|
||||
} {
|
||||
group = "core";
|
||||
kind = "Pod";
|
||||
version = "v1";
|
||||
default.metadata.labels.gvk-label = "value";
|
||||
} {
|
||||
resource = "pods";
|
||||
default = { config, ... }: {
|
||||
config.metadata.annotations = mkIf (config.metadata.labels ? "custom-label") {
|
||||
conditional-annotation = "value";
|
||||
};
|
||||
};
|
||||
}];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue