snapctl 0.43.2__py3-none-any.whl → 0.46.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of snapctl might be problematic. Click here for more details.
- snapctl/commands/byogs.py +37 -18
- snapctl/commands/byosnap.py +623 -222
- snapctl/commands/generate.py +3 -71
- snapctl/commands/release_notes.py +65 -0
- snapctl/commands/snapend.py +91 -76
- snapctl/config/constants.py +11 -9
- snapctl/config/hashes.py +18 -25
- snapctl/data/profiles/snapser-byosnap-profile.json +62 -0
- snapctl/data/profiles/snapser-byosnap-profile.yaml +54 -0
- snapctl/data/releases/beta-0.46.0.mdx +55 -0
- snapctl/main.py +81 -67
- {snapctl-0.43.2.dist-info → snapctl-0.46.0.dist-info}/METADATA +199 -98
- snapctl-0.46.0.dist-info/RECORD +27 -0
- snapctl-0.43.2.dist-info/RECORD +0 -23
- {snapctl-0.43.2.dist-info → snapctl-0.46.0.dist-info}/LICENSE +0 -0
- {snapctl-0.43.2.dist-info → snapctl-0.46.0.dist-info}/WHEEL +0 -0
- {snapctl-0.43.2.dist-info → snapctl-0.46.0.dist-info}/entry_points.txt +0 -0
snapctl/commands/byogs.py
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import base64
|
|
5
5
|
from binascii import Error as BinasciiError
|
|
6
6
|
import os
|
|
7
|
+
import json
|
|
7
8
|
import subprocess
|
|
8
9
|
import time
|
|
9
10
|
import platform as sys_platform
|
|
@@ -36,30 +37,27 @@ class ByoGs:
|
|
|
36
37
|
def __init__(
|
|
37
38
|
self, *, subcommand: str, base_url: str, api_key: Union[str, None],
|
|
38
39
|
tag: Union[str, None] = None, path: Union[str, None] = None,
|
|
39
|
-
resources_path: Union[str, None] = None,
|
|
40
|
+
resources_path: Union[str, None] = None, docker_filename: Union[str, None] = None,
|
|
40
41
|
skip_build: bool = False, snapend_id: Union[str, None] = None,
|
|
41
42
|
fleet_names: Union[str, None] = None, blocking: bool = False
|
|
42
43
|
) -> None:
|
|
43
44
|
self.subcommand: str = subcommand
|
|
44
45
|
self.base_url: str = base_url
|
|
45
46
|
self.api_key: Union[str, None] = api_key
|
|
46
|
-
# self.sid: str = sid
|
|
47
|
-
# if subcommand == 'publish':
|
|
48
|
-
# self.sid = ByoGs.SID
|
|
49
|
-
|
|
50
|
-
self.token: Union[str, None] = get_composite_token(
|
|
51
|
-
base_url, api_key, 'byogs', {'service_id': ByoGs.SID}
|
|
52
|
-
)
|
|
53
|
-
self.token_parts: Union[List, None] = ByoGs._get_token_values(
|
|
54
|
-
self.token) if self.token is not None else None
|
|
55
47
|
self.tag: Union[str, None] = tag
|
|
56
48
|
self.path: Union[str, None] = path
|
|
57
49
|
self.resources_path: Union[str, None] = resources_path
|
|
58
|
-
self.
|
|
50
|
+
self.docker_filename: str = docker_filename
|
|
59
51
|
self.skip_build: bool = skip_build
|
|
60
52
|
self.snapend_id: Union[str, None] = snapend_id
|
|
61
53
|
self.fleet_names: Union[str, None] = fleet_names
|
|
62
54
|
self.blocking: bool = blocking
|
|
55
|
+
# Values below are derived values
|
|
56
|
+
self.token: Union[str, None] = get_composite_token(
|
|
57
|
+
base_url, api_key, 'byogs', {'service_id': ByoGs.SID}
|
|
58
|
+
)
|
|
59
|
+
self.token_parts: Union[List, None] = ByoGs._get_token_values(
|
|
60
|
+
self.token) if self.token is not None else None
|
|
63
61
|
# Validate input
|
|
64
62
|
self.validate_input()
|
|
65
63
|
|
|
@@ -130,6 +128,25 @@ class ByoGs:
|
|
|
130
128
|
try:
|
|
131
129
|
# Login to Snapser Registry
|
|
132
130
|
if platform == 'win32':
|
|
131
|
+
# Start: Hack for Windows
|
|
132
|
+
data = {
|
|
133
|
+
"auths": {
|
|
134
|
+
"https://index.docker.io/v1/": {}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# Path to the Docker config file, adjust the path as necessary
|
|
139
|
+
docker_config_path = os.path.expanduser(
|
|
140
|
+
'~\\.docker\\config.json')
|
|
141
|
+
|
|
142
|
+
# Ensure the directory exists
|
|
143
|
+
os.makedirs(os.path.dirname(docker_config_path), exist_ok=True)
|
|
144
|
+
|
|
145
|
+
# Write the data to the file
|
|
146
|
+
with open(docker_config_path, 'w', encoding='utf-8') as file:
|
|
147
|
+
json.dump(data, file)
|
|
148
|
+
info("Updated the docker config for docker login")
|
|
149
|
+
# End: Hack for Windows
|
|
133
150
|
response = subprocess.run([
|
|
134
151
|
'docker', 'login', '--username', ecr_repo_username,
|
|
135
152
|
'--password', ecr_repo_token, ecr_repo_url
|
|
@@ -172,7 +189,7 @@ class ByoGs:
|
|
|
172
189
|
base_path = self.resources_path
|
|
173
190
|
else:
|
|
174
191
|
base_path = self.path
|
|
175
|
-
docker_file_path = os.path.join(base_path, self.
|
|
192
|
+
docker_file_path = os.path.join(base_path, self.docker_filename)
|
|
176
193
|
|
|
177
194
|
# Warning check for architecture specific commands
|
|
178
195
|
info(f'Building on system architecture {sys_platform.machine()}')
|
|
@@ -354,14 +371,15 @@ class ByoGs:
|
|
|
354
371
|
code=SNAPCTL_INPUT_ERROR)
|
|
355
372
|
# Check path
|
|
356
373
|
if self.resources_path:
|
|
357
|
-
docker_file_path = f"{
|
|
374
|
+
docker_file_path = f"{
|
|
375
|
+
self.resources_path}/{self.docker_filename}"
|
|
358
376
|
else:
|
|
359
|
-
docker_file_path = f"{self.path}/{self.
|
|
377
|
+
docker_file_path = f"{self.path}/{self.docker_filename}"
|
|
360
378
|
|
|
361
379
|
if not self.skip_build and not os.path.isfile(docker_file_path):
|
|
362
380
|
snapctl_error(
|
|
363
381
|
message="Unable to find " +
|
|
364
|
-
f"{self.
|
|
382
|
+
f"{self.docker_filename} at path {docker_file_path}",
|
|
365
383
|
code=SNAPCTL_INPUT_ERROR)
|
|
366
384
|
elif self.subcommand == 'sync':
|
|
367
385
|
if not self.skip_build and not self.path:
|
|
@@ -370,14 +388,15 @@ class ByoGs:
|
|
|
370
388
|
code=SNAPCTL_INPUT_ERROR)
|
|
371
389
|
# Check path
|
|
372
390
|
if self.resources_path:
|
|
373
|
-
docker_file_path = f"{
|
|
391
|
+
docker_file_path = f"{
|
|
392
|
+
self.resources_path}/{self.docker_filename}"
|
|
374
393
|
else:
|
|
375
|
-
docker_file_path = f"{self.path}/{self.
|
|
394
|
+
docker_file_path = f"{self.path}/{self.docker_filename}"
|
|
376
395
|
|
|
377
396
|
if not self.skip_build and not os.path.isfile(docker_file_path):
|
|
378
397
|
snapctl_error(
|
|
379
398
|
message="Unable to find " +
|
|
380
|
-
f"{self.
|
|
399
|
+
f"{self.docker_filename} at path {docker_file_path}",
|
|
381
400
|
code=SNAPCTL_INPUT_ERROR)
|
|
382
401
|
if not self.snapend_id:
|
|
383
402
|
snapctl_error(
|