Class: Jets::CLI::Dotenv::Set

Inherits:
Base
  • Object
show all
Includes:
Env::Parse
Defined in:
lib/jets/cli/dotenv/set.rb

Direct Known Subclasses

Unset

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods included from Env::Parse

#parse_cli_env_values

Methods inherited from Base

#initialize, #paginate, #paging_params, rescue_api_error

Methods included from Util::Logging

#log

Methods included from AwsServices

#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2

Methods included from AwsServices::StackStatus

#output_value, #stack_exists?

Methods included from AwsServices::GlobalMemoist

included, #reset_cache!

Methods included from Api

#api, #api_key

Constructor Details

This class inherits a constructor from Jets::CLI::Base

Instance Method Details

#namesObject



31
32
33
# File 'lib/jets/cli/dotenv/set.rb', line 31

def names
  vars.keys.map(&:to_s)
end

#option_keyObject

interface method



22
23
24
# File 'lib/jets/cli/dotenv/set.rb', line 22

def option_key
  :values
end

#performObject



13
14
15
# File 'lib/jets/cli/dotenv/set.rb', line 13

def perform
  ssm_manager.set(vars)
end

#runObject



5
6
7
8
9
10
11
# File 'lib/jets/cli/dotenv/set.rb', line 5

def run
  sure? sure_message
  puts "Setting SSM vars for #{Jets.project.namespace}"

  perform # interface method
  Jets::CLI::Tip.show(:ssm_change)
end

#ssm_managerObject



45
46
47
# File 'lib/jets/cli/dotenv/set.rb', line 45

def ssm_manager
  Jets::CLI::Dotenv::Ssm.new(@options)
end

#ssm_methodObject



26
27
28
29
# File 'lib/jets/cli/dotenv/set.rb', line 26

def ssm_method
  name = self.class.name.demodulize # Set or Unset
  (name == "Set") ? :set : :delete
end

#sure_messageObject



35
36
37
38
39
40
41
42
43
# File 'lib/jets/cli/dotenv/set.rb', line 35

def sure_message
  <<~EOL
    Will #{ssm_method} the SSM vars for #{Jets.project.namespace}
    Note: SSM changes do not update the Lambda function env vars.
    You will need run jets deploy to update the env vars.

    #{ssm_manager.preview_list(names)}
  EOL
end

#varsObject



17
18
19
# File 'lib/jets/cli/dotenv/set.rb', line 17

def vars
  parse_cli_env_values(@options[option_key])
end