snapctl 0.43.1__tar.gz → 0.43.2__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: snapctl
3
- Version: 0.43.1
3
+ Version: 0.43.2
4
4
  Summary: Snapser CLI Tool
5
5
  Author: Ajinkya Apte
6
6
  Author-email: aj@snapser.com
@@ -365,10 +365,10 @@ snapctl byosnap publish-version --help
365
365
  # $byosnap_sid = Snap ID for your snap
366
366
  # $image_tag = An image tag for your snap
367
367
  # $version = Semantic version for your snap Eg: v0.0.1
368
- # $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 profile --category byosnap --out-path <output_path>` command
368
+ # $byosnapProfilePath = 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 profile --category byosnap --out-path <output_path>` command
369
369
  # Example:
370
370
  # snapctl byosnap publish-version byosnap-jinks-flask --tag my-first-image --version v0.0.1 --path /Users/DevName/Development/SnapserEngine/jinks_flask
371
- snapctl byosnap publish-version $byosnap_sid --tag $image_tag --version $version --path $path
371
+ snapctl byosnap publish-version $byosnap_sid --tag $image_tag --version $version --path $byosnapProfilePath
372
372
  ```
373
373
 
374
374
  ### BYO Game Server - Bring your own Game Server
@@ -346,10 +346,10 @@ snapctl byosnap publish-version --help
346
346
  # $byosnap_sid = Snap ID for your snap
347
347
  # $image_tag = An image tag for your snap
348
348
  # $version = Semantic version for your snap Eg: v0.0.1
349
- # $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 profile --category byosnap --out-path <output_path>` command
349
+ # $byosnapProfilePath = 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 profile --category byosnap --out-path <output_path>` command
350
350
  # Example:
351
351
  # snapctl byosnap publish-version byosnap-jinks-flask --tag my-first-image --version v0.0.1 --path /Users/DevName/Development/SnapserEngine/jinks_flask
