Sha256: fa96cfbeae46f5dcae5a0210dbabd8fce97083a5708b411c56c26829577ebda3

Contents?: true

Size: 665 Bytes

Versions: 4

Compression:

Stored size: 665 Bytes

Contents

module Kontena::Cli::Nodes
  class RemoveLabelCommand < Clamp::Command
    include Kontena::Cli::Common

    parameter "NODE_ID", "Node id"
    parameter "LABEL", "Label"

    def execute
      require_api_url
      require_current_grid
      token = require_token

      node = client(token).get("grids/#{current_grid}/nodes/#{node_id}")
      unless node['labels'].include?(label)
        abort("Node #{node['name']} does not have label #{label}")
      end
      node['labels'].delete(label)
      data = {}
      data[:labels] = node['labels']
      client.put("nodes/#{node['id']}", data, {}, {'Kontena-Grid-Token' => node['grid']['token']})
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kontena-cli-0.12.3 lib/kontena/cli/nodes/remove_label_command.rb
kontena-cli-0.12.2 lib/kontena/cli/nodes/remove_label_command.rb
kontena-cli-0.12.1 lib/kontena/cli/nodes/remove_label_command.rb
kontena-cli-0.12.0 lib/kontena/cli/nodes/remove_label_command.rb