Class: SafeDb::Docker
Overview
This docker use case handles the …
safe docker login
safe docker logout
Constant Summary
Constants inherited from UseCase
UseCase::APP_DIR_NAME, UseCase::COMMANDMENT, UseCase::ENV_VAR_KEY_NAME, UseCase::ENV_VAR_PREFIX_A, UseCase::ENV_VAR_PREFIX_B, UseCase::FILE_CONTENT_KEY, UseCase::FILE_KEY_PREFIX, UseCase::FILE_NAME_KEY
Instance Attribute Summary collapse
-
#command ⇒ Object
writeonly
The command which currently must be login, logout or an empty string.
Attributes inherited from UseCase
Instance Method Summary collapse
Methods inherited from UseCase
#check_post_conditions, #check_pre_conditions, #cleanup, #config_directory, #config_file, #flow_of_events, #get_master_database, #initialize, #post_validation, #pre_validation
Constructor Details
This class inherits a constructor from SafeDb::UseCase
Instance Attribute Details
#command=(value) ⇒ Object (writeonly)
The command which currently must be login, logout or an empty string.
14 15 16 |
# File 'lib/usecase/docker/docker.rb', line 14 def command=(value) @command = value end |
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/usecase/docker/docker.rb', line 16 def execute return unless ops_key_exists? master_db = get_master_database() return if unopened_envelope?( master_db ) # Get the open chapter identifier (id). # Decide whether chapter already exists. # Then get (or instantiate) the chapter's hash data structure chapter_id = ENVELOPE_KEY_PREFIX + master_db[ ENV_PATH ] verse_id = master_db[ KEY_PATH ] chapter_exists = KeyApi.db_envelope_exists?( master_db[ chapter_id ] ) # Unlock the chapter data structure by supplying # key/value mini-dictionary breadcrumbs sitting # within the master database at the section labelled # envelope@<<actual_chapter_id>>. chapter_data = KeyDb.from_json( KeyApi.content_unlock( master_db[ chapter_id ] ) ) key_value_dictionary = chapter_data[ verse_id ] docker_username = key_value_dictionary[ "docker.username" ] docker_password = key_value_dictionary[ "@docker.password" ] docker_login_cmd = "docker login --username #{docker_username} --password #{docker_password} 2>/dev/null" docker_logout_cmd = "docker logout" docker_cmd = @command.eql?( "logout" ) ? docker_logout_cmd : docker_login_cmd system docker_cmd end |