Skip to content

Commit

Permalink
fix: a docker section in global/user config caused 'stack new' to try…
Browse files Browse the repository at this point in the history
… to start a container
  • Loading branch information
borsboom committed Oct 12, 2015
1 parent 3e9b1a8 commit 6a9261f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
8 changes: 7 additions & 1 deletion src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,13 @@ loadConfig :: (MonadLogger m,MonadIO m,MonadCatch m,MonadThrow m,MonadBaseContro
loadConfig configArgs mstackYaml = do
stackRoot <- determineStackRoot
userConfigPath <- getDefaultUserConfigPath stackRoot
extraConfigs <- getExtraConfigs userConfigPath >>= mapM loadYaml
extraConfigs0 <- getExtraConfigs userConfigPath >>= mapM loadYaml
let extraConfigs =
-- non-project config files' existence of a docker section should never default docker
-- to enabled, so make it look like they didn't exist
map (\c -> c {configMonoidDockerOpts =
(configMonoidDockerOpts c) {dockerMonoidDefaultEnable = False}})
extraConfigs0
mproject <- loadProjectConfig mstackYaml
config <- configFromConfigMonoid stackRoot userConfigPath (fmap (\(proj, _, _) -> proj) mproject) $ mconcat $
case mproject of
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Config/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dockerOptsFromMonoid
=> Maybe Project -> Path Abs Dir -> DockerOptsMonoid -> m DockerOpts
dockerOptsFromMonoid mproject stackRoot DockerOptsMonoid{..} = do
let dockerEnable =
fromMaybe (fromMaybe False dockerMonoidExists) dockerMonoidEnable
fromMaybe dockerMonoidDefaultEnable dockerMonoidEnable
dockerImage =
let defaultTag =
case mproject of
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ configOptsParser docker =
dockerOptsParser :: Bool -> Parser DockerOptsMonoid
dockerOptsParser showOptions =
DockerOptsMonoid
<$> pure Nothing
<$> pure False
<*> maybeBoolFlags dockerCmdName
"using a Docker container"
hide
Expand Down
10 changes: 5 additions & 5 deletions src/Stack/Types/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ data DockerOpts = DockerOpts
-- | An uninterpreted representation of docker options.
-- Configurations may be "cascaded" using mappend (left-biased).
data DockerOptsMonoid = DockerOptsMonoid
{dockerMonoidExists :: !(Maybe Bool)
-- ^ Does a @docker:@ section exist in the top-level (usually project) config?
{dockerMonoidDefaultEnable :: !Bool
-- ^ Should Docker be defaulted to enabled (does @docker:@ section exist in the config)?
,dockerMonoidEnable :: !(Maybe Bool)
-- ^ Is using Docker enabled?
,dockerMonoidRepoOrImage :: !(Maybe DockerMonoidRepoOrImage)
Expand Down Expand Up @@ -92,7 +92,7 @@ data DockerOptsMonoid = DockerOptsMonoid
-- | Decode uninterpreted docker options from JSON/YAML.
instance FromJSON (DockerOptsMonoid, [JSONWarning]) where
parseJSON = withObjectWarnings "DockerOptsMonoid"
(\o -> do dockerMonoidExists <- pure (Just True)
(\o -> do dockerMonoidDefaultEnable <- pure True
dockerMonoidEnable <- o ..:? dockerEnableArgName
dockerMonoidRepoOrImage <- ((Just . DockerMonoidImage) <$> o ..: dockerImageArgName) <|>
((Just . DockerMonoidRepo) <$> o ..: dockerRepoArgName) <|>
Expand All @@ -115,7 +115,7 @@ instance FromJSON (DockerOptsMonoid, [JSONWarning]) where
-- | Left-biased combine Docker options
instance Monoid DockerOptsMonoid where
mempty = DockerOptsMonoid
{dockerMonoidExists = Just False
{dockerMonoidDefaultEnable = False
,dockerMonoidEnable = Nothing
,dockerMonoidRepoOrImage = Nothing
,dockerMonoidRegistryLogin = Nothing
Expand All @@ -133,7 +133,7 @@ instance Monoid DockerOptsMonoid where
,dockerMonoidSetUser = Nothing
}
mappend l r = DockerOptsMonoid
{dockerMonoidExists = dockerMonoidExists l <|> dockerMonoidExists r
{dockerMonoidDefaultEnable = dockerMonoidDefaultEnable l || dockerMonoidDefaultEnable r
,dockerMonoidEnable = dockerMonoidEnable l <|> dockerMonoidEnable r
,dockerMonoidRepoOrImage = dockerMonoidRepoOrImage l <|> dockerMonoidRepoOrImage r
,dockerMonoidRegistryLogin = dockerMonoidRegistryLogin l <|> dockerMonoidRegistryLogin r
Expand Down

0 comments on commit 6a9261f

Please sign in to comment.