Sha256: 0f8d4b36b02a6773fd70625c9ec659f48bf7e4cfbda70d59d80bc5c1e647bd42

Contents?: true

Size: 1.12 KB

Versions: 39

Compression:

Stored size: 1.12 KB

Contents

module Kontena::Cli::Volumes
  class CreateCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions

    banner "Creates a volume"
    parameter 'NAME', 'Volume name'

    SCOPES = %w(grid stack instance)

    option '--driver', 'DRIVER', 'Volume driver to be used', required: true
    option '--driver-opt', 'DRIVER_OPT', 'Volume driver options', multivalued: true
    option '--scope', 'SCOPE', "Volume scope (#{SCOPES.join(',')})", required: true do |scope|
      exit_with_error "Unknown scope '#{scope}, must be one of #{SCOPES.join(',')}" unless SCOPES.include?(scope)
      scope
    end

    requires_current_master
    requires_current_master_token

    def execute
      volume = {
        name: name,
        scope: scope,
        driver: driver,
        driver_opts: parse_driver_opts
      }
      spinner "Creating volume #{pastel.cyan(name)} " do
        create_volume(volume)
      end
    end

    def parse_driver_opts
      driver_opt_list.map{ |opt| opt.split('=', 2) }.to_h
    end

    def create_volume(volume)
      client.post("volumes/#{current_grid}", volume)
    end
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
krates-1.7.11 lib/kontena/cli/volumes/create_command.rb
krates-1.7.10 lib/kontena/cli/volumes/create_command.rb
krates-1.7.9 lib/kontena/cli/volumes/create_command.rb
krates-1.7.8 lib/kontena/cli/volumes/create_command.rb
krates-1.7.7 lib/kontena/cli/volumes/create_command.rb
krates-1.7.6 lib/kontena/cli/volumes/create_command.rb
krates-1.7.5 lib/kontena/cli/volumes/create_command.rb
krates-1.7.4 lib/kontena/cli/volumes/create_command.rb
krates-1.7.3 lib/kontena/cli/volumes/create_command.rb
krates-1.7.2 lib/kontena/cli/volumes/create_command.rb
krates-1.7.1 lib/kontena/cli/volumes/create_command.rb
krates-1.7.0 lib/kontena/cli/volumes/create_command.rb
krates-1.6.9 lib/kontena/cli/volumes/create_command.rb
krates-1.6.8 lib/kontena/cli/volumes/create_command.rb
krates-1.6.7 lib/kontena/cli/volumes/create_command.rb
krates-1.6.6 lib/kontena/cli/volumes/create_command.rb
krates-1.6.5 lib/kontena/cli/volumes/create_command.rb
krates-1.6.4 lib/kontena/cli/volumes/create_command.rb
krates-1.6.3 lib/kontena/cli/volumes/create_command.rb
krates-1.6.2 lib/kontena/cli/volumes/create_command.rb