Sha256: 4b0275f7ef8ecb6258d7013beea516cc7dce9fc16ecb1c78c11d879489523db2

Contents?: true

Size: 1.17 KB

Versions: 19

Compression:

Stored size: 1.17 KB

Contents

require_relative '../apps/yaml/reader'

module Kontena::Cli::Stacks
  module Common
    include Kontena::Cli::Apps::Common

    def service_prefix
      @service_prefix ||= project_name_from_yaml(filename)
    end

    def stack_from_yaml(filename)
      set_env_variables(service_prefix, current_grid)
      outcome = read_yaml(filename)
      if outcome[:version] != '2'
        STDERR.puts "Stack supported only in v2 YAML! Aborting.".colorize(:red)
        abort
      end
      if outcome[:name].nil?
        STDERR.puts "Stack MUST have name in YAML! Aborting.".colorize(:red)
        abort
      end
      hint_on_validation_notifications(outcome[:notifications]) if outcome[:notifications].size > 0
      abort_on_validation_errors(outcome[:errors]) if outcome[:errors].size > 0
      kontena_services = generate_services(outcome[:services], outcome[:version])
      # services now as hash, needs to be array in stacks API
      services = []
      kontena_services.each do |name, service|
        service['name'] = prefixed_name(name)
        services << service
      end
      stack = {
        'name' => outcome[:name],
        'services' => services
      }
      stack
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
kontena-cli-0.15.5 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.5.rc2 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.5.rc1 lib/kontena/cli/stacks/common.rb
kontena-cli-0.16.0.pre5 lib/kontena/cli/stacks/common.rb
kontena-cli-0.16.0.pre4 lib/kontena/cli/stacks/common.rb
kontena-cli-0.16.0.pre3 lib/kontena/cli/stacks/common.rb
kontena-cli-0.16.0.pre2 lib/kontena/cli/stacks/common.rb
kontena-cli-0.16.0.pre1 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.4 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.4.rc2 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.4.rc1 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.4.pre1 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.3 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.2 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.1 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.0 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.0.rc3 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.0.rc2 lib/kontena/cli/stacks/common.rb
kontena-cli-0.15.0.rc1 lib/kontena/cli/stacks/common.rb