Class: Travis::CLI::Encrypt
- Inherits:
-
RepoCommand
- Object
- Command
- ApiCommand
- RepoCommand
- Travis::CLI::Encrypt
- Defined in:
- lib/travis/cli/encrypt.rb
Constant Summary
Constants inherited from RepoCommand
RepoCommand::GIT_REGEX, RepoCommand::TRAVIS
Constants inherited from Command
Command::DAY, Command::HOUR, Command::MINUTE, Command::WEEK
Constants included from Tools::Assets
Instance Attribute Summary collapse
-
#config_key ⇒ Object
Returns the value of attribute config_key.
Attributes inherited from RepoCommand
Attributes inherited from ApiCommand
Attributes inherited from Command
#arguments, #config, #debug, #force_interactive, #formatter, #input, #output
Instance Method Summary collapse
Methods inherited from RepoCommand
Methods inherited from ApiCommand
#authenticate, #detected_endpoint?, #endpoint_config, #enterprise?, #initialize, #pro?, #setup, #sync
Methods included from Travis::Client::Methods
#access_token, #access_token=, #account, #accounts, #api_endpoint, #api_endpoint=, #artifact, #broadcasts, #build, #cancel, #explicit_api_endpoint?, #github_auth, #hooks, #job, #lint, #listen, #logout, #regenerate_token, #remove_token, #repo, #repos, #restart, #user
Methods inherited from Command
abstract, abstract?, #check_completion, #check_ruby, #check_version, command_name, #command_name, #debug?, description, #error, #execute, #help, #info, #initialize, #last_check, #on_signal, #parse, #say, #setup, skip, subcommands, #terminal, #time, #usage, #usage_for, #warn, #write_to
Methods included from Tools::Assets
Methods included from Parser
Constructor Details
This class inherits a constructor from Travis::CLI::ApiCommand
Instance Attribute Details
#config_key ⇒ Object
Returns the value of attribute config_key.
9 10 11 |
# File 'lib/travis/cli/encrypt.rb', line 9 def config_key @config_key end |
Instance Method Details
#run(*args) ⇒ Object
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 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/travis/cli/encrypt.rb', line 19 def run(*args) confirm = force_interactive.nil? || force_interactive error 'cannot combine --override and --append' if append? && override? error '--append without --add makes no sense' if append? && !add? error '--override without --add makes no sense' if override? && !add? self.override |= !config_key.start_with?('env.') if add? && !append? if args.first =~ %r{\w+/\w+} && !args.first.include?('=') warn 'WARNING: The name of the repository is now passed to the command with the -r option:' warn " #{command("encrypt [...] -r #{args.first}")}" warn ' If you tried to pass the name of the repository as the first argument, you' warn " probably won't get the results you wanted.\n" end data = args.join(' ') if data.empty? say color('Reading from stdin, press Ctrl+D when done', :info) if $stdin.tty? data = $stdin.read end data = split? ? data.split("\n") : [data.strip] warn_env_assignments(data) encrypted = data.map { |data| repository.encrypt(data) } if config_key set_config(encrypted.map { |e| { 'secure' => e } }) confirm_and_save_travis_config confirm else list = encrypted.map { |data| format(data.inspect, ' secure: %s') } say(list.join("\n"), template(__FILE__), :none) end rescue OpenSSL::PKey::RSAError => e error "#{e..sub(' for key size', '')} - consider using " << color('travis encrypt-file', %i[red bold]) << color(' or ', :red) << color('travis env set', %i[red bold]) end |