snapctl 0.29.1__py3-none-any.whl → 0.31.1__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 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,13 +2,14 @@
2
2
  Constants used by snapctl
3
3
  """
4
4
  COMPANY_NAME = 'Snapser'
5
- VERSION = '0.29.1'
5
+ VERSION = '0.31.1'
6
6
  CONFIG_FILE_MAC = '~/.snapser/config'
7
7
  CONFIG_FILE_WIN = '%homepath%\\.snapser\\config'
8
8
 
9
9
  DEFAULT_PROFILE = 'default'
10
10
  API_KEY = 'SNAPSER_API_KEY'
11
11
  URL_KEY = 'SNAPSER_URL_KEY'
12
+ CONFIG_PATH_KEY = 'SNAPSER_CONFIG_PATH'
12
13
  SERVER_CALL_TIMEOUT = 30
13
14
 
14
15
  SNAPCTL_SUCCESS = 0
snapctl/main.py CHANGED
@@ -13,7 +13,7 @@ from snapctl.commands.byogs import ByoGs
13
13
  from snapctl.commands.game import Game
14
14
  from snapctl.commands.snapend import Snapend
15
15
  from snapctl.config.constants import COMPANY_NAME, API_KEY, URL_KEY, CONFIG_FILE_MAC, \
16
- CONFIG_FILE_WIN, DEFAULT_PROFILE, VERSION, SNAPCTL_SUCCESS, SNAPCTL_ERROR
16
+ CONFIG_FILE_WIN, DEFAULT_PROFILE, VERSION, SNAPCTL_SUCCESS, SNAPCTL_ERROR, CONFIG_PATH_KEY
17
17
  from snapctl.config.endpoints import END_POINTS
18
18
  from snapctl.config.hashes import CLIENT_SDK_TYPES, SERVER_SDK_TYPES, PROTOS_TYPES, SERVICE_IDS, \
19
19
  SNAPEND_MANIFEST_TYPES
@@ -50,22 +50,23 @@ def extract_config(extract_key: str, profile: str | None = None) -> object:
50
50
  'location': '',
51
51
  'value': None
52
52
  }
53
- # Option 1
53
+ # Option 1 - Get the API Key from the environment variable
54
54
  env_api_key = os.getenv(extract_key)
55
55
  if env_api_key is not None:
56
56
  result['location'] = 'environment-variable'
57
57
  result['value'] = env_api_key
58
58
  return result
59
- # Option 2
60
- config_file_path: str = ''
61
- encoding: str | None = None
62
- if platform == 'win32':
63
- config_file_path = os.path.expandvars(CONFIG_FILE_WIN)
64
- encoding = "utf-8-sig"
65
- else:
66
- config_file_path = os.path.expanduser(CONFIG_FILE_MAC)
59
+ encoding: str | None = "utf-8-sig" if platform == 'win32' else None
60
+ # Option 2 - Get the API Key from CONFIG PATH environment variable
61
+ config_file_path: str | None = os.getenv(CONFIG_PATH_KEY)
62
+ # Option 3 - Get the API Key from the hardcoded config file we look for
63
+ if config_file_path is None:
64
+ if platform == 'win32':
65
+ config_file_path = os.path.expandvars(CONFIG_FILE_WIN)
66
+ else:
67
+ config_file_path = os.path.expanduser(CONFIG_FILE_MAC)
68
+ result['location'] = f'config-file:{config_file_path}'
67
69
  if os.path.isfile(config_file_path):
68
- result['location'] = 'config-file'
69
70
  config = configparser.ConfigParser()
70
71
  config.read(config_file_path, encoding=encoding)
71
72
  config_profile: str = DEFAULT_PROFILE
@@ -319,7 +320,7 @@ def byogs(
319
320
  ..., help="BYOGs Subcommands: " + ", ".join(ByoGs.SUBCOMMANDS) + "."
320
321
  ),
321
322
  sid: str = typer.Argument(
322
- ..., help="Game Server Id. Should start with byogs-"
323
+ ByoGs.SID, help="Game Server Id. Should start with byogs"
323
324
  ),
324
325
  # create
325
326
  name: str = typer.Option(
@@ -338,14 +339,14 @@ def byogs(
338
339
  help="(req: create) Language of your snap - " + \
339
340
  ", ".join(ByoGs.LANGUAGES) + "."
340
341
  ),
341
- # publish-image and publish-version
342
+ # publish, publish-image and publish-version
342
343
  tag: str = typer.Option(
343
344
  None, "--tag",
344
- help="(req: build, push, publish-image and publish-version) Tag for your snap"
345
+ help="(req: build, push, publish, publish-image and publish-version) Tag for your snap"
345
346
  ),
346
- # publish-image
347
+ # publish and publish-image
347
348
  path: Union[str, None] = typer.Option(
348
- None, "--path", help="(req: build, publish-image, upload-docs) Path to your snap code"
349
+ None, "--path", help="(req: build, publish, publish-image, upload-docs) Path to your snap code"
349
350
  ),
350
351
  docker_file: str = typer.Option(
351
352
  "Dockerfile", help="Dockerfile name to use"
@@ -512,7 +513,7 @@ def snapend(
512
513
  byogs: str = typer.Option(
513
514
  None, "--byogs",
514
515
  help=(
515
- "(optional: update) Comma separated list of BYOGs fleet name, ids and versions. "
516
+ "(optional: update) Comma separated list of BYOGs fleet name:tags. "
516
517
  "Eg: fleet-1:service-1:v1.0.0,fleet-2:service-2:v1.0.0"
517
518
  )
518
519
  ),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: snapctl
3
- Version: 0.29.1
3
+ Version: 0.31.1
4
4
  Summary: Snapser CLI Tool
5
5
  Author: Ajinkya Apte
6
6
  Author-email: aj@snapser.com
@@ -101,7 +101,10 @@ be evaluated after verifying if there is any command line argument.
101
101
 
102
102
  Create a file named `~/.snapser/config`. Open it using the editor of your choice and replace with your
103
103
  personal Snapser Access key. Save the file. Advantage of using this method is you can use the `--profile`
104
- argument with your snapctl command to use different API keys.
104
+ argument with your snapctl command to use different API keys. NOTE: You may want to pass your own path
105
+ instead on relying on the default one the CLI looks for. You can do so by setting an environment
106
+ variable `SNAPSER_CONFIG_PATH='<your_custom_path>'`. Doing this will make sure that the CLI tool
107
+ will look for the config file at that path.
105
108
 
106
109
  ```
107
110
  [default]
@@ -302,7 +305,7 @@ See all the supported commands
302
305
  snapctl byogs --help
303
306
  ```
304
307
 
305
- #### 2. byogs create
308
+ #### 2. [Deprecated soon] byogs create
306
309
 
307
310
  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
311
  in a Snapend fleet.
@@ -336,7 +339,7 @@ snapctl byogs build --help
336
339
  # $image_tag = An image tag for your snap
337
340
  # $code_root_path = Local code path where your Dockerfile is present
338
341
  # Example:
339
- # snapctl byogs build byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
342
+ # snapctl byogs build byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/game_server
340
343
  snapctl byogs build $byogs_sid --tag $image_tag --path $code_root_path
341
344
  ```
342
345
 
@@ -356,7 +359,7 @@ snapctl byogs push --help
356
359
  snapctl byogs push $byogs_sid --tag $image_tag
357
360
  ```
358
361
 
359
- #### 5. byogs publish-image
362
+ #### 5. [Deprecated soon] byogs publish-image
360
363
 
361
364
  Publish your custom game server image. This command executes, `build` and `push` one after the other.
362
365
 
@@ -369,11 +372,11 @@ snapctl byogs publish-image --help
369
372
  # $image_tag = An image tag for your snap
370
373
  # $code_root_path = Local code path where your Dockerfile is present
371
374
  # Example:
372
- # snapctl byogs publish-image byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/jinks_flask
375
+ # snapctl byogs publish-image byosnap-jinks-gs --tag my-first-image --path /Users/DevName/Development/SnapserEngine/game_server
373
376
  snapctl byogs publish-image $byogs_sid --tag $image_tag --path $code_root_path
374
377
  ```
375
378
 
376
- #### 6. byogs publish-version
379
+ #### 6. [Deprecated soon] byogs publish-version
377
380
 
378
381
  Publish a new version for your game server. Only after your game server version is published, you will be able
379
382
  to use it in your Snapend fleet. This command should be run after you `push` or `publish-image` commands.
@@ -393,6 +396,24 @@ snapctl byogs publish-version --help
393
396
  snapctl byogs publish-version $byogs_sid --tag $image_tag --prefix $prefix --version $version --http-port $ingress_port
394
397
  ```
395
398
 
399
+ #### 7. [New] byogs publish
400
+
401
+ Publish your custom game server image. This commend replaces the old way of creating, publishing image and
402
+ then publishing the byogs. Now all you have to do is publish your image and create a fleet using the web portal.
403
+
404
+ ```
405
+ # Help for the byogs command
406
+ snapctl byogs publish --help
407
+
408
+ # Publish a new image
409
+ # $image_tag = An image tag for your snap
410
+ # $code_root_path = Local code path where your Dockerfile is present
411
+ # Example:
412
+ # snapctl byogs publish --tag my-first-image --path /Users/DevName/Development/SnapserEngine/game_server
413
+ snapctl byogs publish --tag $image_tag --path $code_root_path
414
+ ```
415
+
416
+
396
417
  ### Game
397
418
 
398
419
  #### 1. snapend help
@@ -505,9 +526,9 @@ snapctl snapend update --help
505
526
  # --blocking = (Optional) This makes sure the CLI waits till your Snapend is live.
506
527
  # Note at least one of the two needs to be present
507
528
  # Example:
508
- # 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
510
- snapctl snapend update $snapend_id --byosnaps $byosnaps --byogs $byogs --blocking
529
+ # snapctl snapend update --snapend-id 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
530
+ # snapctl snapend update --snapend-id 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
531
+ snapctl snapend update --snapend-id $snapend_id --byosnaps $byosnaps --byogs $byogs --blocking
511
532
  ```
512
533
 
513
534
  #### 6. Get the Snapend state
@@ -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=iX5zkftpOqdGJWoCK8-zwP_Mz9GD3BU62DVKrzTygpw,565
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=QES1PqGgMWjKVcOdUA8b14KHweiE2iJigxKtaoJfBDw,19147
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.1.dist-info/METADATA,sha256=cIywFLCBwuCumEUspq8sf4qgNcsAcixFSIph1Wz0fvI,16509
19
+ snapctl-0.31.1.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
20
+ snapctl-0.31.1.dist-info/entry_points.txt,sha256=tkKW9MzmFdRs6Bgkv29G78i9WEBK4WIOWunPfe3t2Wg,44
21
+ snapctl-0.31.1.dist-info/RECORD,,