Class: TerraformEnterprise::CommandLine::PoliciesCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/terraform_enterprise/command_line/commands/policies.rb

Constant Summary collapse

ATTR_STR =
STRINGS[:policies][:attributes]
CMD_STR =
STRINGS[:policies][:commands]

Constants included from TerraformEnterprise::CommandLine

STRINGS, VERSION

Instance Method Summary collapse

Methods included from Util::Tar

#gzip, #tar, #tarball

Instance Method Details

#create(name) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 19

def create(name)
  params = {
    name: name,
    organization: options[:organization],
    enforce: [
      {
        path: "#{name}.sentinel",
        mode: options[:mode]
      }
    ]
  }
  render client.policies.create(params)
end

#delete(id) ⇒ Object



57
58
59
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 57

def delete(id)
  render client.policies.delete(id: id)
end

#get(id) ⇒ Object



52
53
54
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 52

def get(id)
  render client.policies.get(id:id)
end

#listObject



12
13
14
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 12

def list
  render client.policies.list(organization: options[:organization])
end

#update(id) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 35

def update(id)
  name = ''
  params = {
    id: id,
    name: name,
    enforce: [
      {
        path: 'default.sentinel',
        mode: options[:mode]
      }
    ]
  }

  render client.policies.update(params)
end

#upload(path, policy_id) ⇒ Object



62
63
64
65
66
67
68
69
# File 'lib/terraform_enterprise/command_line/commands/policies.rb', line 62

def upload(path, policy_id)
  full_path = File.expand_path(path)
  content = File.read(full_path)

  params = { content: content, id: policy_id }

  render client.policies.upload(params)
end