docker-cli: add docker contexts support
Adds docker-cli.contexts support. This allows declarative configuration of [docker contexts](https://docs.docker.com/engine/manage-resources/contexts/).
This commit is contained in:
parent
25ca7d297f
commit
990e5ce679
4 changed files with 93 additions and 1 deletions
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
docker-cli = ./example-config.nix;
|
||||
docker-cli-empty-config = ./empty-config.nix;
|
||||
docker-cli-contexts = ./example-contexts.nix;
|
||||
}
|
||||
|
|
|
|||
11
tests/modules/programs/docker-cli/example-contexts.json
Normal file
11
tests/modules/programs/docker-cli/example-contexts.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"Endpoints": {
|
||||
"docker": {
|
||||
"Host": "unix://example2"
|
||||
}
|
||||
},
|
||||
"Metadata": {
|
||||
"Description": "example1"
|
||||
},
|
||||
"Name": "example"
|
||||
}
|
||||
36
tests/modules/programs/docker-cli/example-contexts.nix
Normal file
36
tests/modules/programs/docker-cli/example-contexts.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
programs.docker-cli = {
|
||||
enable = true;
|
||||
|
||||
configDir = ".docker2";
|
||||
|
||||
contexts = {
|
||||
example = {
|
||||
Metadata = {
|
||||
Description = "example1";
|
||||
};
|
||||
Endpoints = {
|
||||
docker = {
|
||||
Host = "unix://example2";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
cfgDocker = config.programs.docker-cli;
|
||||
configTestPath = "home-files/${cfgDocker.configDir}/contexts/meta/50d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c/meta.json";
|
||||
in
|
||||
''
|
||||
assertPathNotExists home-files/.docker/config.json
|
||||
assertFileExists ${configTestPath}
|
||||
assertFileContent ${configTestPath} \
|
||||
${./example-contexts.json}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue