-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding support for CHALK_BYPASS environment variable
this allows to completely skip chalk when wrapping `docker`. Whenever its enabled, chalk directly proxies the command to `docker` without invoking any of the chalk internal machinery such as loading configs/etc
- Loading branch information
Showing
6 changed files
with
52 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## | ||
## Copyright (c) 2024, Crash Override, Inc. | ||
## | ||
## This file is part of Chalk | ||
## (see https://crashoverride.com/docs/chalk) | ||
## | ||
|
||
import std/[os, strutils] | ||
import pkg/nimutils/[file] | ||
import "."/[util] | ||
|
||
proc bypassChalk*() = | ||
## Bypasses any chalk execution if possible and directly execs the underlying command. | ||
## Note this function explicitly writes to stderr for "logging" to avoid invoking | ||
## any of the con4m machinery. | ||
if getEnv("CHALK_BYPASS").toLower() notin @["1", "true", "on"]: | ||
return | ||
|
||
let | ||
(path, exe) = getAppFilename().splitPath() | ||
# setup.sh for example stores chalkless variants of binaries | ||
# in chalkless folder | ||
# we need to account for it as otherwise original binary | ||
# might not be on PATH overwise | ||
# and as we don't load the chalk config here as a precaution | ||
# and so we must mimic disk structure directly | ||
chalklessDir = path.parentDir().joinPath("chalkless") | ||
|
||
case exe | ||
of "docker": | ||
let chalkless = file.findExePath(exe, extraPaths = @[chalklessDir]) | ||
if chalkless == "": | ||
stderr.writeLine("Could not find " & exe & " to exec while bypassing chalk") | ||
quitChalk(1) | ||
handleExec(@[chalkless], commandLineParams(), log = false) | ||
else: | ||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
default_command: "docker" | ||
error("chalk is wrapping docker") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters