snapctl 0.29.1__py3-none-any.whl → 0.31.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.
snapctl/commands/byogs.py CHANGED
@@ -24,10 +24,11 @@ class ByoGs:
24
24
  """
25
25
  BYOGS CLI commands
26
26
  """
27
- ID_PREFIX = 'byogs-'
27
+ SID = 'byogs'
28
28
  SUBCOMMANDS = [
29
29
  'build', 'push',
30
30
  'create', 'publish-image', 'publish-version',
31
+ 'publish'
31
32
  ]
32
33
  PLATFORMS = ['linux/amd64']
33
34
  LANGUAGES = ['go', 'python', 'ruby', 'c#', 'c++', 'rust', 'java', 'node']
@@ -45,15 +46,17 @@ class ByoGs:
45
46
  self.base_url: str = base_url
46
47
  self.api_key: str = api_key
47
48
  self.sid: str = sid
49
+ if subcommand == 'publish':
50
+ self.sid = ByoGs.SID
48
51
  self.name: str = name
49
52
  self.desc: str = desc
50
53
  self.platform_type: str = platform_type
51
54
  self.language: str = language
55
+ self.token: Union[str, None] = None
52
56
  if subcommand != 'create':
53
57
  self.token: Union[str, None] = get_composite_token(
54
- base_url, api_key, 'byogs', {'service_id': sid})
55
- else:
56
- self.token: Union[str, None] = None
58
+ base_url, api_key, 'byogs', {'service_id': self.sid}
59
+ )
57
60
  self.token_parts: Union[list, None] = ByoGs._get_token_values(
58
61
  self.token) if self.token is not None else None
59
62
  self.input_tag: Union[str, None] = input_tag
@@ -269,10 +272,10 @@ class ByoGs:
269
272
  response['msg'] = f"Invalid command. Valid commands are {', '.join(ByoGs.SUBCOMMANDS)}."
270
273
  return response
271
274
  # Validate the SID
272
- if not self.sid.startswith(ByoGs.ID_PREFIX):
275
+ if not self.sid.startswith(ByoGs.SID):
273
276
  response['msg'] = (
274
277
  "Invalid Game Server ID. Valid Game Server IDs start "
275
- f"with {ByoGs.ID_PREFIX}."
278
+ f"with {ByoGs.SID}."
276
279
  )
277
280
  return response
278
281
  if len(self.sid) > ByoGs.SID_CHARACTER_LIMIT:
@@ -310,7 +313,7 @@ class ByoGs:
310
313
  f"{ByoGs.TAG_CHARACTER_LIMIT} characters"
311
314
  )
312
315
  return response
313
- if self.subcommand == 'build' or self.subcommand == 'publish-image':
316
+ if self.subcommand in ['build', 'publish-image', 'publish']:
314
317
  if not self.input_tag:
315
318
  response['msg'] = "Missing required parameter: tag"
316
319
  return response
@@ -430,6 +433,21 @@ class ByoGs:
430
433
  return False
431
434
  return True
432
435
 
436
+ def publish(self) -> bool:
437
+ """
438
+ Publish the image
439
+ 1. Check Dependencies
440
+ 2. Login to Snapser Registry
441
+ 3. Build your snap
442
+ 4. Tag the repo
443
+ 5. Push the image
444
+ 6. Upload swagger.json
445
+ """
446
+ if not self._check_dependencies() or not self._docker_login() or \
447
+ not self._docker_build() or not self._docker_tag() or not self._docker_push():
448
+ return False
449
+ return True
450
+
433
451
  def publish_version(self) -> bool:
434
452
  """
435
453
  Publish your game server version
@@ -117,12 +117,11 @@ class Snapend:
117
117
  byogs_list = []
118
118
  for byog in byogs.split(','):
119
119
  byog = byog.strip()
120
- if len(byog.split(':')) != 3:
120
+ if len(byog.split(':')) != 2:
121
121
  return []
122
122
  byogs_list.append({
123
123
  'fleet_name': byog.split(':')[0],
124
- 'service_id': byog.split(':')[1],
125
- 'service_version': byog.split(':')[2]
124
+ 'image_tag': byog.split(':')[1],
126
125
  })
127
126
  return byogs_list
128
127
 
@@ -2,7 +2,7 @@
2
2
  Constants used by snapctl
3
3
  """
4
4
  COMPANY_NAME = 'Snapser'
5
- VERSION = '0.29.1'
5
+ VERSION = '0.31.0'
6
6
  CONFIG_FILE_MAC = '~/.snapser/config'
7
7
  CONFIG_FILE_WIN = '%homepath%\\.snapser\\config'
8
8
 
snapctl/main.py CHANGED
@@ -319,7 +319,7 @@ def byogs(
319
319
  ..., help="BYOGs Subcommands: " + ", ".join(ByoGs.SUBCOMMANDS) + "."
320
320
  ),
