snapctl 0.48.0__py3-none-any.whl → 0.48.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.

@@ -18,7 +18,8 @@ from snapctl.config.constants import SERVER_CALL_TIMEOUT, SNAPCTL_INPUT_ERROR, \
18
18
  SNAPCTL_SNAPEND_APPLY_ERROR, SNAPCTL_SNAPEND_PROMOTE_SERVER_ERROR, \
19
19
  SNAPCTL_SNAPEND_PROMOTE_TIMEOUT_ERROR, SNAPCTL_SNAPEND_PROMOTE_ERROR, \
20
20
  SNAPCTL_SNAPEND_DOWNLOAD_ERROR, SNAPCTL_SNAPEND_UPDATE_TIMEOUT_ERROR, \
21
- SNAPCTL_SNAPEND_UPDATE_ERROR, SNAPCTL_SNAPEND_STATE_ERROR
21
+ SNAPCTL_SNAPEND_UPDATE_ERROR, SNAPCTL_SNAPEND_STATE_ERROR, HTTP_ERROR_SNAPEND_MANIFEST_MISMATCH, \
22
+ SNAPCTL_SNAPEND_APPLY_MANIFEST_MISMATCH_ERROR
22
23
  from snapctl.config.hashes import PROTOS_TYPES, CLIENT_SDK_TYPES, SERVER_SDK_TYPES, \
23
24
  SNAPEND_MANIFEST_TYPES, SDK_TYPES, SDK_ACCESS_AUTH_TYPE_LOOKUP
24
25
  from snapctl.utils.echo import error, success, info
@@ -57,6 +58,7 @@ class Snapend:
57
58
  env: Union[str, None] = None,
58
59
  # Clone, Apply, Promote
59
60
  manifest_path_filename: Union[str, None] = None,
61
+ force: bool = False,
60
62
  # Download
61
63
  category: Union[str, None] = None,
62
64
  category_format: Union[str, None] = None,
@@ -78,6 +80,7 @@ class Snapend:
78
80
  self.name: str = name
79
81
  self.env: str = env
80
82
  self.manifest_path_filename: Union[str, None] = manifest_path_filename
83
+ self.force: bool = force
81
84
  self.category: str = category
82
85
  self.portal_category: Union[str, None] = Snapend._make_portal_category(
83
86
  category_format)
@@ -598,14 +601,17 @@ class Snapend:
598
601
  payload = {
599
602
  'ext': self.manifest_file_name.split('.')[-1]
600
603
  }
604
+ if self.force is True:
605
+ info('Force flag is set. Ignoring manifest diff.')
606
+ payload['ignore_diff'] = 'true'
601
607
  url = f"{self.base_url}/v1/snapser-api/snapends/snapend-manifest"
602
608
  res = requests.put(
603
609
  url, headers={'api-key': self.api_key},
604
610
  files=files, data=payload, timeout=SERVER_CALL_TIMEOUT
605
611
  )
612
+ response = res.json()
606
613
  if res.ok:
607
614
  # extract the cluster ID
608
- response = res.json()
609
615
  if 'cluster' not in response or 'id' not in response['cluster']:
610
616
  snapctl_error(
611
617
  message='Server Error. Unable to get a Snapend ID. '
@@ -643,6 +649,13 @@ class Snapend:
643
649
  f"{response['cluster']['id']}`",
644
650
  progress=progress
645
651
  )
652
+ else:
653
+ if "api_error_code" in response and "message" in response:
654
+ if response['api_error_code'] == HTTP_ERROR_SNAPEND_MANIFEST_MISMATCH:
655
+ snapctl_error(
656
+ message='Remote manifest does not match the manifest in the applied_configuration field.',
657
+ code=SNAPCTL_SNAPEND_APPLY_MANIFEST_MISMATCH_ERROR, progress=progress
658
+ )
646
659
  except RequestException as e:
