Sha256: 2fe1cb1abb4eb19b9af0fa47dd306b85a5f4447bf2c2bb896162a8c0524e8929

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

class Jets::CLI::Dotenv
  class Set < Base
    include Jets::CLI::Env::Parse

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

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

    def perform
      ssm_manager.set(vars)
    end

    def vars
      parse_cli_env_values(@options[option_key])
    end

    # interface method
    def option_key
      :values
    end

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

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

    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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jets-6.0.5 lib/jets/cli/dotenv/set.rb
jets-6.0.4 lib/jets/cli/dotenv/set.rb
jets-6.0.3 lib/jets/cli/dotenv/set.rb
jets-6.0.2 lib/jets/cli/dotenv/set.rb