Class: Jets::Command::CredentialsCommand

Inherits:
Base
  • Object
show all
Includes:
Diffing, EnvironmentArgument, Helpers::Editor
Defined in:
lib/jets/commands/credentials/credentials_command.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Diffing

Constant Summary

Constants included from Diffing

Diffing::GITATTRIBUTES_ENTRY

Instance Method Summary collapse

Methods included from Diffing

#disenroll_project_from_credentials_diffing, #enroll_project_in_credentials_diffing, #ensure_diffing_driver_is_configured

Methods inherited from Base

banner, base_name, command_name, default_command_root, desc, engine?, executable, exit_on_failure?, #help, hide_command!, inherited, long_desc, namespace, perform, printing_commands, usage_path

Methods included from ApiHelpers

#check_for_error_message!, #no_token_exit!, #paging_params

Methods included from AwsHelpers

#find_stack, #first_run?

Methods included from AwsServices

#apigateway, #aws_lambda, #aws_options, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts

Methods included from AwsServices::StackStatus

#lookup, #stack_exists?, #stack_in_progress?

Methods included from AwsServices::GlobalMemoist

included

Methods included from Actions

#load_generators, #load_tasks, #require_application!, #require_application_and_environment!, #set_application_directory!

Instance Method Details

#diff(content_path = nil) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/jets/commands/credentials/credentials_command.rb', line 58

def diff(content_path = nil)
  if @content_path = content_path
    extract_environment_option_from_argument(default_environment: extract_environment_from_path(content_path))
    require_application!

    say credentials.read.presence || credentials.content_path.read
  else
    require_application!
    disenroll_project_from_credentials_diffing if options[:disenroll]
    enroll_project_in_credentials_diffing if options[:enroll]
  end
rescue ActiveSupport::MessageEncryptor::InvalidMessage
  say credentials.content_path.read
end

#editObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/jets/commands/credentials/credentials_command.rb', line 26

def edit
  extract_environment_option_from_argument(default_environment: nil)
  require_application!

  ensure_editor_available(command: "bin/jets credentials:edit") || (return)

  ensure_encryption_key_has_been_added if credentials.key.nil?
  ensure_credentials_have_been_added
  ensure_diffing_driver_is_configured

  catch_editing_exceptions do
    change_credentials_in_system_editor
  end

  say "File encrypted and saved."
rescue ActiveSupport::MessageEncryptor::InvalidMessage
  say "Couldn't decrypt #{content_path}. Perhaps you passed the wrong key?"
end

#showObject



45
46
47
48
49
50
# File 'lib/jets/commands/credentials/credentials_command.rb', line 45

def show
  extract_environment_option_from_argument(default_environment: nil)
  require_application!

  say credentials.read.presence || missing_credentials_message
end