321
321
  sid: str = typer.Argument(
322
- ..., help="Game Server Id. Should start with byogs-"
322
+ ByoGs.SID, help="Game Server Id. Should start with byogs"
323
323
  ),
324
324
  # create
325
325
  name: str = typer.Option(
@@ -338,14 +338,14 @@ def byogs(
338
338
  help="(req: create) Language of your snap - " + \
339
339
  ", ".join(ByoGs.LANGUAGES) + "."
340
340
  ),
341
- # publish-image and publish-version
341
+ # publish, publish-image and publish-version
342
342
  tag: str = typer.Option(
343
343
  None, "--tag",
344
- help="(req: build, push, publish-image and publish-version) Tag for your snap"
344
+ help="(req: build, push, publish, publish-image and publish-version) Tag for your snap"
345
345
  ),
346
- # publish-image
346
+ # publish and publish-image
347
347
  path: Union[str, None] = typer.Option(
348
- None, "--path", help="(req: build, publish-image, upload-docs) Path to your snap code"
348
+ None, "--path", help="(req: build, publish, publish-image, upload-docs) Path to your snap code"
349
349
  ),
350
350
  docker_file: str = typer.Option(
351
351
  "Dockerfile", help="Dockerfile name to use"
@@ -512,7 +512,7 @@ def snapend(
512
512
  byogs: str = typer.Option(
513
513
  None, "--byogs",
514
514
  help=(
515
- "(optional: update) Comma separated list of BYOGs fleet name, ids and versions. "
515
+ "(optional: update) Comma separated list of BYOGs fleet name:tags. "
516
516
  "Eg: fleet-1:service-1:v1.0.0,fleet-2:service-2:v1.0.0"
517
517
  )
518
518
  ),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: snapctl
3
- Version: 0.29.1
3
+ Version: 0.31.0
4
4
  Summary: Snapser CLI Tool
5
5
  Author: Ajinkya Apte
6
6
  Author-email: aj@snapser.com
@@ -302,7 +302,7 @@ See all the supported commands
302
302
  snapctl byogs --help
303
303
  ```
304
304
 
305
- #### 2. byogs create
305
+ #### 2. [Deprecated soon] byogs create
306
306
 
307
307
  Create a custom game server. Note that you will have to build, push and publish your game server image, for it to be useable
308
308
  in a Snapend fleet.
@@ -336,7 +336,7 @@ snapctl byogs build --help
336
336
  # $image_tag = An image tag for your snap
337
337
  # $code_root_path = Local code path where your Dockerfile is present
338
338
  # Example:
339
- # snapctl byogs build byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
339
+ # snapctl byogs build byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/game_server
340
340
  snapctl byogs build $byogs_sid --tag $image_tag --path $code_root_path
341
341
  ```
342
342
 
@@ -356,7 +356,7 @@ snapctl byogs push --help
356
356
  snapctl byogs push $byogs_sid --tag $image_tag
357
357
  ```
358
358
 
359
- #### 5. byogs publish-image
359
+ #### 5. [Deprecated soon] byogs publish-image
360
360
 
361
361
  Publish your custom game server image. This command executes, `build` and `push` one after the other.
362
362
 
@@ -369,11 +369,11 @@ snapctl byogs publish-image --help
369
369
  # $image_tag = An image tag for your snap
370
370
  # $code_root_path = Local code path where your Dockerfile is present
371
371
  # Example:
372
- # snapctl byogs publish-image byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
372
+ # snapctl byogs publish-image byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/game_server
373
373
  snapctl byogs publish-image $byogs_sid --tag $image_tag --path $code_root_path
374
374
  ```
375
375
 
376
- #### 6. byogs publish-version
376
+ #### 6. [Deprecated soon] byogs publish-version
377
377
 
378
378
  Publish a new version for your game server. Only after your game server version is published, you will be able
379
379
  to use it in your Snapend fleet. This command should be run after you `push` or `publish-image` commands.
@@ -393,6 +393,24 @@ snapctl byogs publish-version --help
393
393
  snapctl byogs publish-version $byogs_sid --tag $image_tag --prefix $prefix --version $version --http-port $ingress_port
394
394
  ```
395
395
 
396
+ #### 7. [New] byogs publish
397
+
398
+ Publish your custom game server image. This commend replaces the old way of creating, publishing image and
399
+ then publishing the byogs. Now all you have to do is publish your image and create a fleet using the web portal.
400
+
401
+ ```
402
+ # Help for the byogs command
403
+ snapctl byogs publish --help
404
+
405
+ # Publish a new image
406
+ # $image_tag = An image tag for your snap
407
+ # $code_root_path = Local code path where your Dockerfile is present
408
+ # Example:
409
+ # snapctl byogs publish --tag my-first-image --path /Users/DevName/Development/SnapserEngine/game_server
410
+ snapctl byogs publish --tag $image_tag --path $code_root_path
411
+ ```
412
+
413
+
396
414
  ### Game
397
415
 
398
416
  #### 1. snapend help
@@ -506,7 +524,7 @@ snapctl snapend update --help
506
524
  # Note at least one of the two needs to be present
507
525
  # Example:
508
526
  # snapctl snapend update gx5x6bc0 --byosnaps byosnap-service-1:v1.0.0,byosnap-service--2:v1.0.0 --byogs byogs-fleet-one:gs-1:v0.0.1,my-fleet-two:gs-2:v0.0.4
509
- # snapctl snapend update gx5x6bc0 --byosnaps byosnap-service-1:v1.0.0,byosnap-service--2:v1.0.0 --byogs byogs-fleet-one:gs-1:v0.0.1,my-fleet-two:gs-2:v0.0.4 --blocking
527
+ # snapctl snapend update gx5x6bc0 --byosnaps byosnap-service-1:v1.0.0,byosnap-service--2:v1.0.0 --byogs fleet-one:v0.0.1,fleet-two:v0.0.4 --blocking
510
528
  snapctl snapend update $snapend_id --byosnaps $byosnaps --byogs $byogs --blocking
511
529
  ```
512
530
 
@@ -1,21 +1,21 @@
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=S77gBVT7W-6Ph7D8YU_2YfFNFHhlnBYYg3hafuw_w5Q,19216
4
+ snapctl/commands/byogs.py,sha256=2Jocaemxn01IrKno3u9QrVeiAsqIpCJBVsWi2ivHuCY,19762
5
5
  snapctl/commands/byosnap.py,sha256=RQv3r30dkz8n1BgEnE-tAnAzPLoz-CLEQoiy1WKZQeg,23172
6
6
  snapctl/commands/game.py,sha256=rnsTqrXavE5D-KULXkDBQ-PBI8sSKK4it3S_YMJfiUY,3633
7
- snapctl/commands/snapend.py,sha256=QfmjaGsB_expDdc9JSkrOWPkFmMYtPfBBNFMKFRn-mI,26242
7
+ snapctl/commands/snapend.py,sha256=exMH-8lp9qUociAWHJS15xRr-MtCe1fjbQAQmgODNIw,26187
8
8
  snapctl/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- snapctl/config/constants.py,sha256=z-_Wjcw77f_m_H8PRg__eSjzbbdxrmZ3ypugBQXKoYg,525
9
+ snapctl/config/constants.py,sha256=0XQxi_HgoQlhmxxfSFR0Zqu2OIVedIAZNKiDkKWmQOU,525
10
10
  snapctl/config/endpoints.py,sha256=VAeOmx3k3ukB-9XuGI65KtCJwFK-KFgzor-UWE8JU0g,297
11
11
  snapctl/config/hashes.py,sha256=tb0ilslgYvI8L4IKeiMfz2qYRDcezat8tg8dPGqlbAU,3093
12
- snapctl/main.py,sha256=l4VcMszsLyeDfGjTC_uNyv9Weo4kGSqq6xp6cgOf96w,18814
12
+ snapctl/main.py,sha256=zw3A1c2z0US6l24y847bsG__e2fb1ftYAjttIwsGKOo,18845
13
13
  snapctl/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  snapctl/types/definitions.py,sha256=rkRyTBHzeQtCt_uYObgYvL5txnVq8r_n5g4IUAq2FWc,233
15
15
  snapctl/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  snapctl/utils/echo.py,sha256=0nhWYDBQTfZGtl8EK21hJhj0now2rQmCT-yYMCKupy4,584
17
17
  snapctl/utils/helper.py,sha256=xasSsg-0DgHT-TWejh2IXW-s9AYntO1D2O6Uy6BQLcE,1381
18
- snapctl-0.29.1.dist-info/METADATA,sha256=D7zafku1LZjZzYLKgEgjS0pGwjlqVHO7HKIUTS7Dt8k,15526
19
- snapctl-0.29.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
20
- snapctl-0.29.1.dist-info/entry_points.txt,sha256=tkKW9MzmFdRs6Bgkv29G78i9WEBK4WIOWunPfe3t2Wg,44
21
- snapctl-0.29.1.dist-info/RECORD,,
18
+ snapctl-0.31.0.dist-info/METADATA,sha256=zquisLiqsLYz-hQJG-Gob19JAOKUC7CyjWvdMse8hEo,16191
19
+ snapctl-0.31.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
20
+ snapctl-0.31.0.dist-info/entry_points.txt,sha256=tkKW9MzmFdRs6Bgkv29G78i9WEBK4WIOWunPfe3t2Wg,44
21
+ snapctl-0.31.0.dist-info/RECORD,,