352
- snapctl byosnap publish-version $byosnap_sid --tag $image_tag --version $version --path $path
352
+ snapctl byosnap publish-version $byosnap_sid --tag $image_tag --version $version --path $byosnapProfilePath
353
353
  ```
354
354
 
355
355
  ### BYO Game Server - Bring your own Game Server
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "snapctl"
3
- version = "0.43.1"
3
+ version = "0.43.2"
4
4
  description = "Snapser CLI Tool"
5
5
  authors = ["Ajinkya Apte <aj@snapser.com>"]
6
6
  readme = "README.md"
@@ -91,7 +91,8 @@ class ByoSnap:
91
91
  self.blocking: bool = blocking
92
92
  # Override
93
93
  self.prefix: Union[str, None] = None
94
- self.http_port: Union[int, None] = None
94
+ self.ingress_external_port: Union[dict, None] = None
95
+ self.ingress_internal_ports: Union[list, None] = None
95
96
  self.readiness_path: Union[str, None] = None
96
97
  self.readiness_delay: Union[str, None] = None
97
98
  if self.subcommand in ['publish', 'publish-version']:
@@ -190,14 +191,15 @@ class ByoSnap:
190
191
  )
191
192
  if 'name' not in profile_data or 'description' not in profile_data or \
192
193
  'platform' not in profile_data or 'language' not in profile_data or \
193
- 'prefix' not in profile_data or 'http_port' not in profile_data or \
194
- 'readiness_probe_config' not in profile_data or \
194
+ 'prefix' not in profile_data or \
195
+ ('http_port' not in profile_data and 'ingress' not in profile_data) or \
196
+ 'readiness_probe_config' not in profile_data or \
195
197
  'initial_delay_seconds' not in profile_data['readiness_probe_config'] or \
196
198
  'path' not in profile_data['readiness_probe_config']:
197
199
  snapctl_error(
198
200
  message='BYOSnap profile now requires name, description, platform, ' +
199
- 'language, prefix http_port, and readiness_probe_config fields. Please use ' +
200
- 'the following command: ' +
201
+ 'language, prefix, ingress, and readiness_probe_config fields. ' +
202
+ 'Please use the following command: ' +
201
203
  '`snapctl generate profile --category byosnap --out-path $output_path` ' +
202
204
  'to generate a new profile',
203
205
  code=SNAPCTL_INPUT_ERROR
@@ -227,7 +229,26 @@ class ByoSnap:
227
229
  self.platform_type = profile_data['platform']
228
230
  self.language = profile_data['language']
229
231
  self.prefix = profile_data['prefix']
230
- self.http_port = profile_data['http_port']
232
+ # Setup the final ingress external port
233
+ final_ingress_external_port = {
234
+ 'name': 'http',
235
+ 'port': None
236
+ }
237
+ if 'http_port' in profile_data:
238
+ final_ingress_external_port = {
239
+ 'name': 'http',
240
+ 'port': profile_data['http_port']
241
+ }
242
+ warning('http_port is deprecated. Please use ingress.external_port. ' +
243
+ 'You can generate a new BYOSnap profile via the `generate` command.')
244
+ elif 'ingress' in profile_data and 'external_port' in profile_data['ingress']:
245
+ final_ingress_external_port = profile_data['ingress']['external_port']
246
+ self.ingress_external_port = final_ingress_external_port
247
+ # Setup the final ingress internal ports
248
+ final_ingress_internal_ports = []
249
+ if 'ingress' in profile_data and 'internal_ports' in profile_data['ingress']:
250
+ final_ingress_internal_ports = profile_data['ingress']['internal_ports']
251
+ self.ingress_internal_ports = final_ingress_internal_ports
231
252
  self.readiness_path = profile_data['readiness_probe_config']['path']
232
253
  self.readiness_delay = \
233
254
  profile_data['readiness_probe_config']['initial_delay_seconds']
@@ -246,12 +267,48 @@ class ByoSnap:
246
267
  if not re.match(pattern, self.version):
247
268
  snapctl_error("Version should be in the format vX.X.X",
248
269
  SNAPCTL_INPUT_ERROR)
249
- if not self.http_port:
270
+ if not self.ingress_external_port['port']:
250
271
  snapctl_error("Missing Ingress HTTP Port",
251
272
  SNAPCTL_INPUT_ERROR)
252
- if not isinstance(self.http_port, int):
253
- snapctl_error("Ingress HTTP Port should be a number",
273
+ if not isinstance(self.ingress_external_port['port'], int):
274
+ snapctl_error("Ingress external port should be a number",
254
275
  SNAPCTL_INPUT_ERROR)
276
+ # Check internal ports
277
+ duplicate_name = {}
278
+ duplicate_port = {}
279
+ index = 0
280
+ for internal_port in self.ingress_internal_ports:
281
+ if 'name' not in internal_port or 'port' not in internal_port:
282
+ snapctl_error("Internal ports need a name and a port. Check internal port " +
283
+ f"number {index}.",
284
+ SNAPCTL_INPUT_ERROR)
285
+ # Confirm the name does not collide with the external port
286
+ if internal_port['name'] == self.ingress_external_port['name']:
287
+ snapctl_error("Internal port name should not be the same as " +
288
+ "the external port name", SNAPCTL_INPUT_ERROR)
289
+ # Confirm the port does not collide with the external port
290
+ if internal_port['port'] == self.ingress_external_port['port']:
291
+ snapctl_error("Internal port number should not be the same as " +
292
+ "the external port number", SNAPCTL_INPUT_ERROR)
293
+ index += 1
294
+ if not internal_port['port']:
295
+ snapctl_error("Missing internal port. Check internal port " +
296
+ f"number {index}",
297
+ SNAPCTL_INPUT_ERROR)
298
+ if not isinstance(internal_port['port'], int):
299
+ snapctl_error("Internal port should be a number. Check internal port " +
300
+ f"number {index}",
301
+ SNAPCTL_INPUT_ERROR)
302
+ if internal_port['name'] in duplicate_name:
303
+ snapctl_error("Duplicate internal port name. Check internal port " +
304
+ f"number {index}",
305
+ SNAPCTL_INPUT_ERROR)
306
+ if internal_port['port'] in duplicate_port:
307
+ snapctl_error("Duplicate internal port number. Check internal port " +
308
+ f"number {index}",
309
+ SNAPCTL_INPUT_ERROR)
310
+ duplicate_name[internal_port['name']] = True
311
+ duplicate_port[internal_port['port']] = True
255
312
  if self.readiness_path is not None:
256
313
  if self.readiness_path.strip() == '':
257
314
  snapctl_error("Readiness path cannot be empty",
@@ -918,14 +975,19 @@ class ByoSnap:
918
975
  "version": self.version,
919
976
  "image_tag": self.tag,
920
977
  "base_url": f"{self.prefix}/{self.sid}",
921
- "http_port": self.http_port,
978
+ "ingress": {
979
+ "external_port": self.ingress_external_port,
980
+ "internal_ports": self.ingress_internal_ports
981
+ },
922
982
  "readiness_probe_config": {
923
983
  "path": self.readiness_path,
924
984
  "initial_delay_seconds": self.readiness_delay
925
985
  },
926
986
  "dev_template": profile_data['dev_template'],
927
987
  "stage_template": profile_data['stage_template'],
928
- "prod_template": profile_data['prod_template']
988
+ "prod_template": profile_data['prod_template'],
989
+ # Currently not supported so we are just hardcoding an empty list
990
+ "egress": {"ports": []},
929
991
  }
930
992
  res = requests.post(
931
993
  f"{self.base_url}/v1/snapser-api/byosnaps/{self.sid}/versions",
@@ -2,7 +2,7 @@
2
2
  Constants used by snapctl
3
3
  """
4
4
  COMPANY_NAME = 'Snapser'
5
- VERSION = '0.43.1'
5
+ VERSION = '0.43.2'
6
6
  CONFIG_FILE_MAC = '~/.snapser/config'
7
7
  CONFIG_FILE_WIN = '%homepath%\\.snapser\\config'
8
8
 
@@ -188,15 +188,24 @@ DEFAULT_BYOSNAP_PROD_TEMPLATE: Dict[str, object] = {
188
188
  }
189
189
 
190
190
  BYOSNAP_TEMPLATE: Dict[str, Dict[str, object]] = {
191
- "name": "TODO: Add your BYOSnap name here. Name has to start with byosnap-. This is to ensure we avoid any collisions.",
191
+ 'name': "TODO: Add your BYOSnap name here. Name has to start with byosnap-. This is to ensure we avoid any collisions.",
192
192
  'description': "TODO: Add your BYOSnap description here",
193
193
  'platform': "TODO: Add your platform here. Options are 'linux/arm64' or 'linux/amd64'",
194
194
  'language': "TODO: Add your language here. Options are 'go', 'node', 'python', 'java', 'csharp', 'cpp', 'rust', 'ruby', 'php', 'perl', 'clojure', 'lua', 'ts', 'js', 'kotlin', 'c'",
195
195
  'prefix': "TODO: Add your prefix here. Prefix should start with /. Eg: '/v1'",
196
- 'http_port': 'TODO: Add your HTTP Port. Eg: 8080',
196
+ 'ingress': {
197
+ 'external_port': {
198
+ 'name': 'http',
199
+ 'port': "TODO: Enter your external port here. Eg: 5003. Make sure it is a number and not a string."
200
+ },
201
+ 'internal_ports': [{
202
+ 'name': 'TODO: Optionally add your internal port name here. Eg: grpc. Names should be unique across the `ingress` dict. IMPORTANT: If you are not adding any internal ports, just keep `internal_ports: []`",',
203
+ 'port': "TODO: Optionally add your internal port here. Eg: 5004. Make sure it is a number and not a string. Port numbers should be unique across the `ingress` dict."
204
+ }]
205
+ },
197
206
  'readiness_probe_config': {
198
- 'initial_delay_seconds': "TODO: Add your readiness delay in seconds here. Eg: 5 or use null",
199
- 'path': "TODO: Add your readiness path here. Eg: '/health' or use null",
207
+ 'initial_delay_seconds': "TODO: Optionally add your readiness delay in seconds here. Eg: 5 or use null. Make sure it is a number and not a string.",
208
+ 'path': "TODO: Optionally add your readiness path here. Eg: '/health' or use null",
200
209
  },
201
210
  'dev_template': DEFAULT_BYOSNAP_DEV_TEMPLATE,
202
211
  'stage_template': DEFAULT_BYOSNAP_STAGE_TEMPLATE,
File without changes
File without changes
File without changes
File without changes
File without changes