MCPcopy Index your code
hub / github.com/docker/docker-py / write_context_name_to_docker_config

Function write_context_name_to_docker_config

docker/context/config.py:24–46  ·  view source on GitHub ↗
(name=None)

Source from the content-addressed store, hash-verified

22
23
24def write_context_name_to_docker_config(name=None):
25 if name == 'default':
26 name = None
27 docker_cfg_path = find_config_file()
28 config = {}
29 if docker_cfg_path:
30 try:
31 with open(docker_cfg_path) as f:
32 config = json.load(f)
33 except Exception as e:
34 return e
35 current_context = config.get("currentContext", None)
36 if current_context and not name:
37 del config["currentContext"]
38 elif name:
39 config["currentContext"] = name
40 else:
41 return
42 try:
43 with open(docker_cfg_path, "w") as f:
44 json.dump(config, f, indent=4)
45 except Exception as e:
46 return e
47
48
49def get_context_id(name):

Callers 2

set_current_contextMethod · 0.85
remove_contextMethod · 0.85

Calls 3

find_config_fileFunction · 0.90
loadMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected