feat(legacy): improve legacy support, add more tests

This commit is contained in:
Jaka Hudoklin 2019-10-21 12:20:57 +02:00
parent 086780088c
commit 29b1140178
No known key found for this signature in database
GPG key ID: D1F18234B07BD6E2
5 changed files with 189 additions and 74 deletions

57
tests/legacy/k8s.nix Normal file
View file

@ -0,0 +1,57 @@
{ config, lib, kubenix, pkgs, k8sVersion, ... }:
with lib;
let
cfg = config.kubernetes.api.resources.deployments.app;
in {
imports = with kubenix.modules; [ test k8s legacy ];
test = {
name = "legacy-k8s";
description = "Simple test kubenix legacy kubernetes support";
assertions = [{
message = "should have correct resource options set";
assertion =
cfg.kind == "Deployment" &&
cfg.metadata.name == "app";
} {
message = "should have correct defaults set";
assertion =
cfg.metadata.namespace == "test" &&
cfg.metadata.labels.label1 == "value1" &&
cfg.metadata.labels.label2 == "value2";
}];
};
kubernetes.version = k8sVersion;
kubernetes.resources.deployments.app = {
spec = {
replicas = 2;
selector = {
matchLabels.app = "app";
};
template.spec = {
containers.app = {
image = "hello-world";
};
};
};
};
kubernetes.resources.configMaps.app = {
data."my-conf.json" = builtins.toJSON {};
};
kubernetes.defaults = {
all = [{
metadata.namespace = "test";
metadata.labels.label1 = "value1";
}];
deployments = [{
metadata.labels.label2 = "value2";
}];
};
}