2021-05-06 16:07:24 -04:00
|
|
|
{ config, lib, kubenix, ... }:
|
2019-02-27 12:06:18 +01:00
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
let
|
2019-09-27 18:29:00 +02:00
|
|
|
pod1 = config.kubernetes.api.resources.pods.pod1;
|
|
|
|
|
pod2 = config.kubernetes.api.resources.pods.pod2;
|
2021-05-13 17:27:08 -04:00
|
|
|
in
|
|
|
|
|
{
|
2019-03-07 23:23:07 +01:00
|
|
|
imports = with kubenix.modules; [ test k8s ];
|
2019-02-27 12:06:18 +01:00
|
|
|
|
|
|
|
|
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";
|
2021-05-13 17:27:08 -04:00
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
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";
|
|
|
|
|
}];
|
2019-02-27 12:06:18 +01:00
|
|
|
};
|
|
|
|
|
|
2021-05-13 17:27:08 -04:00
|
|
|
kubernetes.resources.pods.pod1 = { };
|
2019-02-27 12:06:18 +01:00
|
|
|
|
2019-09-27 18:29:00 +02:00
|
|
|
kubernetes.resources.pods.pod2 = {
|
2019-02-27 12:06:18 +01:00
|
|
|
metadata.labels.custom-label = "value";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
kubernetes.api.defaults = [{
|
|
|
|
|
resource = "pods";
|
|
|
|
|
default.metadata.labels.resource-label = "value";
|
2021-05-13 17:27:08 -04:00
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
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";
|
|
|
|
|
};
|
2019-02-27 12:06:18 +01:00
|
|
|
};
|
2021-05-13 17:27:08 -04:00
|
|
|
}];
|
2019-02-27 12:06:18 +01:00
|
|
|
}
|