(name=None)
| 22 | |
| 23 | |
| 24 | def 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 | |
| 49 | def get_context_id(name): |
no test coverage detected