switch formatting to nixpkgs-fmt

This commit is contained in:
Bryton Hall 2023-07-07 22:01:34 -04:00
parent 3598716c73
commit 2712e89716
65 changed files with 4839 additions and 5222 deletions

View file

@ -1,20 +1,15 @@
{
system ? builtins.currentSystem,
evalModules ? (import ../. {}).evalModules.${system},
}: {
k8sVersion ? "1.23",
registry ? throw "Registry url not defined",
doThrowError ? true, # whether any testing error should throw an error
enabledTests ? null,
}: let
{ system ? builtins.currentSystem, evalModules ? (import ../. { }).evalModules.${system} }:
{ k8sVersion ? "1.23"
, registry ? throw "Registry url not defined"
, doThrowError ? true
# whether any testing error should throw an error
, enabledTests ? null
}:
let
inherit
((evalModules {
module = {
kubenix,
pkgs,
...
}: {
imports = [kubenix.modules.testing];
module = { kubenix, pkgs, ... }: {
imports = [ kubenix.modules.testing ];
testing = {
inherit doThrowError enabledTests;
@ -38,21 +33,19 @@
./submodules/passthru.nix
];
args = {images = pkgs.callPackage ./images.nix {};};
args = { images = pkgs.callPackage ./images.nix { }; };
docker.registryUrl = registry;
common = [
{
features = ["k8s"];
options = {
kubernetes.version = k8sVersion;
};
}
];
common = [{
features = [ "k8s" ];
options = {
kubernetes.version = k8sVersion;
};
}];
};
};
}))
config
;
in
config.testing // {recurseForDerivations = true;}
config.testing // { recurseForDerivations = true; }

View file

@ -1,11 +1,4 @@
{
config,
lib,
pkgs,
kubenix,
helm,
...
}:
{ config, lib, pkgs, kubenix, helm, ... }:
with lib;
with kubenix.lib;
with pkgs.dockerTools; let
@ -35,8 +28,9 @@ with pkgs.dockerTools; let
finalImageName = "docker.io/bitnami/bitnami-shell";
finalImageTag = "10";
};
in {
imports = [kubenix.modules.test kubenix.modules.helm kubenix.modules.k8s kubenix.modules.docker];
in
{
imports = [ kubenix.modules.test kubenix.modules.helm kubenix.modules.k8s kubenix.modules.docker ];
docker.images = {
postgresql.image = postgresql;

View file

@ -1,44 +1,40 @@
{
pkgs,
dockerTools,
lib,
...
}:
{ pkgs, dockerTools, lib, ... }:
with lib; {
curl = dockerTools.buildLayeredImage {
name = "curl";
tag = "latest";
config.Cmd = ["${pkgs.bash}" "-c" "sleep infinity"];
contents = [pkgs.bash pkgs.curl pkgs.cacert];
config.Cmd = [ "${pkgs.bash}" "-c" "sleep infinity" ];
contents = [ pkgs.bash pkgs.curl pkgs.cacert ];
};
nginx = let
nginxPort = "80";
nginxConf = pkgs.writeText "nginx.conf" ''
user nginx nginx;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
access_log /dev/stdout;
server {
listen ${nginxPort};
index index.html;
location / {
root ${nginxWebRoot};
nginx =
let
nginxPort = "80";
nginxConf = pkgs.writeText "nginx.conf" ''
user nginx nginx;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
access_log /dev/stdout;
server {
listen ${nginxPort};
index index.html;
location / {
root ${nginxWebRoot};
}
}
}
}
'';
nginxWebRoot = pkgs.writeTextDir "index.html" ''
<html><body><h1>Hello from NGINX</h1></body></html>
'';
in
'';
nginxWebRoot = pkgs.writeTextDir "index.html" ''
<html><body><h1>Hello from NGINX</h1></body></html>
'';
in
dockerTools.buildLayeredImage {
name = "xtruder/nginx";
tag = "latest";
contents = [pkgs.nginx];
contents = [ pkgs.nginx ];
extraCommands = ''
mkdir -p etc
chmod u+w etc
@ -50,9 +46,9 @@ with lib; {
echo "nginx:x:1000:nginx" > etc/group
'';
config = {
Cmd = ["nginx" "-c" nginxConf];
Cmd = [ "nginx" "-c" nginxConf ];
ExposedPorts = {
"${nginxPort}/tcp" = {};
"${nginxPort}/tcp" = { };
};
};
};

View file

@ -1,5 +1,5 @@
{kubenix, ...}: {
imports = with kubenix.modules; [test k8s istio];
{ kubenix, ... }: {
imports = with kubenix.modules; [ test k8s istio ];
test = {
name = "istio-bookinfo";
@ -17,7 +17,7 @@
name = "http";
protocol = "HTTP";
};
hosts = ["*"];
hosts = [ "*" ];
}
];
};
@ -25,8 +25,8 @@
VirtualService.bookinfo = {
spec = {
hosts = ["*"];
gateways = ["bookinfo-gateway"];
hosts = [ "*" ];
gateways = [ "bookinfo-gateway" ];
http = [
{
match = [

View file

@ -1,24 +1,18 @@
{
config,
lib,
kubenix,
...
}:
{ config, lib, kubenix, ... }:
with lib; let
latestCrontab = config.kubernetes.api.resources.cronTabs.latest;
in {
imports = with kubenix.modules; [test k8s];
in
{
imports = with kubenix.modules; [ test k8s ];
test = {
name = "k8s-crd";
description = "Simple test tesing CRD";
enable = builtins.compareVersions config.kubernetes.version "1.8" >= 0;
assertions = [
{
message = "Custom resource should have correct version set";
assertion = latestCrontab.apiVersion == "stable.example.com/v2";
}
];
assertions = [{
message = "Custom resource should have correct version set";
assertion = latestCrontab.apiVersion == "stable.example.com/v2";
}];
script = ''
@pytest.mark.applymanifest('${config.kubernetes.resultYAML}')
def test_testing_module(kube):

View file

@ -1,14 +1,10 @@
{
config,
lib,
kubenix,
...
}:
{ config, lib, kubenix, ... }:
with lib; let
inherit (config.kubernetes.api.resources.pods) pod1;
inherit (config.kubernetes.api.resources.pods) pod2;
in {
imports = with kubenix.modules; [test k8s];
in
{
imports = with kubenix.modules; [ test k8s ];
test = {
name = "k8s-defaults";
@ -29,7 +25,7 @@ in {
];
};
kubernetes.resources.pods.pod1 = {};
kubernetes.resources.pods.pod1 = { };
kubernetes.resources.pods.pod2 = {
metadata.labels.custom-label = "value";
@ -48,7 +44,7 @@ in {
}
{
resource = "pods";
default = {config, ...}: {
default = { config, ... }: {
config.metadata.annotations = mkIf (config.metadata.labels ? "custom-label") {
conditional-annotation = "value";
};

View file

@ -1,11 +1,4 @@
{
config,
lib,
kubenix,
images,
test,
...
}:
{ config, lib, kubenix, images, test, ... }:
with lib; let
cfg = config.kubernetes.api.resources.deployments.nginx;
image = images.nginx;
@ -17,17 +10,16 @@ with lib; let
inherit (config.kubernetes) namespace;
name = "curl";
};
spec.containers = [
{
name = "curl";
image = config.docker.images.curl.path;
args = ["curl" "--retry" "20" "--retry-connrefused" "http://nginx"];
}
];
spec.containers = [{
name = "curl";
image = config.docker.images.curl.path;
args = [ "curl" "--retry" "20" "--retry-connrefused" "http://nginx" ];
}];
spec.restartPolicy = "Never";
});
in {
imports = [kubenix.modules.test kubenix.modules.k8s kubenix.modules.docker];
in
{
imports = [ kubenix.modules.test kubenix.modules.k8s kubenix.modules.docker ];
test = {
name = "k8s-deployment";

View file

@ -1,14 +1,10 @@
{
config,
lib,
kubenix,
...
}:
{ config, lib, kubenix, ... }:
with lib; let
pod = config.kubernetes.api.resources.core.v1.Pod.test;
deployment = config.kubernetes.api.resources.apps.v1.Deployment.nginx-deployment;
in {
imports = with kubenix.modules; [test k8s];
in
{
imports = with kubenix.modules; [ test k8s ];
test = {
name = "k8s-imports";

View file

@ -1,11 +1,6 @@
{
config,
lib,
kubenix,
...
}:
{ config, lib, kubenix, ... }:
with lib; {
imports = with kubenix.modules; [test k8s];
imports = with kubenix.modules; [ test k8s ];
test = {
name = "k8s-order";
@ -39,7 +34,7 @@ with lib; {
plural = "crontabs";
singular = "crontab";
kind = "CronTab";
shortNames = ["ct"];
shortNames = [ "ct" ];
};
};
};
@ -62,7 +57,7 @@ with lib; {
}
];
kubernetes.resources.namespaces.test = {};
kubernetes.resources.namespaces.test = { };
kubernetes.resources."stable.example.com"."v1".CronTab.crontab.spec.schedule = "* * * * *";
}

View file

@ -1,11 +1,9 @@
{
config,
kubenix,
...
}: let
{ config, kubenix, ... }:
let
cfg = config.kubernetes.api.resources.pods.nginx;
in {
imports = [kubenix.modules.test kubenix.modules.k8s];
in
{
imports = [ kubenix.modules.test kubenix.modules.k8s ];
test = {
name = "k8s-simple";
@ -22,5 +20,5 @@ in {
];
};
kubernetes.resources.pods.nginx = {};
kubernetes.resources.pods.nginx = { };
}

View file

@ -1,13 +1,6 @@
{
name,
config,
lib,
kubenix,
images,
...
}:
{ name, config, lib, kubenix, images, ... }:
with lib; {
imports = with kubenix.modules; [test submodules k8s docker];
imports = with kubenix.modules; [ test submodules k8s docker ];
test = {
name = "k8s-submodule";
@ -26,41 +19,33 @@ with lib; {
kubernetes.namespace = "test-namespace";
submodules.imports = [
{
module = {
name,
config,
...
}: {
imports = with kubenix.modules; [submodule k8s docker];
submodules.imports = [{
module = { name, config, ... }: {
imports = with kubenix.modules; [ submodule k8s docker ];
config = {
submodule = {
name = "test-submodule";
passthru = {
kubernetes.objects = config.kubernetes.objects;
docker.images = config.docker.images;
};
config = {
submodule = {
name = "test-submodule";
passthru = {
kubernetes.objects = config.kubernetes.objects;
docker.images = config.docker.images;
};
kubernetes.resources.pods.nginx = {
metadata.name = name;
spec.containers.nginx.image = config.docker.images.nginx.path;
};
docker.images.nginx.image = images.nginx;
};
};
}
];
kubernetes.api.defaults = [
{
propagate = true;
default.metadata.labels.my-label = "my-value";
}
];
kubernetes.resources.pods.nginx = {
metadata.name = name;
spec.containers.nginx.image = config.docker.images.nginx.path;
};
docker.images.nginx.image = images.nginx;
};
};
}];
kubernetes.api.defaults = [{
propagate = true;
default.metadata.labels.my-label = "my-value";
}];
submodules.instances.passthru = {
submodule = "test-submodule";

View file

@ -1,10 +1,4 @@
{
name,
config,
lib,
kubenix,
...
}:
{ name, config, lib, kubenix, ... }:
with lib; let
inherit (config.submodules.instances) instance1;
inherit (config.submodules.instances) instance2;
@ -13,8 +7,8 @@ with lib; let
inherit (config.submodules.instances) instance5;
inherit (config.submodules.instances) versioned-submodule;
submodule = {...}: {
imports = [kubenix.modules.submodule];
submodule = { ... }: {
imports = [ kubenix.modules.submodule ];
options.submodule.args = {
value = mkOption {
@ -28,8 +22,9 @@ with lib; let
};
};
};
in {
imports = with kubenix.modules; [test submodules];
in
{
imports = with kubenix.modules; [ test submodules ];
test = {
name = "submodules-defaults";
@ -80,7 +75,7 @@ in {
{
submodule = {
name = "submodule1";
tags = ["tag1"];
tags = [ "tag1" ];
};
}
];
@ -91,7 +86,7 @@ in {
{
submodule = {
name = "submodule2";
tags = ["tag2"];
tags = [ "tag2" ];
};
}
];
@ -102,7 +97,7 @@ in {
{
submodule = {
name = "submodule3";
tags = ["tag2"];
tags = [ "tag2" ];
};
}
];
@ -146,11 +141,11 @@ in {
default.submodule.args.defaultValue = mkDefault "value";
}
{
tags = ["tag1"];
tags = [ "tag1" ];
default.submodule.args.value = mkDefault "value1";
}
{
tags = ["tag2"];
tags = [ "tag2" ];
default.submodule.args.value = mkDefault "value2";
}
{
@ -158,7 +153,7 @@ in {
default.submodule.args.value = mkDefault "value4";
}
{
default = {config, ...}: {
default = { config, ... }: {
submodule.args.defaultValue = mkIf (config.submodule.args.value == "custom-value") "my-custom-value";
};
}

View file

@ -1,14 +1,7 @@
{
name,
config,
lib,
kubenix,
subm-lib,
...
}:
{ name, config, lib, kubenix, subm-lib, ... }:
with lib; let
submodule = {
imports = [kubenix.modules.submodule];
imports = [ kubenix.modules.submodule ];
config.submodule = {
name = "subm";
@ -17,8 +10,9 @@ with lib; let
};
};
};
in {
imports = with kubenix.modules; [test submodules];
in
{
imports = with kubenix.modules; [ test submodules ];
test = {
name = "submodules-exports";
@ -33,7 +27,7 @@ in {
submodules.imports = [
{
modules = [submodule];
modules = [ submodule ];
exportAs = "subm-lib";
}
];

View file

@ -1,27 +1,22 @@
{
name,
config,
lib,
kubenix,
...
}:
{ name, config, lib, kubenix, ... }:
with lib; let
submodule = {name, ...}: {
imports = [kubenix.modules.submodule];
submodule = { name, ... }: {
imports = [ kubenix.modules.submodule ];
config.submodule = {
name = "subm";
passthru.global.${name} = "true";
};
};
in {
imports = with kubenix.modules; [test submodules];
in
{
imports = with kubenix.modules; [ test submodules ];
options = {
global = mkOption {
description = "Global value";
type = types.attrs;
default = {};
default = { };
};
};
@ -45,11 +40,9 @@ in {
];
};
submodules.imports = [
{
modules = [submodule];
}
];
submodules.imports = [{
modules = [ submodule ];
}];
submodules.instances.inst1 = {
submodule = "subm";

View file

@ -1,15 +1,10 @@
{
name,
config,
lib,
kubenix,
...
}:
{ name, config, lib, kubenix, ... }:
with lib; let
cfg = config.submodules.instances.instance;
inherit (cfg.config.submodule) args;
in {
imports = with kubenix.modules; [test submodules];
in
{
imports = with kubenix.modules; [ test submodules ];
test = {
name = "submodules-simple";
@ -45,8 +40,8 @@ in {
submodules.propagate.enable = true;
submodules.imports = [
{
module = {submodule, ...}: {
imports = [kubenix.modules.submodule];
module = { submodule, ... }: {
imports = [ kubenix.modules.submodule ];
options.submodule.args = {
name = mkOption {
@ -62,7 +57,7 @@ in {
config = {
submodule.name = "submodule";
submodule.tags = ["tag"];
submodule.tags = [ "tag" ];
};
};
}

View file

@ -1,17 +1,11 @@
{
name,
config,
lib,
kubenix,
...
}:
{ name, config, lib, kubenix, ... }:
with lib; let
inst-exact = config.submodules.instances.inst-exact.config;
inst-regex = config.submodules.instances.inst-regex.config;
inst-latest = config.submodules.instances.inst-latest.config;
submodule = {
imports = [kubenix.modules.submodule];
imports = [ kubenix.modules.submodule ];
options.version = mkOption {
type = types.str;
@ -20,8 +14,9 @@ with lib; let
config.submodule.name = "subm";
};
in {
imports = with kubenix.modules; [test submodules];
in
{
imports = with kubenix.modules; [ test submodules ];
test = {
name = "submodules-versioning";