Module: Jackal::Stacks::StackCommon
Instance Method Summary collapse
-
#api_config ⇒ Hash
API connection configuration.
-
#determine_namespace(payload) ⇒ String
Determine namespace key to use for accessing parameters.
-
#stack_name(payload) ⇒ String
Generate stack name based on payload.
- #stacks_api ⇒ Miasma::Models::Orchestration
Instance Method Details
#api_config ⇒ Hash
Returns API connection configuration.
13 14 15 16 17 |
# File 'lib/jackal-stacks/stack_common.rb', line 13 def api_config config.fetch(:orchestration, :api, Smash.new).merge( :type => :orchestration ) end |
#determine_namespace(payload) ⇒ String
Note:
if not match found, ‘default` will return
Determine namespace key to use for accessing parameters
24 25 26 27 28 |
# File 'lib/jackal-stacks/stack_common.rb', line 24 def determine_namespace(payload) config.fetch(:mappings, Smash.new).map do |ns, glob| ns if File.fnmatch?(glob, payload.get(:data, :stacks, :reference).to_s) end.compact.first end |
#stack_name(payload) ⇒ String
Generate stack name based on payload
34 35 36 37 38 39 40 41 42 |
# File 'lib/jackal-stacks/stack_common.rb', line 34 def stack_name(payload) s_namespace = determine_namespace(payload) s_project = payload.fetch(:data, :stacks, :project, SecureRandom.urlsafe_base64) [ s_namespace, s_project, payload.get(:data, :stacks, :template).sub(/\.[a-z]+$/, '') ].compact.join('-').gsub(/[^A-Za-z0-9\-]/, '-') end |
#stacks_api ⇒ Miasma::Models::Orchestration
8 9 10 |
# File 'lib/jackal-stacks/stack_common.rb', line 8 def stacks_api Miasma.api(api_config) end |