MCPcopy
hub / github.com/saltstack/salt / create

Function create

tools/container.py:43–149  ·  view source on GitHub ↗
(ctx: Context, image: str, name: str = "", platform: str = "")

Source from the content-addressed store, hash-verified

41 },
42)
43def create(ctx: Context, image: str, name: str = "", platform: str = ""):
44 onci = "GITHUB_WORKFLOW" in os.environ
45 workdir = "/salt"
46 home = "/root"
47 network = "ip6net"
48 tmpdir = tempfile.mkdtemp(prefix="salt-test-container")
49 if not onci and not has_network(ctx, network):
50 ctx.info(f"Creating docker network: {network}")
51 create_network(ctx, network)
52 if onci:
53 cwdname = pathlib.Path().resolve().name
54 workdir = f"/__w/{cwdname}/{cwdname}"
55 home = "/github/home"
56 env = {
57 "HOME": home,
58 "SKIP_REQUIREMENTS_INSTALL": "1",
59 "PRINT_TEST_SELECTION": "0",
60 "PRINT_TEST_PLAN_ONLY": "0",
61 "PRINT_SYSTEM_INFO": "0",
62 "RERUN_FAILURES": "0",
63 "SKIP_INITIAL_ONEDIR_FAILURES": "1",
64 "SKIP_INITIAL_GH_ACTIONS_FAILURES": "1",
65 "RAISE_DEPRECATIONS_RUNTIME_ERRORS": "1",
66 "LANG": "en_US.UTF-8",
67 "SHELL": "/bin/bash",
68 }
69 for var in [
70 "PIP_INDEX_URL",
71 "PIP_EXTRA_INDEX_URL",
72 "PIP_TRUSTED_HOST",
73 "PIP_DISABLE_PIP_VERSION_CHECK",
74 "SALT_TRANSPORT",
75 # Are both of these really needed?
76 "GITHUB_ACTIONS",
77 "GITHUB_ACTIONS_PIPELINE",
78 "CI",
79 "SKIP_CODE_COVERAGE",
80 "COVERAGE_CONTEXT",
81 "RERUN_FAILURES",
82 "COLUMNS",
83 "RAISE_DEPRECATIONS_RUNTIME_ERRORS",
84 "FIPS_TESTRUN",
85 ]:
86 if var in os.environ:
87 env[var] = os.environ[var]
88
89 pathlib.Path("/tmp/docker-var").mkdir(exist_ok=True)
90
91 cmd = [
92 "/usr/bin/docker",
93 "create",
94 f"--name={name}",
95 "--privileged",
96 f"--workdir={workdir}",
97 "-v",
98 f"{tmpdir}:/var/lib/docker",
99 ]
100 if platform:

Callers

nothing calls this directly

Calls 5

has_networkFunction · 0.85
create_networkFunction · 0.85
infoMethod · 0.45
extendMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected