Class: TerraformEnterprise::Commands::WorkspacesCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/terraform-enterprise/commands/workspaces_command.rb

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#create(name) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/terraform-enterprise/commands/workspaces_command.rb', line 25

def create(name)
  params = {
    organization: options[:organization],
    name: name,
    'working-directory' => options[:working_directory] || '',
  }
  if options[:repo] && options[:oauth_token]
    repo = {}
    repo['branch']             = options[:branch] || ''
    repo['identifier']         = options[:repo]
    repo['oauth-token-id']     = options[:oauth_token]
    repo['ingress-submodules'] = options[:ingress_submodules] || false
    params['vcs-repo'] = repo
  end

  params['migration-environment'] = options[:import_legacy_environment] if options[:import_legacy_environment]
  params['terraform_version']     = options[:terraform_version] if options[:terraform_version]
  render client.workspaces.create(params), except:[:permissions, :actions, :environment]
end

#delete(name) ⇒ Object



57
58
59
60
61
62
63
# File 'lib/terraform-enterprise/commands/workspaces_command.rb', line 57

def delete(name)
  params = {
    organization: options[:organization],
    workspace: name
  }
  render client.workspaces.delete(params), except:[:permissions, :actions, :environment]
end

#get(name) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/terraform-enterprise/commands/workspaces_command.rb', line 47

def get(name)
  params = {
    organization: options[:organization],
    workspace: name
  }
  render client.workspaces.get(params), except:[:permissions, :actions, :environment]
end

#listObject



12
13
14
# File 'lib/terraform-enterprise/commands/workspaces_command.rb', line 12

def list
  render client.workspaces.list(options), except:[:permissions, :actions, :environment, 'created-at']
end

#lock(id) ⇒ Object



77
78
79
# File 'lib/terraform-enterprise/commands/workspaces_command.rb', line 77

def lock(id)
  render client.workspaces.action(action: :lock, id: id), except:[:permissions, :actions, :environment]
end

#unlock(id) ⇒ Object



82
83
84
# File 'lib/terraform-enterprise/commands/workspaces_command.rb', line 82

def unlock(id)
  render client.workspaces.action(action: :unlock, id: id), except:[:permissions, :actions, :environment]
end

#update(name) ⇒ Object



70
71
72
73
74
# File 'lib/terraform-enterprise/commands/workspaces_command.rb', line 70

def update(name)
  params = options
  params[:workspace] = name
  render client.workspaces.update(params), except:[:permissions, :actions, :environment]
end