Class: Seira::Config
Constant Summary collapse
- VALID_ACTIONS =
%w[help get set unset list].freeze
- SUMMARY =
"Manage your application's environment variables configuration".freeze
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize(app:, action:, args:, context:) ⇒ Config
constructor
A new instance of Config.
- #main_config_name ⇒ Object
- #run ⇒ Object
Methods included from Commands
#gcloud, gcloud, kubectl, #kubectl, #tsh, tsh
Constructor Details
#initialize(app:, action:, args:, context:) ⇒ Config
Returns a new instance of Config.
17 18 19 20 21 22 |
# File 'lib/seira/config.rb', line 17 def initialize(app:, action:, args:, context:) @app = app @action = action @args = args @context = context end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
15 16 17 |
# File 'lib/seira/config.rb', line 15 def action @action end |
#app ⇒ Object (readonly)
Returns the value of attribute app.
15 16 17 |
# File 'lib/seira/config.rb', line 15 def app @app end |
#args ⇒ Object (readonly)
Returns the value of attribute args.
15 16 17 |
# File 'lib/seira/config.rb', line 15 def args @args end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
15 16 17 |
# File 'lib/seira/config.rb', line 15 def context @context end |
Instance Method Details
#get(key) ⇒ Object
48 49 50 51 52 |
# File 'lib/seira/config.rb', line 48 def get(key) config = fetch_current_config value = config.dig('data', key) value.nil? ? nil : value end |
#main_config_name ⇒ Object
44 45 46 |
# File 'lib/seira/config.rb', line 44 def main_config_name "#{app}-env-config" end |
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/seira/config.rb', line 24 def run case action when 'help' run_help when 'get' validate_single_key run_get when 'set' validate_keys_and_values run_set when 'unset' validate_single_key run_unset when 'list' run_list else fail "Unknown command encountered" end end |