MCPcopy
hub / github.com/docker/docker-py / save

Method save

docker/context/context.py:146–171  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

144 self.tls_path = tls_dir
145
146 def save(self):
147 meta_dir = get_meta_dir(self.name)
148 if not os.path.isdir(meta_dir):
149 os.makedirs(meta_dir)
150 with open(get_meta_file(self.name), "w") as f:
151 f.write(json.dumps(self.Metadata))
152
153 tls_dir = get_tls_dir(self.name)
154 for endpoint, tls in self.tls_cfg.items():
155 if not os.path.isdir(os.path.join(tls_dir, endpoint)):
156 os.makedirs(os.path.join(tls_dir, endpoint))
157
158 ca_file = tls.ca_cert
159 if ca_file:
160 copyfile(ca_file, os.path.join(
161 tls_dir, endpoint, os.path.basename(ca_file)))
162
163 if tls.cert:
164 cert_file, key_file = tls.cert
165 copyfile(cert_file, os.path.join(
166 tls_dir, endpoint, os.path.basename(cert_file)))
167 copyfile(key_file, os.path.join(
168 tls_dir, endpoint, os.path.basename(key_file)))
169
170 self.meta_path = get_meta_dir(self.name)
171 self.tls_path = get_tls_dir(self.name)
172
173 def remove(self):
174 if os.path.isdir(self.meta_path):

Callers 1

create_contextMethod · 0.95

Calls 4

get_meta_dirFunction · 0.85
get_meta_fileFunction · 0.85
get_tls_dirFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected