snapctl 0.47.2__tar.gz → 0.48.0__tar.gz
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-0.47.2 → snapctl-0.48.0}/PKG-INFO +21 -56
- {snapctl-0.47.2 → snapctl-0.48.0}/README.md +20 -55
- {snapctl-0.47.2 → snapctl-0.48.0}/pyproject.toml +1 -1
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/commands/byogs.py +30 -29
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/commands/byosnap.py +67 -56
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/config/constants.py +2 -1
- snapctl-0.48.0/snapctl/data/releases/beta-0.48.0.mdx +19 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/main.py +3 -3
- {snapctl-0.47.2 → snapctl-0.48.0}/LICENSE +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/__init__.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/__main__.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/commands/__init__.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/commands/game.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/commands/generate.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/commands/release_notes.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/commands/snapend.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/config/__init__.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/config/endpoints.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/config/hashes.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/data/profiles/snapser-byosnap-profile.json +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/data/profiles/snapser-byosnap-profile.yaml +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/data/profiles/snapser-byosnap-profile.yml +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/data/releases/beta-0.46.0.mdx +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/data/releases/beta-0.46.4.mdx +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/data/releases/beta-0.47.0.mdx +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/data/releases/beta-0.47.1.mdx +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/data/releases/beta-0.47.2.mdx +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/types/__init__.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/types/definitions.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/utils/__init__.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/utils/echo.py +0 -0
- {snapctl-0.47.2 → snapctl-0.48.0}/snapctl/utils/helper.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: snapctl
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.48.0
|
|
4
4
|
Summary: Snapser CLI Tool
|
|
5
5
|
Author: Ajinkya Apte
|
|
6
6
|
Author-email: aj@snapser.com
|
|
@@ -24,58 +24,23 @@ Snapser has developed a CLI tool called **snapctl** that can be used on MaxOSX,
|
|
|
24
24
|
Snapctl will be the best way for game studios to integrate Snapser into their build pipelines.
|
|
25
25
|
|
|
26
26
|
## What's new in the latest version?
|
|
27
|
-
###
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
- The manifest path variable has been changed for Snapend commands like `apply` and `clone`
|
|
45
|
-
from `--manifest-path` to `--manifest-path-filename`, for consistency with our new
|
|
46
|
-
variable naming nomenclature.
|
|
47
|
-
- The Snapend download command has new variable names like `format` and `type`. This is to add
|
|
48
|
-
more consistency and clarity to the command.
|
|
49
|
-
```bash
|
|
50
|
-
# Previously
|
|
51
|
-
# snapctl snapend download --snapend-id gx5x6bc0 --category sdk --type unity --sdk-access-type external --sdk-auth-type user --out-path .
|
|
52
|
-
|
|
53
|
-
# New
|
|
54
|
-
snapctl snapend download --snapend-id gx5x6bc0 --category sdk --format unity --type user --out-path .
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
- Input param `--docker` for BYOGS and BYOSnap commands has been changed to `--docker_filename`
|
|
58
|
-
|
|
59
|
-
### New Commands
|
|
60
|
-
- **BYOSnap Generate Profile**: You can now use a new command to generate a base BYOSnap profile.
|
|
61
|
-
```bash
|
|
62
|
-
snapctl byosnap generate-profile --out-path $outputPath --profile-filename $profileName
|
|
63
|
-
```
|
|
64
|
-
- **BYOSnap Validate Profile**: After you hand edit the base BYOSnap profile, you can use this
|
|
65
|
-
command to validate your BYOSnap profile before using it in other commands like `publish` and `sync`
|
|
66
|
-
```bash
|
|
67
|
-
snapctl byosnap validate-profile --path $path --profile-filename $profileName
|
|
68
|
-
# or
|
|
69
|
-
snapctl byosnap validate-profile --resources-path $resources_path --profile-filename $profileName
|
|
70
|
-
```
|
|
71
|
-
- **Release Notes**: You can now view release notes for a specific version of Snapctl using the
|
|
72
|
-
`release-notes` command.
|
|
73
|
-
```bash
|
|
74
|
-
snapctl release-notes releases
|
|
75
|
-
snapctl release-notes show
|
|
76
|
-
# or
|
|
77
|
-
snapctl release-notes show --version $version
|
|
78
|
-
```
|
|
27
|
+
### Features
|
|
28
|
+
1. Dockerfile can now be present either at the root or the resources path. Snapctl will automatically look for the Dockerfile in both locations.
|
|
29
|
+
2. Snapctl now throws a better warning when the swagger for the BYOSnap is not compatible with what the Snapser backed expects. You will get a warning message:
|
|
30
|
+
```bash
|
|
31
|
+
Warning Snapser enforces a strict schema for the swagger.json file. It needs to be a valid OpenAPI 3.0 spec. In addition, ever API needs an operationId. a summary and
|
|
32
|
+
a non-empty description. This allows Snapser to generate your SDK and power the API explorer. If you do not wish to leverage this feature, just remove the
|
|
33
|
+
swagger.json file.
|
|
34
|
+
```
|
|
35
|
+
3. You can now use the `--skip-build` flag with the snapctl sync command. This allows you to skip the build step when syncing your Snapend resources.
|
|
36
|
+
```bash
|
|
37
|
+
byosnap sync --snapend-id $snapendId --byosnap-id $byosnapId --version $version --path $path --skip-build
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Fixes
|
|
41
|
+
1. Snapctl was failing if the user passed in a tag with a `:` in it. This has been fixed. It now checks for the presence of a `:` in the tag and throws an error in the input validation step.
|
|
42
|
+
2. The byosnap generate command was failing. This has been fixed.
|
|
43
|
+
|
|
79
44
|
|
|
80
45
|
## Requirements
|
|
81
46
|
### Python 3.X and Pip
|
|
@@ -310,7 +275,7 @@ can deploy it.
|
|
|
310
275
|
- This command needs a BYOSnap profile. BYOSnap profile, holds information about
|
|
311
276
|
your BYOSnap like, name, description, etc and hardware requirements like CPU, Memory. We
|
|
312
277
|
recommend you store this file at the root of your BYOSnap and also add it to version control.
|
|
313
|
-
You can generate it using `snapctl generate
|
|
278
|
+
You can generate it using `snapctl byosnap generate-profile --out-path $outputPath --profile-filename $profileName`.
|
|
314
279
|
|
|
315
280
|
```bash
|
|
316
281
|
# Help for the byosnap command
|
|
@@ -462,7 +427,7 @@ Publish a new version for your Snap. Only after your Snap version is published,
|
|
|
462
427
|
to use your snap in your Snapend. This command should be run after `push` or `publish-image` commands.
|
|
463
428
|
|
|
464
429
|
IMPORTANT: You need to have $byosnapProfile to run this command. BYOSnap profile is a JSON configuration
|
|
465
|
-
of your BYOSnap for the development, staging and production environments. You can generate a base version of this file using the `snapctl generate
|
|
430
|
+
of your BYOSnap for the development, staging and production environments. You can generate a base version of this file using the `snapctl byosnap generate-profile --out-path $outputPath --profile-filename $profileName` command.
|
|
466
431
|
|
|
467
432
|
```bash
|
|
468
433
|
# Help for the byosnap command
|
|
@@ -472,7 +437,7 @@ snapctl byosnap publish-version --help
|
|
|
472
437
|
# $byosnap_id = Snap ID for your snap
|
|
473
438
|
# $image_tag = An image tag for your snap
|
|
474
439
|
# $version = Semantic version for your snap Eg: v0.0.1
|
|
475
|
-
# $byosnap_profile_path = Path to the snapser-byosnap-profile.json BYOSnap profile to configure dev, stage and prod settings for this snap. You can generate a base version of this file using the `snapctl generate
|
|
440
|
+
# $byosnap_profile_path = Path to the snapser-byosnap-profile.json BYOSnap profile to configure dev, stage and prod settings for this snap. You can generate a base version of this file using the `snapctl byosnap generate-profile --out-path $outputPath --profile-filename $profileName` command
|
|
476
441
|
# Example:
|
|
477
442
|
# snapctl byosnap publish-version --byosnap-id byosnap-jinks-flask --tag my-first-image --version v0.0.1 --path /Users/DevName/Development/SnapserEngine/jinks_flask
|
|
478
443
|
snapctl byosnap publish-version --byosnap-id $byosnap_id --tag $image_tag --version $version --path $byosnap_profile_path
|
|
@@ -4,58 +4,23 @@ Snapser has developed a CLI tool called **snapctl** that can be used on MaxOSX,
|
|
|
4
4
|
Snapctl will be the best way for game studios to integrate Snapser into their build pipelines.
|
|
5
5
|
|
|
6
6
|
## What's new in the latest version?
|
|
7
|
-
###
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- The manifest path variable has been changed for Snapend commands like `apply` and `clone`
|
|
25
|
-
from `--manifest-path` to `--manifest-path-filename`, for consistency with our new
|
|
26
|
-
variable naming nomenclature.
|
|
27
|
-
- The Snapend download command has new variable names like `format` and `type`. This is to add
|
|
28
|
-
more consistency and clarity to the command.
|
|
29
|
-
```bash
|
|
30
|
-
# Previously
|
|
31
|
-
# snapctl snapend download --snapend-id gx5x6bc0 --category sdk --type unity --sdk-access-type external --sdk-auth-type user --out-path .
|
|
32
|
-
|
|
33
|
-
# New
|
|
34
|
-
snapctl snapend download --snapend-id gx5x6bc0 --category sdk --format unity --type user --out-path .
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
- Input param `--docker` for BYOGS and BYOSnap commands has been changed to `--docker_filename`
|
|
38
|
-
|
|
39
|
-
### New Commands
|
|
40
|
-
- **BYOSnap Generate Profile**: You can now use a new command to generate a base BYOSnap profile.
|
|
41
|
-
```bash
|
|
42
|
-
snapctl byosnap generate-profile --out-path $outputPath --profile-filename $profileName
|
|
43
|
-
```
|
|
44
|
-
- **BYOSnap Validate Profile**: After you hand edit the base BYOSnap profile, you can use this
|
|
45
|
-
command to validate your BYOSnap profile before using it in other commands like `publish` and `sync`
|
|
46
|
-
```bash
|
|
47
|
-
snapctl byosnap validate-profile --path $path --profile-filename $profileName
|
|
48
|
-
# or
|
|
49
|
-
snapctl byosnap validate-profile --resources-path $resources_path --profile-filename $profileName
|
|
50
|
-
```
|
|
51
|
-
- **Release Notes**: You can now view release notes for a specific version of Snapctl using the
|
|
52
|
-
`release-notes` command.
|
|
53
|
-
```bash
|
|
54
|
-
snapctl release-notes releases
|
|
55
|
-
snapctl release-notes show
|
|
56
|
-
# or
|
|
57
|
-
snapctl release-notes show --version $version
|
|
58
|
-
```
|
|
7
|
+
### Features
|
|
8
|
+
1. Dockerfile can now be present either at the root or the resources path. Snapctl will automatically look for the Dockerfile in both locations.
|
|
9
|
+
2. Snapctl now throws a better warning when the swagger for the BYOSnap is not compatible with what the Snapser backed expects. You will get a warning message:
|
|
10
|
+
```bash
|
|
11
|
+
Warning Snapser enforces a strict schema for the swagger.json file. It needs to be a valid OpenAPI 3.0 spec. In addition, ever API needs an operationId. a summary and
|
|
12
|
+
a non-empty description. This allows Snapser to generate your SDK and power the API explorer. If you do not wish to leverage this feature, just remove the
|
|
13
|
+
swagger.json file.
|
|
14
|
+
```
|
|
15
|
+
3. You can now use the `--skip-build` flag with the snapctl sync command. This allows you to skip the build step when syncing your Snapend resources.
|
|
16
|
+
```bash
|
|
17
|
+
byosnap sync --snapend-id $snapendId --byosnap-id $byosnapId --version $version --path $path --skip-build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Fixes
|
|
21
|
+
1. Snapctl was failing if the user passed in a tag with a `:` in it. This has been fixed. It now checks for the presence of a `:` in the tag and throws an error in the input validation step.
|
|
22
|
+
2. The byosnap generate command was failing. This has been fixed.
|
|
23
|
+
|
|
59
24
|
|
|
60
25
|
## Requirements
|
|
61
26
|
### Python 3.X and Pip
|
|
@@ -290,7 +255,7 @@ can deploy it.
|
|
|
290
255
|
- This command needs a BYOSnap profile. BYOSnap profile, holds information about
|
|
291
256
|
your BYOSnap like, name, description, etc and hardware requirements like CPU, Memory. We
|
|
292
257
|
recommend you store this file at the root of your BYOSnap and also add it to version control.
|
|
293
|
-
You can generate it using `snapctl generate
|
|
258
|
+
You can generate it using `snapctl byosnap generate-profile --out-path $outputPath --profile-filename $profileName`.
|
|
294
259
|
|
|
295
260
|
```bash
|
|
296
261
|
# Help for the byosnap command
|
|
@@ -442,7 +407,7 @@ Publish a new version for your Snap. Only after your Snap version is published,
|
|
|
442
407
|
to use your snap in your Snapend. This command should be run after `push` or `publish-image` commands.
|
|
443
408
|
|
|
444
409
|
IMPORTANT: You need to have $byosnapProfile to run this command. BYOSnap profile is a JSON configuration
|
|
445
|
-
of your BYOSnap for the development, staging and production environments. You can generate a base version of this file using the `snapctl generate
|
|
410
|
+
of your BYOSnap for the development, staging and production environments. You can generate a base version of this file using the `snapctl byosnap generate-profile --out-path $outputPath --profile-filename $profileName` command.
|
|
446
411
|
|
|
447
412
|
```bash
|
|
448
413
|
# Help for the byosnap command
|
|
@@ -452,7 +417,7 @@ snapctl byosnap publish-version --help
|
|
|
452
417
|
# $byosnap_id = Snap ID for your snap
|
|
453
418
|
# $image_tag = An image tag for your snap
|
|
454
419
|
# $version = Semantic version for your snap Eg: v0.0.1
|
|
455
|
-
# $byosnap_profile_path = Path to the snapser-byosnap-profile.json BYOSnap profile to configure dev, stage and prod settings for this snap. You can generate a base version of this file using the `snapctl generate
|
|
420
|
+
# $byosnap_profile_path = Path to the snapser-byosnap-profile.json BYOSnap profile to configure dev, stage and prod settings for this snap. You can generate a base version of this file using the `snapctl byosnap generate-profile --out-path $outputPath --profile-filename $profileName` command
|
|
456
421
|
# Example:
|
|
457
422
|
# snapctl byosnap publish-version --byosnap-id byosnap-jinks-flask --tag my-first-image --version v0.0.1 --path /Users/DevName/Development/SnapserEngine/jinks_flask
|
|
458
423
|
snapctl byosnap publish-version --byosnap-id $byosnap_id --tag $image_tag --version $version --path $byosnap_profile_path
|
|
@@ -49,6 +49,9 @@ class ByoGs:
|
|
|
49
49
|
self.path: Union[str, None] = path
|
|
50
50
|
self.resources_path: Union[str, None] = resources_path
|
|
51
51
|
self.docker_filename: str = docker_filename
|
|
52
|
+
self.docker_path_filename: Union[str, None] = ByoGs._make_dockerfile_path(
|
|
53
|
+
path, resources_path, docker_filename
|
|
54
|
+
)
|
|
52
55
|
self.skip_build: bool = skip_build
|
|
53
56
|
self.snapend_id: Union[str, None] = snapend_id
|
|
54
57
|
self.fleet_names: Union[str, None] = fleet_names
|
|
@@ -63,6 +66,22 @@ class ByoGs:
|
|
|
63
66
|
self.validate_input()
|
|
64
67
|
|
|
65
68
|
# Protected methods
|
|
69
|
+
@staticmethod
|
|
70
|
+
def _make_dockerfile_path(path: str, resources_path: str, docker_filename: str) -> Union[str, None]:
|
|
71
|
+
"""
|
|
72
|
+
Check for the existence of a Dockerfile in the given `path` and `resources_path`.
|
|
73
|
+
Returns the path where the Dockerfile is found, or an empty string if not found.
|
|
74
|
+
"""
|
|
75
|
+
# Check the primary path
|
|
76
|
+
if path and os.path.isfile(os.path.join(path, docker_filename)):
|
|
77
|
+
return os.path.join(path, docker_filename)
|
|
78
|
+
|
|
79
|
+
# Check the resources path
|
|
80
|
+
if resources_path and os.path.isfile(os.path.join(resources_path, docker_filename)):
|
|
81
|
+
return os.path.join(resources_path, docker_filename)
|
|
82
|
+
|
|
83
|
+
# Return empty string if not found in either location
|
|
84
|
+
return None
|
|
66
85
|
|
|
67
86
|
@staticmethod
|
|
68
87
|
def _get_token_values(token: str) -> Union[None, List]:
|
|
@@ -185,17 +204,11 @@ class ByoGs:
|
|
|
185
204
|
build_platform = ByoGs.DEFAULT_BUILD_PLATFORM
|
|
186
205
|
if len(self.token_parts) == 4:
|
|
187
206
|
build_platform = self.token_parts[3]
|
|
188
|
-
# Build your snap
|
|
189
|
-
if self.resources_path:
|
|
190
|
-
base_path = self.resources_path
|
|
191
|
-
else:
|
|
192
|
-
base_path = self.path
|
|
193
|
-
docker_file_path = os.path.join(base_path, self.docker_filename)
|
|
194
207
|
|
|
195
208
|
# Warning check for architecture specific commands
|
|
196
209
|
info(f'Building on system architecture {sys_platform.machine()}')
|
|
197
210
|
check_response = check_dockerfile_architecture(
|
|
198
|
-
|
|
211
|
+
self.docker_path_filename, sys_platform.machine())
|
|
199
212
|
if check_response['error']:
|
|
200
213
|
warning(check_response['message'])
|
|
201
214
|
# Build the image
|
|
@@ -203,7 +216,7 @@ class ByoGs:
|
|
|
203
216
|
response = subprocess.run([
|
|
204
217
|
# f"docker build --no-cache -t {tag} {path}"
|
|
205
218
|
'docker', 'build', '--platform', build_platform, '-t', self.tag,
|
|
206
|
-
'-f',
|
|
219
|
+
'-f', self.docker_path_filename, self.path
|
|
207
220
|
], shell=True, check=False)
|
|
208
221
|
# stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
|
209
222
|
else:
|
|
@@ -211,7 +224,7 @@ class ByoGs:
|
|
|
211
224
|
# f"docker build --no-cache -t {tag} {path}"
|
|
212
225
|
"docker build --platform " +
|
|
213
226
|
f"{build_platform} -t {self.tag} " +
|
|
214
|
-
f"-f {
|
|
227
|
+
f"-f {self.docker_path_filename} {self.path}"
|
|
215
228
|
], shell=True, check=False)
|
|
216
229
|
# stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
|
217
230
|
if not response.returncode:
|
|
@@ -366,37 +379,25 @@ class ByoGs:
|
|
|
366
379
|
code=SNAPCTL_INPUT_ERROR
|
|
367
380
|
)
|
|
368
381
|
if self.subcommand in ['build', 'publish']:
|
|
382
|
+
# Check path
|
|
369
383
|
if not self.skip_build and not self.path:
|
|
370
384
|
snapctl_error(
|
|
371
385
|
message="Missing required parameter: path",
|
|
372
386
|
code=SNAPCTL_INPUT_ERROR)
|
|
373
|
-
# Check path
|
|
374
|
-
if self.
|
|
375
|
-
docker_file_path = f"{self.resources_path}/{self.docker_filename}"
|
|
376
|
-
else:
|
|
377
|
-
docker_file_path = f"{self.path}/{self.docker_filename}"
|
|
378
|
-
|
|
379
|
-
if not self.skip_build and not os.path.isfile(docker_file_path):
|
|
387
|
+
# Check docker file path
|
|
388
|
+
if not self.skip_build and not self.docker_path_filename:
|
|
380
389
|
snapctl_error(
|
|
381
|
-
|
|
382
|
-
f"{self.docker_filename} at path {docker_file_path}",
|
|
383
|
-
code=SNAPCTL_INPUT_ERROR)
|
|
390
|
+
f"Unable to find {self.docker_path_filename}", SNAPCTL_INPUT_ERROR)
|
|
384
391
|
elif self.subcommand == 'sync':
|
|
392
|
+
# Check path
|
|
385
393
|
if not self.skip_build and not self.path:
|
|
386
394
|
snapctl_error(
|
|
387
395
|
message="Missing required parameter: path",
|
|
388
396
|
code=SNAPCTL_INPUT_ERROR)
|
|
389
|
-
# Check path
|
|
390
|
-
if self.
|
|
391
|
-
docker_file_path = f"{self.resources_path}/{self.docker_filename}"
|
|
392
|
-
else:
|
|
393
|
-
docker_file_path = f"{self.path}/{self.docker_filename}"
|
|
394
|
-
|
|
395
|
-
if not self.skip_build and not os.path.isfile(docker_file_path):
|
|
397
|
+
# Check docker file path
|
|
398
|
+
if not self.skip_build and not self.docker_path_filename:
|
|
396
399
|
snapctl_error(
|
|
397
|
-
|
|
398
|
-
f"{self.docker_filename} at path {docker_file_path}",
|
|
399
|
-
code=SNAPCTL_INPUT_ERROR)
|
|
400
|
+
f"Unable to find {self.docker_path_filename}", SNAPCTL_INPUT_ERROR)
|
|
400
401
|
if not self.snapend_id:
|
|
401
402
|
snapctl_error(
|
|
402
403
|
message="Missing required parameter: snapend_id",
|
|
@@ -29,7 +29,7 @@ from snapctl.config.constants import HTTP_ERROR_SERVICE_VERSION_EXISTS, \
|
|
|
29
29
|
SNAPCTL_BYOSNAP_UPDATE_VERSION_ERROR, SNAPCTL_BYOSNAP_UPDATE_VERSION_SERVICE_IN_USE_ERROR, \
|
|
30
30
|
SNAPCTL_BYOSNAP_UPDATE_VERSION_TAG_ERROR, SNAPCTL_BYOSNAP_NOT_FOUND, \
|
|
31
31
|
HTTP_ERROR_RESOURCE_NOT_FOUND, SNAPCTL_BYOSNAP_PUBLISH_ERROR, \
|
|
32
|
-
SNAPCTL_BYOSNAP_GENERATE_PROFILE_ERROR, SNAPCTL_CONFIGURATION_INCORRECT
|
|
32
|
+
SNAPCTL_BYOSNAP_GENERATE_PROFILE_ERROR, SNAPCTL_CONFIGURATION_INCORRECT, SNAPCTL_BYOSNAP_SWAGGER_ERROR
|
|
33
33
|
from snapctl.utils.echo import info, warning, success
|
|
34
34
|
from snapctl.utils.helper import get_composite_token, snapctl_error, snapctl_success, \
|
|
35
35
|
check_dockerfile_architecture, check_use_containerd_snapshotter
|
|
@@ -84,9 +84,14 @@ class ByoSnap:
|
|
|
84
84
|
self.api_key: Union[str, None] = api_key
|
|
85
85
|
self.byosnap_id: str = byosnap_id
|
|
86
86
|
self.tag: Union[str, None] = tag
|
|
87
|
+
# Remote tag is overridden in publish and sync
|
|
88
|
+
self.remote_tag: Union[str, None] = tag
|
|
87
89
|
self.path: Union[str, None] = path
|
|
88
90
|
self.resources_path: Union[str, None] = resources_path
|
|
89
91
|
self.docker_filename: str = docker_filename
|
|
92
|
+
self.docker_path_filename: Union[str, None] = ByoSnap._make_dockerfile_path(
|
|
93
|
+
path, resources_path, docker_filename
|
|
94
|
+
)
|
|
90
95
|
self.profile_filename: Union[str, None] = profile_filename
|
|
91
96
|
self.version: Union[str, None] = version
|
|
92
97
|
self.name: Union[str, None] = name
|
|
@@ -110,9 +115,26 @@ class ByoSnap:
|
|
|
110
115
|
self.readiness_path: Union[str, None] = None
|
|
111
116
|
self.readiness_delay: Union[str, None] = None
|
|
112
117
|
# Setup and Validate the input
|
|
113
|
-
self.
|
|
118
|
+
self.validate_input()
|
|
114
119
|
|
|
115
120
|
# Protected methods
|
|
121
|
+
@staticmethod
|
|
122
|
+
def _make_dockerfile_path(path: str, resources_path: str, docker_filename: str) -> Union[str, None]:
|
|
123
|
+
"""
|
|
124
|
+
Check for the existence of a Dockerfile in the given `path` and `resources_path`.
|
|
125
|
+
Returns the path where the Dockerfile is found, or an empty string if not found.
|
|
126
|
+
"""
|
|
127
|
+
# Check the primary path
|
|
128
|
+
if path and os.path.isfile(os.path.join(path, docker_filename)):
|
|
129
|
+
return os.path.join(path, docker_filename)
|
|
130
|
+
|
|
131
|
+
# Check the resources path
|
|
132
|
+
if resources_path and os.path.isfile(os.path.join(resources_path, docker_filename)):
|
|
133
|
+
return os.path.join(resources_path, docker_filename)
|
|
134
|
+
|
|
135
|
+
# Return empty string if not found in either location
|
|
136
|
+
return None
|
|
137
|
+
|
|
116
138
|
@staticmethod
|
|
117
139
|
def _get_token_values(token: str) -> Union[None, List]:
|
|
118
140
|
"""
|
|
@@ -692,33 +714,26 @@ class ByoSnap:
|
|
|
692
714
|
progress.add_task(
|
|
693
715
|
description='Building your snap...', total=None)
|
|
694
716
|
try:
|
|
695
|
-
# Build your snap
|
|
696
|
-
if self.resources_path:
|
|
697
|
-
base_path = self.resources_path
|
|
698
|
-
else:
|
|
699
|
-
base_path = self.path
|
|
700
|
-
docker_file_path = os.path.join(base_path, self.docker_filename)
|
|
701
|
-
|
|
702
717
|
# Warning check for architecture specific commands
|
|
703
718
|
info(f'Building on system architecture {sys_platform.machine()}')
|
|
704
719
|
check_response = check_dockerfile_architecture(
|
|
705
|
-
|
|
720
|
+
self.docker_path_filename, sys_platform.machine())
|
|
706
721
|
if check_response['error']:
|
|
707
722
|
warning(check_response['message'])
|
|
708
723
|
# Build the image
|
|
709
724
|
if platform == "win32":
|
|
710
725
|
response = subprocess.run([
|
|
711
|
-
# f"docker build --no-cache -t {
|
|
712
|
-
'docker', 'build', '--platform', build_platform, '-t', self.
|
|
713
|
-
'-f',
|
|
726
|
+
# f"docker build --no-cache -t {remote_tag} {path}"
|
|
727
|
+
'docker', 'build', '--platform', build_platform, '-t', self.remote_tag,
|
|
728
|
+
'-f', self.docker_path_filename, self.path
|
|
714
729
|
], shell=True, check=False)
|
|
715
730
|
# stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
|
716
731
|
else:
|
|
717
732
|
response = subprocess.run([
|
|
718
|
-
# f"docker build --no-cache -t {
|
|
733
|
+
# f"docker build --no-cache -t {remote_tag} {path}"
|
|
719
734
|
"docker build --platform " +
|
|
720
|
-
f"{build_platform} -t {self.
|
|
721
|
-
f"-f {
|
|
735
|
+
f"{build_platform} -t {self.remote_tag} " +
|
|
736
|
+
f"-f {self.docker_path_filename} {self.path}"
|
|
722
737
|
], shell=True, check=False)
|
|
723
738
|
# stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
|
724
739
|
if not response.returncode:
|
|
@@ -737,7 +752,7 @@ class ByoSnap:
|
|
|
737
752
|
def _docker_tag(self) -> None:
|
|
738
753
|
# Get the data
|
|
739
754
|
ecr_repo_url = self.token_parts[0]
|
|
740
|
-
image_tag = f'{self.byosnap_id}.{self.
|
|
755
|
+
image_tag = f'{self.byosnap_id}.{self.remote_tag}'
|
|
741
756
|
full_ecr_repo_url = f'{ecr_repo_url}:{image_tag}'
|
|
742
757
|
progress = Progress(
|
|
743
758
|
SpinnerColumn(),
|
|
@@ -840,7 +855,7 @@ class ByoSnap:
|
|
|
840
855
|
# Public methods
|
|
841
856
|
|
|
842
857
|
# Validate
|
|
843
|
-
def
|
|
858
|
+
def validate_input(self) -> None:
|
|
844
859
|
"""
|
|
845
860
|
Validator
|
|
846
861
|
"""
|
|
@@ -895,20 +910,16 @@ class ByoSnap:
|
|
|
895
910
|
f"{ByoSnap.TAG_CHARACTER_LIMIT} characters",
|
|
896
911
|
SNAPCTL_INPUT_ERROR
|
|
897
912
|
)
|
|
913
|
+
if ':' in self.tag:
|
|
914
|
+
snapctl_error("Tag should not contain `:` ",
|
|
915
|
+
SNAPCTL_INPUT_ERROR)
|
|
898
916
|
if not self.skip_build and not self.path:
|
|
899
917
|
snapctl_error("Missing required parameter: path",
|
|
900
918
|
SNAPCTL_INPUT_ERROR)
|
|
901
|
-
# Check path
|
|
902
|
-
if self.
|
|
903
|
-
docker_file_path = \
|
|
904
|
-
f"{self.resources_path}/{self.docker_filename}"
|
|
905
|
-
else:
|
|
906
|
-
docker_file_path = f"{self.path}/{self.docker_filename}"
|
|
907
|
-
if not self.skip_build and not os.path.isfile(docker_file_path):
|
|
919
|
+
# Check docker file path
|
|
920
|
+
if not self.skip_build and not self.docker_path_filename:
|
|
908
921
|
snapctl_error(
|
|
909
|
-
"Unable to find "
|
|
910
|
-
f"{self.docker_filename} at path {docker_file_path}",
|
|
911
|
-
SNAPCTL_INPUT_ERROR)
|
|
922
|
+
f"Unable to find {self.docker_path_filename}", SNAPCTL_INPUT_ERROR)
|
|
912
923
|
elif self.subcommand == 'upload-docs':
|
|
913
924
|
# Setup
|
|
914
925
|
self._setup_token_and_token_parts(
|
|
@@ -1008,17 +1019,10 @@ class ByoSnap:
|
|
|
1008
1019
|
snapctl_error(
|
|
1009
1020
|
message="Missing required parameter: path",
|
|
1010
1021
|
code=SNAPCTL_INPUT_ERROR)
|
|
1011
|
-
# Check path
|
|
1012
|
-
if self.
|
|
1013
|
-
docker_file_path = \
|
|
1014
|
-
f"{self.resources_path}/{self.docker_filename}"
|
|
1015
|
-
else:
|
|
1016
|
-
docker_file_path = f"{self.path}/{self.docker_filename}"
|
|
1017
|
-
if not self.skip_build and not os.path.isfile(docker_file_path):
|
|
1022
|
+
# Check docker file path
|
|
1023
|
+
if not self.skip_build and not self.docker_path_filename:
|
|
1018
1024
|
snapctl_error(
|
|
1019
|
-
|
|
1020
|
-
f"{self.docker_filename} at path {docker_file_path}",
|
|
1021
|
-
code=SNAPCTL_INPUT_ERROR)
|
|
1025
|
+
f"Unable to find {self.docker_path_filename}", SNAPCTL_INPUT_ERROR)
|
|
1022
1026
|
if not self.snapend_id:
|
|
1023
1027
|
snapctl_error(
|
|
1024
1028
|
message="Missing required parameter: snapend-id",
|
|
@@ -1036,20 +1040,10 @@ class ByoSnap:
|
|
|
1036
1040
|
code=SNAPCTL_INPUT_ERROR)
|
|
1037
1041
|
if not self.skip_build and not self.path:
|
|
1038
1042
|
snapctl_error(
|
|
1039
|
-
message="Missing required parameter: path",
|
|
1040
|
-
|
|
1041
|
-
# Check path
|
|
1042
|
-
if self.resources_path:
|
|
1043
|
-
docker_file_path = \
|
|
1044
|
-
f"{self.resources_path}/{self.docker_filename}"
|
|
1045
|
-
else:
|
|
1046
|
-
docker_file_path = f"{self.path}/{self.docker_filename}"
|
|
1047
|
-
if not self.skip_build and not os.path.isfile(docker_file_path):
|
|
1043
|
+
message="Missing required parameter: path", code=SNAPCTL_INPUT_ERROR)
|
|
1044
|
+
if not self.skip_build and not self.docker_path_filename:
|
|
1048
1045
|
snapctl_error(
|
|
1049
|
-
|
|
1050
|
-
f"{self.docker_filename} at path {docker_file_path}",
|
|
1051
|
-
code=SNAPCTL_INPUT_ERROR)
|
|
1052
|
-
|
|
1046
|
+
f"Unable to find {self.docker_path_filename}", SNAPCTL_INPUT_ERROR)
|
|
1053
1047
|
# Run the overrides
|
|
1054
1048
|
elif self.subcommand == 'generate-profile':
|
|
1055
1049
|
# Setup
|
|
@@ -1129,11 +1123,11 @@ class ByoSnap:
|
|
|
1129
1123
|
|
|
1130
1124
|
swagger_file = os.path.join(base_dir, 'swagger.json')
|
|
1131
1125
|
readme_file = os.path.join(base_dir, 'README.md')
|
|
1132
|
-
|
|
1133
1126
|
# Upload swagger.json
|
|
1134
1127
|
if os.path.isfile(swagger_file):
|
|
1135
1128
|
try:
|
|
1136
1129
|
with open(swagger_file, "rb") as attachment_file:
|
|
1130
|
+
info(f'Uploading swagger.json at {swagger_file}')
|
|
1137
1131
|
url = (
|
|
1138
1132
|
f"{self.base_url}/v1/snapser-api/byosnaps/"
|
|
1139
1133
|
f"{self.byosnap_id}/docs/{self.tag}/openapispec"
|
|
@@ -1147,7 +1141,18 @@ class ByoSnap:
|
|
|
1147
1141
|
snapctl_success(
|
|
1148
1142
|
message='Uploaded swagger.json', progress=None, no_exit=True)
|
|
1149
1143
|
else:
|
|
1150
|
-
|
|
1144
|
+
static_message = 'Snapser enforces a strict schema for the swagger.json ' + \
|
|
1145
|
+
'file. It needs to be a valid OpenAPI 3.0 spec. In addition, ever API ' + \
|
|
1146
|
+
'needs an operationId. a summary and a non-empty description. This allows ' + \
|
|
1147
|
+
'Snapser to generate your SDK and power the API explorer. If you do not ' + \
|
|
1148
|
+
'wish to leverage this feature, just remove the swagger.json file.'
|
|
1149
|
+
warning(static_message)
|
|
1150
|
+
response_json = test_res.json()
|
|
1151
|
+
if 'details' in response_json:
|
|
1152
|
+
error_msg = f"Swagger upload error: {response_json['details']}"
|
|
1153
|
+
else:
|
|
1154
|
+
error_msg = 'Swagger upload error: In-compatible swagger.json file.'
|
|
1155
|
+
warning(error_msg)
|
|
1151
1156
|
except RequestException as e:
|
|
1152
1157
|
info(
|
|
1153
1158
|
'Exception: Unable to find swagger.json at ' +
|
|
@@ -1506,9 +1511,11 @@ class ByoSnap:
|
|
|
1506
1511
|
msg=f'BYOSnap {self.name} present. ' +
|
|
1507
1512
|
'Lets proceed',
|
|
1508
1513
|
)
|
|
1509
|
-
# Make the tag same as version
|
|
1510
|
-
self.tag = self.version
|
|
1511
1514
|
# Setup the token and token parts
|
|
1515
|
+
# Make the remote tag same as version if user is not passing the tag
|
|
1516
|
+
if self.tag is None:
|
|
1517
|
+
self.tag = self.version
|
|
1518
|
+
self.remote_tag = self.version
|
|
1512
1519
|
self._setup_token_and_token_parts(
|
|
1513
1520
|
self.base_url, self.api_key, self.byosnap_id)
|
|
1514
1521
|
# Now publish the image
|
|
@@ -1527,7 +1534,11 @@ class ByoSnap:
|
|
|
1527
1534
|
Sync the snap
|
|
1528
1535
|
'''
|
|
1529
1536
|
try:
|
|
1530
|
-
|
|
1537
|
+
# Make the remote tag same as version if user is not passing the tag
|
|
1538
|
+
if self.tag is None:
|
|
1539
|
+
time_string = str(int(time.time()))
|
|
1540
|
+
self.tag = f'{self.version}-{time_string}'
|
|
1541
|
+
self.remote_tag = f'{self.version}-{time_string}'
|
|
1531
1542
|
self.publish_image(no_exit=True)
|
|
1532
1543
|
self.update_version(no_exit=True)
|
|
1533
1544
|
byosnap_list: str = f"{self.byosnap_id}:{self.version}"
|
|
@@ -3,7 +3,7 @@ Constants used by snapctl
|
|
|
3
3
|
"""
|
|
4
4
|
COMPANY_NAME = 'Snapser'
|
|
5
5
|
VERSION_PREFIX = 'beta-'
|
|
6
|
-
VERSION = '0.
|
|
6
|
+
VERSION = '0.48.0'
|
|
7
7
|
CONFIG_FILE_MAC = '~/.snapser/config'
|
|
8
8
|
CONFIG_FILE_WIN = '%homepath%\\.snapser\\config'
|
|
9
9
|
|
|
@@ -73,6 +73,7 @@ SNAPCTL_BYOSNAP_UPDATE_VERSION_INVALID_VERSION_ERROR = 48
|
|
|
73
73
|
SNAPCTL_BYOSNAP_PUBLISH_ERROR = 49
|
|
74
74
|
# Starting with new error codes for BYOSNAP post
|
|
75
75
|
SNAPCTL_BYOSNAP_GENERATE_PROFILE_ERROR = 86
|
|
76
|
+
SNAPCTL_BYOSNAP_SWAGGER_ERROR = 87
|
|
76
77
|
|
|
77
78
|
# Game Errors - 50 - 60
|
|
78
79
|
SNAPCTL_GAME_NOT_FOUND = SNAPCTL_RESOURCE_NOT_FOUND
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## beta-0.48.0
|
|
2
|
+
##### April 11, 2025
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
1. Dockerfile can now be present either at the root or the resources path. Snapctl will automatically look for the Dockerfile in both locations.
|
|
6
|
+
2. Snapctl now throws a better warning when the swagger for the BYOSnap is not compatible with what the Snapser backed expects. You will get a warning message:
|
|
7
|
+
```bash
|
|
8
|
+
Warning Snapser enforces a strict schema for the swagger.json file. It needs to be a valid OpenAPI 3.0 spec. In addition, ever API needs an operationId. a summary and
|
|
9
|
+
a non-empty description. This allows Snapser to generate your SDK and power the API explorer. If you do not wish to leverage this feature, just remove the
|
|
10
|
+
swagger.json file.
|
|
11
|
+
```
|
|
12
|
+
3. You can now use the `--skip-build` flag with the snapctl sync command. This allows you to skip the build step when syncing your Snapend resources.
|
|
13
|
+
```bash
|
|
14
|
+
byosnap sync --snapend-id $snapendId --byosnap-id $byosnapId --version $version --path $path --skip-build
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Fixes
|
|
18
|
+
1. Snapctl was failing if the user passed in a tag with a `:` in it. This has been fixed. It now checks for the presence of a `:` in the tag and throws an error in the input validation step.
|
|
19
|
+
2. The byosnap generate command was failing. This has been fixed.
|
|
@@ -386,15 +386,15 @@ def byosnap(
|
|
|
386
386
|
help="(req: create) Language of your snap - " +
|
|
387
387
|
", ".join(ByoSnap.LANGUAGES) + "."
|
|
388
388
|
),
|
|
389
|
-
# publish-image
|
|
389
|
+
# publish-image, publish-version, publish, sync
|
|
390
390
|
tag: str = typer.Option(
|
|
391
391
|
None, "--tag", help=(
|
|
392
|
-
"(req: publish-image, publish-version, upload-docs) Tag for your snap"
|
|
392
|
+
"(req: publish-image, publish-version, upload-docs) (optional: publish, sync) Tag for your snap"
|
|
393
393
|
)
|
|
394
394
|
),
|
|
395
395
|
# overrides
|
|
396
396
|
skip_build: bool = typer.Option(
|
|
397
|
-
False, "--skip-build", help="(optional: publish-image, sync) Skip the build step. You have to pass the image tag you used during the build step."
|
|
397
|
+
False, "--skip-build", help="(optional: publish-image, publish, sync) Skip the build step. You have to pass the image tag you used during the build step."
|
|
398
398
|
),
|
|
399
399
|
docker_filename: str = typer.Option(
|
|
400
400
|
"Dockerfile", help="(optional override: publish, sync) Dockerfile name to use"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|