File tree Expand file tree Collapse file tree 4 files changed +92
-1
lines changed
tests/modules/programs/docker-cli Expand file tree Collapse file tree 4 files changed +92
-1
lines changed Original file line number Diff line number Diff line change 3232 '' ;
3333 } ;
3434
35+ contexts = mkOption {
36+ type = lib . types . listOf (
37+ lib . types . submodule {
38+ freeformType = jsonFormat . type ;
39+ options . Name = lib . mkOption {
40+ type = lib . types . str ;
41+ description = "The name of the Docker context" ;
42+ } ;
43+ }
44+ ) ;
45+ default = [ ] ;
46+ example = lib . literalExpression ''
47+ [
48+ {
49+ Name = "example";
50+ Metadata = {
51+ Description = "example1";
52+
53+ };
54+ Endpoints = {
55+ docker = {
56+ Host = "unix://example2";
57+ };
58+ };
59+ }
60+ ];
61+ '' ;
62+ description = ''
63+ Array of docker context configurations. See:
64+ <https://docs.docker.com/engine/manage-resources/contexts/
65+ '' ;
66+ } ;
67+
3568 settings = mkOption {
3669 type = jsonFormat . type ;
3770 default = { } ;
6295 "${ cfg . configDir } /config.json" = {
6396 source = jsonFormat . generate "config.json" cfg . settings ;
6497 } ;
65- } ;
98+ }
99+ // builtins . listToAttrs (
100+ map ( s : {
101+ name = "${ cfg . configDir } /contexts/meta/${ builtins . hashString "sha256" s . Name } /meta.json" ;
102+ value = {
103+ source = jsonFormat . generate "config.json" s ;
104+ } ;
105+ } ) cfg . contexts
106+ ) ;
66107 } ;
67108 } ;
68109}
Original file line number Diff line number Diff line change 11{
22 docker-cli = ./example-config.nix ;
33 docker-cli-empty-config = ./empty-config.nix ;
4+ docker-cli-contexts = ./example-contexts.nix ;
45}
Original file line number Diff line number Diff line change 1+ {
2+ "Endpoints" : {
3+ "docker" : {
4+ "Host" : " unix://example2"
5+ }
6+ },
7+ "Metadata" : {
8+ "Description" : " example1"
9+ },
10+ "Name" : " example"
11+ }
Original file line number Diff line number Diff line change 1+ {
2+ config ,
3+ ...
4+ } :
5+ {
6+ programs . docker-cli = {
7+ enable = true ;
8+
9+ configDir = ".docker2" ;
10+
11+ contexts = [
12+ {
13+ Name = "example" ;
14+ Metadata = {
15+ Description = "example1" ;
16+
17+ } ;
18+ Endpoints = {
19+ docker = {
20+ Host = "unix://example2" ;
21+ } ;
22+ } ;
23+ }
24+ ] ;
25+ } ;
26+
27+ nmt . script =
28+ let
29+ cfgDocker = config . programs . docker-cli ;
30+ configTestPath = "home-files/${ cfgDocker . configDir } /contexts/meta/50d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c/meta.json" ;
31+ in
32+ ''
33+ assertPathNotExists home-files/.docker/config.json
34+ assertFileExists ${ configTestPath }
35+ assertFileContent ${ configTestPath } \
36+ ${ ./example-contexts.json }
37+ '' ;
38+ }
You can’t perform that action at this time.
0 commit comments