Class: TerraformEnterprise::CommandLine::Commands::WorkspacesCommand

Inherits:
TerraformEnterprise::CommandLine::Command show all
Defined in:
lib/terraform_enterprise/command_line/commands/workspaces.rb

Constant Summary collapse

ATTR_STR =
STRINGS[:workspaces][:attributes]
CMD_STR =
STRINGS[:workspaces][: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



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/terraform_enterprise/command_line/commands/workspaces.rb', line 26

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



58
59
60
61
62
63
64
# File 'lib/terraform_enterprise/command_line/commands/workspaces.rb', line 58

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

#get(name) ⇒ Object



48
49
50
51
52
53
54
# File 'lib/terraform_enterprise/command_line/commands/workspaces.rb', line 48

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

#listObject



13
14
15
# File 'lib/terraform_enterprise/command_line/commands/workspaces.rb', line 13

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

#lock(id) ⇒ Object



78
79
80
# File 'lib/terraform_enterprise/command_line/commands/workspaces.rb', line 78

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

#unlock(id) ⇒ Object



83
84
85
# File 'lib/terraform_enterprise/command_line/commands/workspaces.rb', line 83

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

#update(name) ⇒ Object



71
72
73
74
75
# File 'lib/terraform_enterprise/command_line/commands/workspaces.rb', line 71

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