Sha256: af730fb9e2c22e4c2eb798a15e3929267b09bd7785bfb73826c4341adf94cc75

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'conjur/command'

class Conjur::Command::Layers < Conjur::Command
  self.prefix = :layer
  
  # Form an account:kind:hostid from the host argument
  # Or interpret a fully-qualified role id
  def self.require_hostid_arg(args)
    hostid = require_arg(args, 'host')
    if hostid.index(':') == 0
      hostid = [ Conjur::Core::API.conjur_account, 'host', hostid ].join(':')
    end
    hostid
  end

  desc "Add a host to an layer (note: host id should be provided in fully-qualified format, i.e. <conjur_account>:host:<id>)"
  arg_name "layer host"
  command :"hosts:add" do |c|
    c.action do |global_options, options, args|
      id = require_arg(args, 'layer')
      hostid = require_hostid_arg(args)
      
      api.layer(id).add_host hostid
    end
  end

  desc "Remove a host from an layer"
  arg_name "layer host"
  command :"hosts:remove" do |c|
    c.action do |global_options, options, args|
      id = require_arg(args, 'layer')
      hostid = require_hostid_arg(args)
      
      api.layer(id).remove_host hostid
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conjur-asset-layer-api-0.3.1 lib/conjur/command/layers.rb