647
660
  snapctl_error(
648
661
  message=f"Unable to apply the manifest snapend. {e}",
@@ -3,7 +3,7 @@ Constants used by snapctl
3
3
  """
4
4
  COMPANY_NAME = 'Snapser'
5
5
  VERSION_PREFIX = 'beta-'
6
- VERSION = '0.48.0'
6
+ VERSION = '0.48.1'
7
7
  CONFIG_FILE_MAC = '~/.snapser/config'
8
8
  CONFIG_FILE_WIN = '%homepath%\\.snapser\\config'
9
9
 
@@ -27,6 +27,7 @@ HTTP_ERROR_SERVICE_VERSION_EXISTS = 542
27
27
  HTTP_ERROR_SERVICE_IN_USE = 543
28
28
  HTTP_ERROR_TAG_NOT_AVAILABLE = 544
29
29
  HTTP_ERROR_ADD_ON_NOT_ENABLED = 547
30
+ HTTP_ERROR_SNAPEND_MANIFEST_MISMATCH = 594
30
31
 
31
32
  # CLI Return Codes
32
33
  SNAPCTL_SUCCESS = 0
@@ -102,6 +103,7 @@ SNAPCTL_SNAPEND_UPDATE_ERROR = 72
102
103
  SNAPCTL_SNAPEND_UPDATE_SERVER_ERROR = 73
103
104
  SNAPCTL_SNAPEND_UPDATE_TIMEOUT_ERROR = 74
104
105
  SNAPCTL_SNAPEND_STATE_ERROR = 75
106
+ SNAPCTL_SNAPEND_APPLY_MANIFEST_MISMATCH_ERROR = 76
105
107
 
106
108
  # Generate Errors - 80 - 85
107
109
  SNAPCTL_GENERATE_GENERIC_ERROR = 80
snapctl/main.py CHANGED
@@ -546,6 +546,10 @@ def snapend(
546
546
  None, "--manifest-path-filename",
547
547
  help="(req: apply|clone) Full Path to the manifest file including the filename."
548
548
  ),
549
+ force: bool = typer.Option(
550
+ False, "--force",
551
+ help="(optional: apply) If true, Snapser will ignore the configuration diff validation and allow to force apply the manifest."
552
+ ),
549
553
  # download
550
554
  category: str = typer.Option(
551
555
  None, "--category",
@@ -646,6 +650,7 @@ def snapend(
646
650
  name=name, env=env,
647
651
  # Apply, Clone
648
652
  manifest_path_filename=manifest_path_filename,
653
+ force=force,
649
654
  # Download
650
655
  category=category,
651
656
  category_format=category_format,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: snapctl
3
- Version: 0.48.0
3
+ Version: 0.48.1
4
4
  Summary: Snapser CLI Tool
5
5
  Author: Ajinkya Apte
6
6
  Author-email: aj@snapser.com
@@ -640,8 +640,12 @@ snapctl snapend clone --game-id $game_id --name $snapend_name --env $env --manif
640
640
 
641
641
  #### 4. Apply Snapend Changes
642
642
 
643
- Apply changes to your Snapend from a manifest. You should have the latest manifest before applying changes. This is to prevent
644
- a user stomping over someone elses changes. Passing the blocking flag ensures your CLI command waits till the update is complete.
643
+ Apply changes to your Snapend from a manifest. You should have the latest manifest before applying changes. Basically, when you download a manifest, Snapser adds an `applied_configuration` section to your manifest, which stores the state of the Snapend during export. Now, if someone manually updates the Snapend or a configuration of a Snap, you are no longer going to have the latest Snapend representation in the `applied_configuration`. This is how Snapser prevents you from stomping over someone elses changes.
644
+
645
+ You can optionally pass a `--force` flag telling Snapser to ignore any diffs it may find in the current state of the Snapend and the one in the `applied_configuration` field of your manifest. Essentially, this flag allows you to stomp over any changes and tell Snapser to force apply.
646
+
647
+ Separately, you can pass a blocking flag to make your CLI wait for the Snapend update to complete.
648
+
645
649
 
646
650
  ```bash
647
651
  # Help for the apply command
@@ -649,10 +653,12 @@ snapctl snapend apply --help
649
653
 
650
654
  # Apply changes to a snapend via manifest
651
655
  # $path_to_manifest = Path to the manifest file; should include the file name
656
+ # --force = Optional flag to tell Snapser that you do not want it to check the diff between the Snapend states and just force apply the changes
652
657
  # Example:
653
- # snapctl snapend apply --manifest-path-filename "C:\Users\name\Downloads\snapser-ox1bcyim-manifest.json" --blocking
658
+ # snapctl snapend apply --manifest-path-filename "C:\Users\name\Downloads\snapser-ox1bcyim-manifest.json" --force --blocking
654
659
  snapctl snapend apply --manifest-path-filename "$path_to_manifest"
655
660
  snapctl snapend apply --manifest-path-filename "$path_to_manifest" --blocking
661
+ snapctl snapend apply --manifest-path-filename "$path_to_manifest" --force --blocking
656
662
  ```
657
663
 
658
664
  #### 5. Update Snapend BYOSnap or BYOGs versions
@@ -6,9 +6,9 @@ snapctl/commands/byosnap.py,sha256=xfUlIMUkiIRi6uYbtGvVR6vM_buO-6KH_i1ay3sELJY,7
6
6
  snapctl/commands/game.py,sha256=nCXtEXAJkvOw26c_OBGr7Pz4hwu-5FXHyBR2kkXhLCM,5247
7
7
  snapctl/commands/generate.py,sha256=9-NlZVQllBT2LZT_t9S3ztwtHzTbM-C8_x0f6z70U3g,5606
8
8
  snapctl/commands/release_notes.py,sha256=K1OdX94pL-pKL2Depbs-AkVcPpKn_CX2cOsZiRZP5kc,2134
9
- snapctl/commands/snapend.py,sha256=ZQSI_QfxsmqCkz2kBkFSMN94ZkSgXlzwZBJXEs5nOoM,38483
9
+ snapctl/commands/snapend.py,sha256=0Ygr3znXc_eu0sVt2YTznnUV4f_L8zjz3FtMSQMUwIY,39288
10
10
  snapctl/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- snapctl/config/constants.py,sha256=9qNitkpp08oNuEuPmHdQPpZ_P97R0CtIfiJVkNk2RQY,3500
11
+ snapctl/config/constants.py,sha256=_5qHkmSUabspjkR8RykZ2WfNEts1kdIAV-YibpQGquU,3594
12
12
  snapctl/config/endpoints.py,sha256=9kllA79xn9G_aBLp1rohURZi93pwYzTEWZ8ObtZ6crw,338
13
13
  snapctl/config/hashes.py,sha256=2Dyb3lbNRNKzc80XUH8S4yNJtRVGRCMK7-GwzyT4WQ0,5149
14
14
  snapctl/data/profiles/snapser-byosnap-profile.json,sha256=c7oIzMJewVQaoLaXCBPXlH-k5cL9DCz6q4IixsWWD9c,2404
@@ -20,14 +20,14 @@ snapctl/data/releases/beta-0.47.0.mdx,sha256=p-bp0NUVcSKELHXtHJaq884_O4yTZDTCUbW
20
20
  snapctl/data/releases/beta-0.47.1.mdx,sha256=YqQ7ncHDW9pCbQNnQic1o_xQt3DinOFEo3YW0hJVUAk,645
21
21
  snapctl/data/releases/beta-0.47.2.mdx,sha256=9FQuJj6ntu0gG5Mf-d8lgCRqmzkuFyESqI_Gf5jLNmo,135
22
22
  snapctl/data/releases/beta-0.48.0.mdx,sha256=b9Dz-a2FAaZx2BnFTyle7PgJ2RuNv6Zj1KsT2TfaNH8,1244
23
- snapctl/main.py,sha256=xjJSSdAGWiYYYC20OumSMxYQODTEAHbRRfyBstFiiAI,22685
23
+ snapctl/main.py,sha256=Or3zsN-4s7G-aJjOyJAtFh1pAvsI5MJjr6n018Lpg-Q,22906
24
24
  snapctl/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
25
  snapctl/types/definitions.py,sha256=EQzLeiXkJ8ISRlCqHMviNVsWWpmhWjpKaOBLdlvOTmY,644
26
26
  snapctl/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  snapctl/utils/echo.py,sha256=V0qgjqqGXRiueMkq31enmNmdqciC8S90qGRcK8UupXA,1090
28
28
  snapctl/utils/helper.py,sha256=co6HhAE-Fo4TMxjSNZUfjK40vAwD3n8qU_JQcNjSlmU,6584
29
- snapctl-0.48.0.dist-info/LICENSE,sha256=6AcXm54KFSpmUI1ji9NIBd4Xl-DtjTqiyjBzfVb_CEk,2804
30
- snapctl-0.48.0.dist-info/METADATA,sha256=elOdGRY3YjNJkIcwTfFk0aG2suCGriS1S5vFUltcgwY,33843
31
- snapctl-0.48.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
- snapctl-0.48.0.dist-info/entry_points.txt,sha256=tkKW9MzmFdRs6Bgkv29G78i9WEBK4WIOWunPfe3t2Wg,44
33
- snapctl-0.48.0.dist-info/RECORD,,
29
+ snapctl-0.48.1.dist-info/LICENSE,sha256=6AcXm54KFSpmUI1ji9NIBd4Xl-DtjTqiyjBzfVb_CEk,2804
30
+ snapctl-0.48.1.dist-info/METADATA,sha256=5Pk1yvwIEQOgBHWqeeroI4A9zRAosh8A9FJQZuyb3Co,34727
31
+ snapctl-0.48.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
32
+ snapctl-0.48.1.dist-info/entry_points.txt,sha256=tkKW9MzmFdRs6Bgkv29G78i9WEBK4WIOWunPfe3t2Wg,44
33
+ snapctl-0.48.1.dist-info/RECORD,,