snapctl 0.39.1__tar.gz → 0.39.3__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.39.1
3
+ Version: 0.39.3
4
4
  Summary: Snapser CLI Tool
5
5
  Author: Ajinkya Apte
6
6
  Author-email: aj@snapser.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "snapctl"
3
- version = "0.39.1"
3
+ version = "0.39.3"
4
4
  description = "Snapser CLI Tool"
5
5
  authors = ["Ajinkya Apte <aj@snapser.com>"]
6
6
  readme = "README.md"
@@ -251,6 +251,35 @@ class ByoGs:
251
251
  snapctl_error('BYOGS upload failure. Duplicate image error.',
252
252
  SNAPCTL_BYOGS_PUBLISH_DUPLICATE_TAG_ERROR, progress)
253
253
 
254
+ def _clean_slate(self) -> None:
255
+ progress = Progress(
256
+ SpinnerColumn(),
257
+ TextColumn("[progress.description]{task.description}"),
258
+ transient=True,
259
+ )
260
+ progress.start()
261
+ progress.add_task(
262
+ description='Cleaning cache and initializing...', total=None)
263
+ try:
264
+ # Specific ECR repository URL to check against
265
+ ecr_repo_url = self.token_parts[0]
266
+ if platform == "win32":
267
+ # Perform the Docker logout
268
+ logout_response = subprocess.run(
269
+ ['docker', 'logout', ecr_repo_url],
270
+ shell=True, check=False)
271
+ else:
272
+ # Perform the Docker logout
273
+ logout_response = subprocess.run([
274
+ f"docker logout {ecr_repo_url}"
275
+ ], shell=True, check=False)
276
+ if not logout_response.returncode:
277
+ return snapctl_success('Cleanup complete', progress, no_exit=True)
278
+ except subprocess.CalledProcessError:
279
+ warning('Unable to initialize with a clean slate.')
280
+ finally:
281
+ progress.stop()
282
+
254
283
  # Public methods
255
284
 
256
285
  # Validator
@@ -310,7 +339,6 @@ class ByoGs:
310
339
  3. Build your snap
311
340
  """
312
341
  self._check_dependencies()
313
- self._docker_login()
314
342
  self._docker_build()
315
343
 
316
344
  def push(self) -> None:
@@ -322,8 +350,9 @@ class ByoGs:
322
350
  4. Push your snap
323
351
  """
324
352
  self._check_dependencies()
325
- self._docker_login()
326
353
  self._docker_tag()
354
+ self._clean_slate()
355
+ self._docker_login()
327
356
  self._docker_push()
328
357
 
329
358
  # Upper echelon commands
@@ -338,11 +367,12 @@ class ByoGs:
338
367
  6. Upload swagger.json
339
368
  """
340
369
  self._check_dependencies()
341
- self._docker_login()
342
370
  if not self.skip_build:
343
371
  self._docker_build()
344
372
  else:
345
373
  info('--skip-build set. Skipping the build step.')
346
374
  self._docker_tag()
375
+ self._clean_slate()
376
+ self._docker_login()
347
377
  self._docker_push()
348
378
  snapctl_success('BYOGS publish successful')
@@ -354,6 +354,33 @@ class ByoSnap:
354
354
  SNAPCTL_INPUT_ERROR
355
355
  )
356
356
 
357
+ def _clean_slate(self) -> None:
358
+ progress = Progress(
359
+ SpinnerColumn(),
360
+ TextColumn("[progress.description]{task.description}"),
361
+ transient=True,
362
+ )
363
+ progress.start()
364
+ progress.add_task(
365
+ description='Cleaning cache and initializing...', total=None)
366
+ try:
367
+ # Specific ECR repository URL to check against
368
+ ecr_domain = self.token_parts[0].split('/')[0]
369
+ # Perform the Docker logout
370
+ if platform == "win32":
371
+ logout_response = subprocess.run(['docker', 'logout', ecr_domain],
372
+ shell=True, check=False)
373
+ else:
374
+ logout_response = subprocess.run([
375
+ f"docker logout {ecr_domain}"
376
+ ], shell=True, check=False)
377
+ if not logout_response.returncode:
378
+ return snapctl_success('Cleanup complete.', progress, no_exit=True)
379
+ except subprocess.CalledProcessError:
380
+ warning('Unable to initialize with a clean slate.')
381
+ finally:
382
+ progress.stop()
383
+
357
384
  # Public methods
358
385
 
359
386
  # Validator
@@ -497,7 +524,6 @@ class ByoSnap:
497
524
  3. Build your snap
498
525
  """
499
526
  self._check_dependencies()
500
- self._docker_login()
501
527
  self._docker_build()
502
528
 
503
529
  def push(self) -> bool:
@@ -509,8 +535,9 @@ class ByoSnap:
509
535
  4. Push your snap
510
536
  """
511
537
  self._check_dependencies()
512
- self._docker_login()
513
538
  self._docker_tag()
539
+ self._clean_slate()
540
+ self._docker_login()
514
541
  self._docker_push()
515
542
 
516
543
  # Upper echelon commands
@@ -658,12 +685,13 @@ class ByoSnap:
658
685
  6. Upload swagger.json
659
686
  """
660
687
  self._check_dependencies()
661
- self._docker_login()
662
688
  if not self.skip_build:
663
689
  self._docker_build()
664
690
  else:
665
691
  info('--skip-build set. Skipping the build step.')
666
692
  self._docker_tag()
693
+ self._clean_slate()
694
+ self._docker_login()
667
695
  self._docker_push()
668
696
  if self.path is not None or self.resources_path is not None:
669
697
  self.upload_docs()
@@ -2,7 +2,7 @@
2
2
  Constants used by snapctl
3
3
  """
4
4
  COMPANY_NAME = 'Snapser'
5
- VERSION = '0.39.1'
5
+ VERSION = '0.39.3'
6
6
  CONFIG_FILE_MAC = '~/.snapser/config'
7
7
  CONFIG_FILE_WIN = '%homepath%\\.snapser\\config'
8
8
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes