Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re #6633 Refactor Stack.Docker vis-a-vis keepStdinOpen #6635

Merged
merged 1 commit into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .stan.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@

# Anti-pattern: Data.ByteString.Char8.pack
[[ignore]]
id = "OBS-STAN-0203-axv1UG-355:32"
id = "OBS-STAN-0203-axv1UG-354:32"
# ✦ Description: Usage of 'pack' function that doesn't handle Unicode characters
# ✦ Category: #AntiPattern
# ✦ File: src\Stack\Docker.hs
#
# 354
# 355 ┃ hashRepoName = Hash.hash . BS.pack . takeWhile (\c -> c /= ':' && c /= '@')
# 356 ┃ ^^^^^^^
# 353
# 354 ┃ hashRepoName = Hash.hash . BS.pack . takeWhile (\c -> c /= ':' && c /= '@')
# 355 ┃ ^^^^^^^

# Data types with non-strict fields
# Defining lazy fields in data types can lead to unexpected space leaks
Expand Down
11 changes: 5 additions & 6 deletions src/Stack/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ runContainerAndExit = do
dockerCertPath = lookup "DOCKER_CERT_PATH" env
bamboo = lookup "bamboo_buildKey" env
jenkins = lookup "JENKINS_HOME" env
notBambooAndNotJenkins = isNothing bamboo && isNothing jenkins
msshAuthSock = lookup "SSH_AUTH_SOCK" env
muserEnv = lookup "USER" env
isRemoteDocker = maybe False (isPrefixOf "tcp://") dockerHost
Expand Down Expand Up @@ -242,15 +243,13 @@ runContainerAndExit = do
platformVariant = show $ hashRepoName image
stackRoot = view stackRootL config
sandboxHomeDir = sandboxDir </> homeDirName
isTerm = not docker.detach &&
isStdinTerminal &&
isStdoutTerminal &&
isStderrTerminal
isTerm = isStdinTerminal && isStdoutTerminal && isStderrTerminal
allocatePseudoTty = not docker.detach && isTerm
keepStdinOpen = not docker.detach &&
-- Workaround for https://github.com/docker/docker/issues/12319
-- This is fixed in Docker 1.9.1, but will leave the workaround
-- in place for now, for users who haven't upgraded yet.
(isTerm || (isNothing bamboo && isNothing jenkins))
(isTerm || notBambooAndNotJenkins)
let mpath = T.pack <$> lookupImageEnv "PATH" imageEnvVars
when (isNothing mpath) $ do
prettyWarnL
Expand Down Expand Up @@ -335,7 +334,7 @@ runContainerAndExit = do
, case docker.containerName of
Just name -> ["--name=" ++ name]
Nothing -> []
, ["-t" | isTerm]
, ["-t" | allocatePseudoTty]
, ["-i" | keepStdinOpen]
, docker.runArgs
, [image]
Expand Down
Loading