kubenix/tests/k8s/order.nix

62 lines
1.5 KiB
Nix
Raw Normal View History

2021-05-06 16:07:24 -04:00
{ config, lib, kubenix, pkgs, ... }:
2019-02-28 14:04:47 +01:00
with lib;
let
2019-09-27 18:29:00 +02:00
cfg = config.kubernetes.api.resources.customResourceDefinitions.crontabs;
2019-02-28 14:04:47 +01:00
in {
imports = with kubenix.modules; [ test k8s ];
2019-02-28 14:04:47 +01:00
test = {
name = "k8s-order";
description = "test tesing k8s resource order";
assertions = [{
message = "should have correct order of resources";
assertion =
(elemAt config.kubernetes.objects 0).kind == "CustomResourceDefinition" &&
(elemAt config.kubernetes.objects 1).kind == "Namespace" &&
(elemAt config.kubernetes.objects 2).kind == "CronTab";
}];
};
2019-09-27 18:29:00 +02:00
kubernetes.resources.customResourceDefinitions.crontabs = {
apiVersion = "apiextensions.k8s.io/v1";
2019-02-28 14:04:47 +01:00
metadata.name = "crontabs.stable.example.com";
spec = {
group = "stable.example.com";
versions = [{
name = "v1";
served = true;
schema = true;
}];
2019-02-28 14:04:47 +01:00
scope = "Namespaced";
names = {
plural = "crontabs";
singular = "crontab";
kind = "CronTab";
shortNames = ["ct"];
};
};
};
2019-09-27 18:29:00 +02:00
kubernetes.customTypes = [{
name = "crontabs";
description = "CronTabs resources";
2020-01-14 19:13:33 +00:00
attrName = "cronTabs";
2019-02-28 14:04:47 +01:00
group = "stable.example.com";
version = "v1";
kind = "CronTab";
module = {
options.schedule = mkOption {
description = "Crontab schedule script";
type = types.str;
};
};
}];
2019-09-27 18:29:00 +02:00
kubernetes.resources.namespaces.test = {};
2019-02-28 14:04:47 +01:00
2019-09-27 18:29:00 +02:00
kubernetes.resources."stable.example.com"."v1".CronTab.crontab.spec.schedule = "* * * * *";
2019-02-28 14:04:47 +01:00
}