From b959ab492d0a435ef3aab9df9617d1c303f195f6 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 11 Oct 2020 12:02:58 +0200 Subject: [PATCH] Move name -> project.name --- docs/modules/ROOT/partials/NixOSOptions.adoc | 40 +++++++++---------- examples/minimal/arion-compose.nix | 2 +- src/haskell/exe/Main.hs | 4 +- src/haskell/lib/Arion/ExtendedInfo.hs | 4 +- .../testdata/Arion/NixSpec/arion-compose.json | 4 +- .../testdata/docker-compose-example.json | 4 +- src/nix/modules/composition/composition.nix | 4 +- 7 files changed, 33 insertions(+), 29 deletions(-) diff --git a/docs/modules/ROOT/partials/NixOSOptions.adoc b/docs/modules/ROOT/partials/NixOSOptions.adoc index 98253bc..34f4bfb 100644 --- a/docs/modules/ROOT/partials/NixOSOptions.adoc +++ b/docs/modules/ROOT/partials/NixOSOptions.adoc @@ -68,26 +68,6 @@ intended for production-like deployment scenarios. Type:: signed integer No Default:: {blank} -No Example:: {blank} - -== name - -Name of the project. - -See link:https://docs.docker.com/compose/reference/envvars/#compose_project_name[COMPOSE_PROJECT_NAME] - - -[discrete] -=== details - -Type:: null or string -Default:: -+ ----- -null ----- - - No Example:: {blank} == out.dockerComposeYaml @@ -126,6 +106,26 @@ No Default:: {blank} Read Only:: {blank} No Example:: {blank} +== project.name + +Name of the project. + +See link:https://docs.docker.com/compose/reference/envvars/#compose_project_name[COMPOSE_PROJECT_NAME] + + +[discrete] +=== details + +Type:: null or string +Default:: ++ +---- +null +---- + + +No Example:: {blank} + == services An attribute set of service configurations. A service specifies how to run an image as a container. diff --git a/examples/minimal/arion-compose.nix b/examples/minimal/arion-compose.nix index e864794..9531a9f 100644 --- a/examples/minimal/arion-compose.nix +++ b/examples/minimal/arion-compose.nix @@ -1,6 +1,6 @@ { pkgs, ... }: { - config.name = "webapp"; + config.project.name = "webapp"; config.services = { webserver = { diff --git a/src/haskell/exe/Main.hs b/src/haskell/exe/Main.hs index ca219c9..0492b2c 100644 --- a/src/haskell/exe/Main.hs +++ b/src/haskell/exe/Main.hs @@ -10,7 +10,7 @@ import Arion.Aeson import Arion.Images (loadImages) import qualified Arion.DockerCompose as DockerCompose import Arion.Services (getDefaultExec) -import Arion.ExtendedInfo (loadExtendedInfoFromPath, ExtendedInfo(images, name)) +import Arion.ExtendedInfo (loadExtendedInfoFromPath, ExtendedInfo(images, projectName)) import Options.Applicative import Control.Monad.Fail @@ -155,7 +155,7 @@ callDC cmd dopts shouldLoadImages path = do when shouldLoadImages $ loadImages (images extendedInfo) let firstOpts = do - n <- toList (name extendedInfo) + n <- toList (projectName extendedInfo) ["--project-name", n] DockerCompose.run DockerCompose.Args { files = [path] diff --git a/src/haskell/lib/Arion/ExtendedInfo.hs b/src/haskell/lib/Arion/ExtendedInfo.hs index dbdf338..92a7668 100644 --- a/src/haskell/lib/Arion/ExtendedInfo.hs +++ b/src/haskell/lib/Arion/ExtendedInfo.hs @@ -23,7 +23,7 @@ data Image = Image } deriving (Eq, Show, Generic, Aeson.ToJSON, Aeson.FromJSON) data ExtendedInfo = ExtendedInfo { - name :: Maybe Text, + projectName :: Maybe Text, images :: [Image] } deriving (Eq, Show) @@ -32,6 +32,6 @@ loadExtendedInfoFromPath fp = do v <- decodeFile fp pure ExtendedInfo { -- TODO: use aeson derived instance? - name = v ^? key "x-arion" . key "name" . _String, + projectName = v ^? key "x-arion" . key "project" . key "name" . _String, images = (v :: Aeson.Value) ^.. key "x-arion" . key "images" . _Array . traverse . _JSON } diff --git a/src/haskell/testdata/Arion/NixSpec/arion-compose.json b/src/haskell/testdata/Arion/NixSpec/arion-compose.json index 63c239d..479fe96 100644 --- a/src/haskell/testdata/Arion/NixSpec/arion-compose.json +++ b/src/haskell/testdata/Arion/NixSpec/arion-compose.json @@ -37,7 +37,9 @@ "imageTag": "" } ], - "name": null, + "project": { + "name": null + }, "serviceInfo": { "webserver": { "defaultExec": [ diff --git a/src/haskell/testdata/docker-compose-example.json b/src/haskell/testdata/docker-compose-example.json index 6392c4d..6fdaa0b 100644 --- a/src/haskell/testdata/docker-compose-example.json +++ b/src/haskell/testdata/docker-compose-example.json @@ -30,7 +30,9 @@ "imageTag": "xr4ljmz3qfcwlq9rl4mr4qdrzw93rl70" } ], - "name": null, + "project": { + "name": null + }, "serviceInfo": { "webserver": { "defaultExec": [ diff --git a/src/nix/modules/composition/composition.nix b/src/nix/modules/composition/composition.nix index fe4daf9..fa46617 100644 --- a/src/nix/modules/composition/composition.nix +++ b/src/nix/modules/composition/composition.nix @@ -8,7 +8,7 @@ let in { options = { - name = mkOption { + project.name = mkOption { description = '' Name of the project. @@ -19,6 +19,6 @@ in }; }; config = { - docker-compose.extended.name = config.name; + docker-compose.extended.project.name = config.project.name; }; }