snapctl 0.38.4__py3-none-any.whl → 0.39.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 +18 -4
- snapctl/commands/byosnap.py +34 -17
- snapctl/config/constants.py +1 -1
- snapctl/main.py +11 -5
- {snapctl-0.38.4.dist-info → snapctl-0.39.0.dist-info}/METADATA +10 -4
- {snapctl-0.38.4.dist-info → snapctl-0.39.0.dist-info}/RECORD +9 -9
- {snapctl-0.38.4.dist-info → snapctl-0.39.0.dist-info}/LICENSE +0 -0
- {snapctl-0.38.4.dist-info → snapctl-0.39.0.dist-info}/WHEEL +0 -0
- {snapctl-0.38.4.dist-info → snapctl-0.39.0.dist-info}/entry_points.txt +0 -0
snapctl/commands/byogs.py
CHANGED
|
@@ -33,7 +33,8 @@ class ByoGs:
|
|
|
33
33
|
|
|
34
34
|
def __init__(
|
|
35
35
|
self, subcommand: str, base_url: str, api_key: Union[str, None],
|
|
36
|
-
input_tag: Union[str, None], path: Union[str, None],
|
|
36
|
+
input_tag: Union[str, None], path: Union[str, None],
|
|
37
|
+
resources_path: Union[str, None], dockerfile: str,
|
|
37
38
|
skip_build: bool = False
|
|
38
39
|
) -> None:
|
|
39
40
|
self.subcommand: str = subcommand
|
|
@@ -50,6 +51,7 @@ class ByoGs:
|
|
|
50
51
|
self.token) if self.token is not None else None
|
|
51
52
|
self.input_tag: Union[str, None] = input_tag
|
|
52
53
|
self.path: Union[str, None] = path
|
|
54
|
+
self.resources_path: Union[str, None] = resources_path
|
|
53
55
|
self.dockerfile: str = dockerfile
|
|
54
56
|
self.skip_build: bool = skip_build
|
|
55
57
|
# Validate input
|
|
@@ -151,7 +153,12 @@ class ByoGs:
|
|
|
151
153
|
if len(self.token_parts) == 4:
|
|
152
154
|
build_platform = self.token_parts[3]
|
|
153
155
|
# Build your snap
|
|
154
|
-
|
|
156
|
+
if self.resources_path:
|
|
157
|
+
base_path = self.resources_path
|
|
158
|
+
else:
|
|
159
|
+
base_path = self.path
|
|
160
|
+
docker_file_path = os.path.join(base_path, self.dockerfile)
|
|
161
|
+
|
|
155
162
|
# Warning check for architecture specific commands
|
|
156
163
|
info(f'Building on system architecture {sys_platform.machine()}')
|
|
157
164
|
check_response = check_dockerfile_architecture(
|
|
@@ -279,9 +286,16 @@ class ByoGs:
|
|
|
279
286
|
snapctl_error("Missing required parameter: path",
|
|
280
287
|
SNAPCTL_INPUT_ERROR)
|
|
281
288
|
# Check path
|
|
282
|
-
if
|
|
289
|
+
if self.resources_path:
|
|
290
|
+
docker_file_path = f"{self.resources_path}/{self.dockerfile}"
|
|
291
|
+
else:
|
|
292
|
+
docker_file_path = f"{self.path}/{self.dockerfile}"
|
|
293
|
+
|
|
294
|
+
if not self.skip_build and not os.path.isfile(docker_file_path):
|
|
283
295
|
snapctl_error(
|
|
284
|
-
|
|
296
|
+
"Unable to find " +
|
|
297
|
+
f"{self.dockerfile} at path {docker_file_path}",
|
|
298
|
+
SNAPCTL_INPUT_ERROR)
|
|
285
299
|
# elif self.subcommand == 'push':
|
|
286
300
|
# if not self.input_tag:
|
|
287
301
|
# error("Missing required parameter: tag", SNAPCTL_INPUT_ERROR)
|
snapctl/commands/byosnap.py
CHANGED
|
@@ -49,10 +49,10 @@ class ByoSnap:
|
|
|
49
49
|
def __init__(
|
|
50
50
|
self, subcommand: str, base_url: str, api_key: Union[str, None], sid: str, name: str,
|
|
51
51
|
desc: str, platform_type: str, language: str, input_tag: Union[str, None],
|
|
52
|
-
path: Union[str, None],
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
readiness_delay: Union[int, None] = None
|
|
52
|
+
path: Union[str, None], resources_path: Union[str, None], dockerfile: str,
|
|
53
|
+
prefix: str, version: Union[str, None], http_port: Union[int, None],
|
|
54
|
+
byosnap_profile: Union[str, None], skip_build: bool = False,
|
|
55
|
+
readiness_path: Union[str, None] = None, readiness_delay: Union[int, None] = None
|
|
56
56
|
) -> None:
|
|
57
57
|
self.subcommand: str = subcommand
|
|
58
58
|
self.base_url: str = base_url
|
|
@@ -73,6 +73,7 @@ class ByoSnap:
|
|
|
73
73
|
self.token) if self.token is not None else None
|
|
74
74
|
self.input_tag: Union[str, None] = input_tag
|
|
75
75
|
self.path: Union[str, None] = path
|
|
76
|
+
self.resources_path: Union[str, None] = resources_path
|
|
76
77
|
self.dockerfile: str = dockerfile
|
|
77
78
|
self.prefix: str = prefix
|
|
78
79
|
self.version: Union[str, None] = version
|
|
@@ -185,7 +186,12 @@ class ByoSnap:
|
|
|
185
186
|
description='Building your snap...', total=None)
|
|
186
187
|
try:
|
|
187
188
|
# Build your snap
|
|
188
|
-
|
|
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.dockerfile)
|
|
194
|
+
|
|
189
195
|
# Warning check for architecture specific commands
|
|
190
196
|
info(f'Building on system architecture {sys_platform.machine()}')
|
|
191
197
|
check_response = check_dockerfile_architecture(
|
|
@@ -416,19 +422,24 @@ class ByoSnap:
|
|
|
416
422
|
snapctl_error("Missing required parameter: path",
|
|
417
423
|
SNAPCTL_INPUT_ERROR)
|
|
418
424
|
# Check path
|
|
419
|
-
if
|
|
425
|
+
if self.resources_path:
|
|
426
|
+
docker_file_path = f"{
|
|
427
|
+
self.resources_path}/{self.dockerfile}"
|
|
428
|
+
else:
|
|
429
|
+
docker_file_path = f"{self.path}/{self.dockerfile}"
|
|
430
|
+
if not self.skip_build and not os.path.isfile(docker_file_path):
|
|
420
431
|
snapctl_error(
|
|
421
|
-
|
|
422
|
-
f"{self.dockerfile} at path {
|
|
432
|
+
"Unable to find " +
|
|
433
|
+
f"{self.dockerfile} at path {docker_file_path}",
|
|
423
434
|
SNAPCTL_INPUT_ERROR)
|
|
424
435
|
# elif self.subcommand == 'push':
|
|
425
436
|
# if not self.input_tag:
|
|
426
437
|
# error("Missing required parameter: tag", SNAPCTL_INPUT_ERROR)
|
|
427
438
|
# raise typer.Exit(code=SNAPCTL_INPUT_ERROR)
|
|
428
439
|
elif self.subcommand == 'upload-docs':
|
|
429
|
-
if self.path is None:
|
|
440
|
+
if self.path is None and self.resources_path is None:
|
|
430
441
|
snapctl_error(
|
|
431
|
-
"Missing
|
|
442
|
+
"Missing one of: path or resources-path parameter", SNAPCTL_INPUT_ERROR)
|
|
432
443
|
elif self.subcommand == 'publish-version':
|
|
433
444
|
if not self.input_tag:
|
|
434
445
|
snapctl_error(
|
|
@@ -516,8 +527,14 @@ class ByoSnap:
|
|
|
516
527
|
progress.add_task(
|
|
517
528
|
description='Uploading your BYOSnap Docs...', total=None)
|
|
518
529
|
try:
|
|
519
|
-
|
|
520
|
-
|
|
530
|
+
if self.resources_path:
|
|
531
|
+
base_dir = self.resources_path
|
|
532
|
+
else:
|
|
533
|
+
base_dir = self.path
|
|
534
|
+
|
|
535
|
+
swagger_file = os.path.join(base_dir, 'swagger.json')
|
|
536
|
+
readme_file = os.path.join(base_dir, 'README.md')
|
|
537
|
+
|
|
521
538
|
if os.path.isfile(swagger_file):
|
|
522
539
|
# Push the swagger.json
|
|
523
540
|
try:
|
|
@@ -538,11 +555,11 @@ class ByoSnap:
|
|
|
538
555
|
except RequestException as e:
|
|
539
556
|
info(
|
|
540
557
|
'Exception: Unable to find swagger.json at ' +
|
|
541
|
-
f'{
|
|
558
|
+
f'{base_dir} {e}'
|
|
542
559
|
)
|
|
543
560
|
else:
|
|
544
561
|
info(
|
|
545
|
-
f'No swagger.json found at {
|
|
562
|
+
f'No swagger.json found at {base_dir}' +
|
|
546
563
|
'. Skipping swagger.json upload'
|
|
547
564
|
)
|
|
548
565
|
|
|
@@ -567,11 +584,11 @@ class ByoSnap:
|
|
|
567
584
|
except RequestException as e:
|
|
568
585
|
info(
|
|
569
586
|
'Exception: Unable to find README.md at ' +
|
|
570
|
-
f'{
|
|
587
|
+
f'{base_dir} {str(e)}'
|
|
571
588
|
)
|
|
572
589
|
else:
|
|
573
590
|
info(
|
|
574
|
-
f'No README.md found at {
|
|
591
|
+
f'No README.md found at {base_dir}. Skipping README.md upload')
|
|
575
592
|
except RequestException as e:
|
|
576
593
|
info(f'Exception: Unable to upload your API Json {str(e)}')
|
|
577
594
|
finally:
|
|
@@ -648,7 +665,7 @@ class ByoSnap:
|
|
|
648
665
|
info('--skip-build set. Skipping the build step.')
|
|
649
666
|
self._docker_tag()
|
|
650
667
|
self._docker_push()
|
|
651
|
-
if self.path is not None:
|
|
668
|
+
if self.path is not None or self.resources_path is not None:
|
|
652
669
|
self.upload_docs()
|
|
653
670
|
snapctl_success('BYOSNAP publish successful')
|
|
654
671
|
|
snapctl/config/constants.py
CHANGED
snapctl/main.py
CHANGED
|
@@ -255,8 +255,11 @@ def byogs(
|
|
|
255
255
|
path: Union[str, None] = typer.Option(
|
|
256
256
|
None, "--path", help="(req: build, publish) Path to your snap code"
|
|
257
257
|
),
|
|
258
|
+
resources_path: Union[str, None] = typer.Option(
|
|
259
|
+
None, "--resources-path", help="(optional: publish) Path to resources such as your Dockerfile, swagger.json or README.md"
|
|
260
|
+
),
|
|
258
261
|
docker_file: str = typer.Option(
|
|
259
|
-
"Dockerfile", help="Dockerfile name to use"
|
|
262
|
+
"Dockerfile", help="(optional: publish) Dockerfile name to use"
|
|
260
263
|
),
|
|
261
264
|
skip_build: bool = typer.Option(
|
|
262
265
|
False, "--skip-build", help="(optional: publish) Skip the build step. You have to pass the image tag you used during the build step."
|
|
@@ -275,7 +278,7 @@ def byogs(
|
|
|
275
278
|
validate_command_context(ctx)
|
|
276
279
|
byogs_obj: ByoGs = ByoGs(
|
|
277
280
|
subcommand, ctx.obj['base_url'], ctx.obj['api_key'],
|
|
278
|
-
tag, path, docker_file, skip_build
|
|
281
|
+
tag, path, resources_path, docker_file, skip_build
|
|
279
282
|
)
|
|
280
283
|
getattr(byogs_obj, subcommand.replace('-', '_'))()
|
|
281
284
|
success(f"BYOGs {subcommand} complete")
|
|
@@ -317,8 +320,11 @@ def byosnap(
|
|
|
317
320
|
path: Union[str, None] = typer.Option(
|
|
318
321
|
None, "--path", help="(req: publish-image) Path to your snap code"
|
|
319
322
|
),
|
|
323
|
+
resources_path: Union[str, None] = typer.Option(
|
|
324
|
+
None, "--resources-path", help="(optional: publish-image, req: upload-docs) Path to resources such as your Dockerfile, swagger.json or README.md"
|
|
325
|
+
),
|
|
320
326
|
docker_file: str = typer.Option(
|
|
321
|
-
"Dockerfile", help="Dockerfile name to use"
|
|
327
|
+
"Dockerfile", help="(optional: publish) Dockerfile name to use"
|
|
322
328
|
),
|
|
323
329
|
# publish-version
|
|
324
330
|
prefix: str = typer.Option(
|
|
@@ -359,7 +365,7 @@ def byosnap(
|
|
|
359
365
|
validate_command_context(ctx)
|
|
360
366
|
byosnap_obj: ByoSnap = ByoSnap(
|
|
361
367
|
subcommand, ctx.obj['base_url'], ctx.obj['api_key'], sid,
|
|
362
|
-
name, desc, platform_type, language, tag, path, docker_file,
|
|
368
|
+
name, desc, platform_type, language, tag, path, resources_path, docker_file,
|
|
363
369
|
prefix, version, http_port, byosnap_profile, skip_build,
|
|
364
370
|
readiness_path, readiness_delay
|
|
365
371
|
)
|
|
@@ -448,7 +454,7 @@ def generate(
|
|
|
448
454
|
raise typer.Exit(code=SNAPCTL_SUCCESS)
|
|
449
455
|
|
|
450
456
|
|
|
451
|
-
@
|
|
457
|
+
@app.command()
|
|
452
458
|
def snapend(
|
|
453
459
|
ctx: typer.Context,
|
|
454
460
|
# Required fields
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: snapctl
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.39.0
|
|
4
4
|
Summary: Snapser CLI Tool
|
|
5
5
|
Author: Ajinkya Apte
|
|
6
6
|
Author-email: aj@snapser.com
|
|
@@ -220,9 +220,11 @@ snapctl byosnap build --help
|
|
|
220
220
|
# $byosnap_sid = Snap ID for your snap
|
|
221
221
|
# $image_tag = An image tag for your snap
|
|
222
222
|
# $code_root_path = Local code path where your Dockerfile is present
|
|
223
|
+
# $resources_path = Optional path to the resources directory in your Snap. This ensures, you are not forced to put the Dockerfile, swagger.json and README.md in the root directory of your Snap.
|
|
223
224
|
# Example:
|
|
224
225
|
# snapctl byosnap build byosnap-jinks-flask --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
|
|
225
226
|
snapctl byosnap build $byosnap_sid --tag $image_tag --path $code_root_path
|
|
227
|
+
snapctl byosnap build $byosnap_sid --tag $image_tag --path $code_root_path --resources-path $resources_path
|
|
226
228
|
```
|
|
227
229
|
|
|
228
230
|
#### 4. byosnap push
|
|
@@ -252,10 +254,10 @@ snapctl byosnap upload-docs --help
|
|
|
252
254
|
# Publish a new image
|
|
253
255
|
# $byosnap_sid = Snap ID for your snap
|
|
254
256
|
# $image_tag = An image tag for your snap
|
|
255
|
-
# $
|
|
257
|
+
# $resources_path = Path to your swagger.json and README.md files
|
|
256
258
|
# Example:
|
|
257
|
-
# snapctl byosnap upload-docs byosnap-jinks-flask --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
|
|
258
|
-
snapctl byosnap upload-docs $byosnap_sid --tag $image_tag --path $
|
|
259
|
+
# snapctl byosnap upload-docs byosnap-jinks-flask --tag my-first-image --resources-path /Users/DevName/Development/SnapserEngine/jinks_flask
|
|
260
|
+
snapctl byosnap upload-docs $byosnap_sid --tag $image_tag --resources-path $resources_path
|
|
259
261
|
```
|
|
260
262
|
|
|
261
263
|
#### 6. byosnap publish-image
|
|
@@ -275,10 +277,12 @@ snapctl byosnap publish-image --help
|
|
|
275
277
|
# $byosnap_sid = Snap ID for your snap
|
|
276
278
|
# $image_tag = An image tag for your snap
|
|
277
279
|
# $code_root_path = Local code path where your Dockerfile is present
|
|
280
|
+
# $resources_path = Optional path to the resources directory in your Snap. This ensures, you are not forced to put the Dockerfile, swagger.json and README.md in the root directory of your Snap.
|
|
278
281
|
# $skip-build = true/false. Default is false. Pass this flag as true to skip the build and head straight to tag and push. Build step needs to run and tagged using the --tag you pass to the publish-image command for this to work.
|
|
279
282
|
# Example:
|
|
280
283
|
# snapctl byosnap publish-image byosnap-jinks-flask --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
|
|
281
284
|
snapctl byosnap publish-image $byosnap_sid --tag $image_tag --path $code_root_path
|
|
285
|
+
snapctl byosnap publish-image $byosnap_sid --tag $image_tag --path $code_root_path --resources-path $resources_path
|
|
282
286
|
snapctl byosnap publish-image $byosnap_sid --tag $image_tag --skip-build
|
|
283
287
|
```
|
|
284
288
|
|
|
@@ -365,10 +369,12 @@ snapctl byogs publish --help
|
|
|
365
369
|
# Publish a new image
|
|
366
370
|
# $image_tag = An image tag for your snap
|
|
367
371
|
# $code_root_path = Local code path where your Dockerfile is present
|
|
372
|
+
# $resources_path = Optional path to the resources directory. This ensures, you are not forced to put the Dockerfile at the root directory of your Game Server code.
|
|
368
373
|
# $skip-build = Default is false. Pass this flag as true to skip the build and head straight to tag and push. Build step needs to run and tagged using the --tag you pass to the publish-image command for this to work.
|
|
369
374
|
# Example:
|
|
370
375
|
# snapctl byogs publish --tag my-first-image --path /Users/DevName/Development/SnapserEngine/game_server
|
|
371
376
|
snapctl byogs publish --tag $image_tag --path $code_root_path
|
|
377
|
+
snapctl byogs publish --tag $image_tag --path $code_root_path --resources-path $resources_path
|
|
372
378
|
snapctl byogs publish --tag $image_tag --skip-build
|
|
373
379
|
```
|
|
374
380
|
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
snapctl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
snapctl/__main__.py,sha256=43jKoTk8b85hk_MT6499N3ruHdEfM8WBImd_-3VzjI8,116
|
|
3
3
|
snapctl/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
snapctl/commands/byogs.py,sha256=
|
|
5
|
-
snapctl/commands/byosnap.py,sha256=
|
|
4
|
+
snapctl/commands/byogs.py,sha256=oKPRHMyA7gqfMHgAg5dEclJMNcNlDffaZI7EEhSWiaw,13998
|
|
5
|
+
snapctl/commands/byosnap.py,sha256=yv7A_s26Znxyl6wRv85LbPXogs7eVEHOCdlaX_vMIvw,31893
|
|
6
6
|
snapctl/commands/game.py,sha256=icAPD8derxtgXHZQvziHd1O8fwD5Kw7HFMA8yXOUSRQ,4344
|
|
7
7
|
snapctl/commands/generate.py,sha256=7z4nyqDuAieFmIg-XVIri2xkXPpDJd0E3uKYIfQtBqE,7891
|
|
8
8
|
snapctl/commands/snapend.py,sha256=aYKeBZNwDMGWPsYl4qOCkVsrotkE2vzUobfg8AkRetw,30741
|
|
9
9
|
snapctl/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
snapctl/config/constants.py,sha256=
|
|
10
|
+
snapctl/config/constants.py,sha256=Kzd50iL81fkkTYHwSVtlewxnQdViZ9cQSbB3RO0IHVQ,2735
|
|
11
11
|
snapctl/config/endpoints.py,sha256=VAeOmx3k3ukB-9XuGI65KtCJwFK-KFgzor-UWE8JU0g,297
|
|
12
12
|
snapctl/config/hashes.py,sha256=7jkMYfMAcgdque5PN10-B3QqwoXvtsuJKJr9dKZUvJ8,4139
|
|
13
|
-
snapctl/main.py,sha256=
|
|
13
|
+
snapctl/main.py,sha256=XEpJSIkp3_ymemykN0Xevyu2B8xSDZuLgZU4RmEjUEg,20094
|
|
14
14
|
snapctl/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
15
|
snapctl/types/definitions.py,sha256=EQzLeiXkJ8ISRlCqHMviNVsWWpmhWjpKaOBLdlvOTmY,644
|
|
16
16
|
snapctl/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
snapctl/utils/echo.py,sha256=V0qgjqqGXRiueMkq31enmNmdqciC8S90qGRcK8UupXA,1090
|
|
18
18
|
snapctl/utils/helper.py,sha256=XSn0x46mED86kQU1UlmuvJY9GsXO3Ncoba18Lb6FE8k,5522
|
|
19
|
-
snapctl-0.
|
|
20
|
-
snapctl-0.
|
|
21
|
-
snapctl-0.
|
|
22
|
-
snapctl-0.
|
|
23
|
-
snapctl-0.
|
|
19
|
+
snapctl-0.39.0.dist-info/LICENSE,sha256=6AcXm54KFSpmUI1ji9NIBd4Xl-DtjTqiyjBzfVb_CEk,2804
|
|
20
|
+
snapctl-0.39.0.dist-info/METADATA,sha256=wWAtfPxvfUX5R3NSEB8Wow2xhj8xOPH1uWf8K8l8fTo,22833
|
|
21
|
+
snapctl-0.39.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
22
|
+
snapctl-0.39.0.dist-info/entry_points.txt,sha256=tkKW9MzmFdRs6Bgkv29G78i9WEBK4WIOWunPfe3t2Wg,44
|
|
23
|
+
snapctl-0.39.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|