MCPcopy Create free account
hub / github.com/wal-e/wal-e / configure_backup_cxt

Function configure_backup_cxt

wal_e/cmd.py:445–559  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

443
444
445def configure_backup_cxt(args):
446 # Try to find some WAL-E prefix to store data in.
447 prefix = (args.file_prefix
448 or args.gs_prefix
449 or args.s3_prefix
450 or args.wabs_prefix
451 or os.getenv('WALE_FILE_PREFIX')
452 or os.getenv('WALE_GS_PREFIX')
453 or os.getenv('WALE_S3_PREFIX')
454 or os.getenv('WALE_SWIFT_PREFIX')
455 or os.getenv('WALE_WABS_PREFIX'))
456
457 if prefix is None:
458 raise UserException(
459 msg='no storage prefix defined',
460 hint=(
461 'Either set one of the'
462 ' --file-prefix,'
463 ' --gs-prefix,'
464 ' --s3-prefix or'
465 ' --wabs-prefix options'
466 ' or define one of the'
467 ' WALE_FILE_PREFIX,'
468 ' WALE_GS_PREFIX,'
469 ' WALE_S3_PREFIX,'
470 ' WALE_SWIFT_PREFIX or'
471 ' WALE_WABS_PREFIX,'
472 ' environment variables.'
473 )
474 )
475
476 store = storage.StorageLayout(prefix)
477
478 # GPG can be optionally layered atop of every backend, so a common
479 # code path suffices.
480 gpg_key_id = args.gpg_key_id or os.getenv('WALE_GPG_KEY_ID')
481 if gpg_key_id is not None:
482 external_program_check([GPG_BIN])
483
484 # Enumeration of reading in configuration for all supported
485 # backend data stores, yielding value adhering to the
486 # 'operator.Backup' protocol.
487 if store.is_s3:
488 use_instance_profile = args.aws_instance_profile or \
489 parse_boolean_envvar(os.getenv('AWS_INSTANCE_PROFILE'))
490 if use_instance_profile:
491 creds = s3_instance_profile()
492 else:
493 creds = s3_explicit_creds(args)
494 from wal_e.blobstore import s3
495 s3.sigv4_check_apply()
496
497 from wal_e.operator import s3_operator
498
499 return s3_operator.S3Backup(store, creds, gpg_key_id)
500 elif store.is_wabs:
501 account_name = args.wabs_account_name or os.getenv('WABS_ACCOUNT_NAME')
502 if account_name is None:

Callers 1

mainFunction · 0.85

Calls 11

UserExceptionClass · 0.90
WABSBackupClass · 0.90
SwiftBackupClass · 0.90
GSBackupClass · 0.90
FileBackupClass · 0.90
UserCriticalClass · 0.90
external_program_checkFunction · 0.85
parse_boolean_envvarFunction · 0.85
s3_instance_profileFunction · 0.85
s3_explicit_credsFunction · 0.85
_config_hint_generateFunction · 0.85

Tested by

no test coverage detected