terraform-enterprise-cli 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +121 -7
- data/lib/terraform_enterprise/command_line/command.rb +2 -1
- data/lib/terraform_enterprise/command_line/commands/configuration_versions.rb +4 -3
- data/lib/terraform_enterprise/command_line/commands/main.rb +5 -0
- data/lib/terraform_enterprise/command_line/strings.rb +6 -1
- data/lib/terraform_enterprise/command_line/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7be0ff4722fee573ba06f5669c5ff3f06f83d865
|
4
|
+
data.tar.gz: 54d126898d3df4a92ef5bfe6779cb8fe9d1de24f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a36b1e28eb77486f599d46ee4c7be11a362e71f9cfa2ba8c43f2d54aadd7527703adc2cacf8a6be7df894c8f2e1f6b5a1708ce992d88a27da70c105aa3ecf7b2
|
7
|
+
data.tar.gz: 4f22023eb7fc584bbd3382916521378c037d89d462d10c302afa6066eca7a238e89e88fd949cfd41fa8a6b63f506a26fbb1876196b0b09f7355eeb6f38ae0419
|
data/README.md
CHANGED
@@ -21,6 +21,10 @@ This gem depends on these other gems for usage at runtime:
|
|
21
21
|
|
22
22
|
Installing the gem `terraform-enterprise-cli` gem installs the `tfe` command line tool. Running `tfe help` provides the help information and list of available subcomands.
|
23
23
|
|
24
|
+
## Releases
|
25
|
+
|
26
|
+
All releases and changelogs are available as [Releases/Tags](https://github.com/skierkowski/terraform-enterprise-cli/releases).
|
27
|
+
|
24
28
|
## Usage
|
25
29
|
|
26
30
|
All of the resources, actions and paraeters are documented in the tool and available through the `help` subcommand.
|
@@ -30,13 +34,27 @@ All of the resources, actions and paraeters are documented in the tool and avail
|
|
30
34
|
```shell
|
31
35
|
➭ tfe help
|
32
36
|
Commands:
|
33
|
-
tfe
|
34
|
-
tfe help [COMMAND]
|
35
|
-
tfe
|
36
|
-
tfe organizations <subcommand>
|
37
|
-
tfe
|
38
|
-
tfe
|
39
|
-
tfe
|
37
|
+
tfe configuration-versions <subcommand> # Manage configuration versions
|
38
|
+
tfe help [COMMAND] # Describe available commands or one specific command
|
39
|
+
tfe oauth-tokens <subcommand> # Manage OAuth tokens
|
40
|
+
tfe organizations <subcommand> # Manage organizations
|
41
|
+
tfe policies <subcommand> # Manage policies
|
42
|
+
tfe policy-checks <subcommand> # Manage policy checks
|
43
|
+
tfe push <organization>/<workspace> --path=PATH # Pushes the configuration to the workspace
|
44
|
+
tfe runs <subcommand> # Manage runs
|
45
|
+
tfe teams <subcommand> # Manage teams
|
46
|
+
tfe variables <subcommand> # Manage variables
|
47
|
+
tfe workspaces <subcommand> # Manage workspaces
|
48
|
+
|
49
|
+
Options:
|
50
|
+
[--host=HOST] # Set host address for private Terraform Enterprise
|
51
|
+
[--token=TOKEN] # Set the auth token, defaults to TFE_TOKEN environment variable
|
52
|
+
[--color], [--no-color] # If disabled the ANSI color codes will not be used
|
53
|
+
[--except=one two three] # List of fields that should not be displayed
|
54
|
+
[--only=one two three] # List of fields that should be displayed
|
55
|
+
[--all], [--no-all] # Return all fields, not just summary
|
56
|
+
[--value], [--no-value] # Only return the value; i.e. do not show keys
|
57
|
+
[--debug], [--no-debug] # Show debug logs
|
40
58
|
```
|
41
59
|
|
42
60
|
## Authentication
|
@@ -54,6 +72,102 @@ The CLI is designed to be easy to call from other scripts. A few command line op
|
|
54
72
|
- `--value` (Boolean, default: false): The output text by default shows the key and values for each field. If this option is enabled only the value of the fields will be returned. This is particularly useful if you would like to obtain the id of a newly created resource (e.g. `tfe workspcaces create new-ws --organization my-organization --only name --value` would return only the name of the created workspace)
|
55
73
|
- `--no-table` (Boolean, default: false): For `list` subcommands format the output as a list of key/value paris instead of formatting the list in a table.
|
56
74
|
|
75
|
+
## Commands
|
76
|
+
|
77
|
+
### Help
|
78
|
+
|
79
|
+
Get the list of all all commands and subcommands, and global options:
|
80
|
+
|
81
|
+
`tfe help`
|
82
|
+
|
83
|
+
Get the help information for a particular subcommand. For example, you can see all the operations on workspaces by running `tfe help workspaces` or `tfe workspaces help`.
|
84
|
+
|
85
|
+
`tfe help <subcommand>`
|
86
|
+
`tfe <subcommand> help`
|
87
|
+
|
88
|
+
Get help information, including the options, for a specific command. For example, to get help on listing workspcaes you can use `tfe workspaces help list`
|
89
|
+
|
90
|
+
`tfe <subcommand> help <command>`
|
91
|
+
|
92
|
+
### Managing TFE Resources
|
93
|
+
|
94
|
+
The CLI supports managing the various Terraform Enterprise resources exposed via the TFE API. Below is a table of all the subcommands and the commands for each for performing CRUD operations. The `X` indicates the operation is supported by the CLI.
|
95
|
+
|
96
|
+
| resource / sub-command | list | get | update | create | delete |
|
97
|
+
| ---------------------- | :--: | :--: | :----: | :----: | :----: |
|
98
|
+
| configuration-version | X | X | | X | X |
|
99
|
+
| oauth-tokens | X | | | | |
|
100
|
+
| organizations | X | X | | X | X |
|
101
|
+
| policies | X | X | X | X | X |
|
102
|
+
| policy-checks | X | | | | |
|
103
|
+
| runs | X | X | | X | |
|
104
|
+
| teams | X | X | | X | X |
|
105
|
+
| variables | X | X | X | X | X |
|
106
|
+
| workspaces | X | X | X | X | X |
|
107
|
+
|
108
|
+
### Upload a configuration-version
|
109
|
+
|
110
|
+
```
|
111
|
+
tfe configuration-versions upload
|
112
|
+
```
|
113
|
+
|
114
|
+
### Upload a Sentinel policy
|
115
|
+
|
116
|
+
```
|
117
|
+
tfe policies upload
|
118
|
+
```
|
119
|
+
|
120
|
+
### Override a policy check
|
121
|
+
|
122
|
+
```
|
123
|
+
tfe policy-checks override
|
124
|
+
```
|
125
|
+
|
126
|
+
|
127
|
+
### Apply or discard a run
|
128
|
+
|
129
|
+
If a workspace is configured with auto-apply disabled and a plan completes successfully, then the run can be applied or discarded.
|
130
|
+
|
131
|
+
```
|
132
|
+
tfe runs apply <id>
|
133
|
+
tfe runs discard <id>
|
134
|
+
```
|
135
|
+
|
136
|
+
### Read and follow run logs (plan & apply)
|
137
|
+
|
138
|
+
When a run is strated in Terraform Enterprise it will queue the work and then execute the plan. Once the plan finishes successfully, it will automatically start an apply or it can be started manually if auto-apply is disabled. When the plan and apply execute, the output is saved in TFE. This is the same output if you ran `terraform plan` or `terraform apply` locally. These locs are accessible via the API and CLI.
|
139
|
+
|
140
|
+
```
|
141
|
+
tfe runs logs <run-id> --event=<event>
|
142
|
+
```
|
143
|
+
|
144
|
+
The `--follow` option can also be specified. If used, this will render the current logs in real time (refreshed every 2 seconds). If the the particular event has not started, then the command will sit idly waiting for the particular event to start.
|
145
|
+
|
146
|
+
### Lock and unlock a workspace
|
147
|
+
|
148
|
+
A workspace can be locked and unlocked. Locking prevents runs from being execute, but permits in progress runs to complete. The workspace ID (not the name) is required to perform the `lock` and `unlock` action.
|
149
|
+
|
150
|
+
```
|
151
|
+
tfe workspace lock <id>
|
152
|
+
tfe workspace unlock <id>
|
153
|
+
```
|
154
|
+
|
155
|
+
### Get the Workspace ID
|
156
|
+
|
157
|
+
A few commands require the workspace ID, not the workspace and organization name. The easiest way to obtain the workspace ID given a organization name and workspace name is to use the `workspaces get` subcommand. The `--value` option will strip away the keys, and the `--only id` option will return only the ID field. As such, response will return the workspace ID.
|
158
|
+
|
159
|
+
```
|
160
|
+
tfe workspaces get <workspace_name> --organization=<organization_name> --value --only id
|
161
|
+
```
|
162
|
+
|
163
|
+
### Get the run ID
|
164
|
+
|
165
|
+
A few command require the run ID. This can be obtained dusing the `tfe runs list` command. The command below shows a nicely formatted list with a few fields removed for brevity.
|
166
|
+
|
167
|
+
```
|
168
|
+
tfe runs list --workspace-id=<workspace_id> --except status-timestamps permissions actions
|
169
|
+
```
|
170
|
+
|
57
171
|
## Contribution
|
58
172
|
|
59
173
|
Contribution to the CLI is welcome. Opening issues and pull requests is welcome and will be reviewed.
|
@@ -46,8 +46,9 @@ module TerraformEnterprise
|
|
46
46
|
def client
|
47
47
|
settings = {}
|
48
48
|
settings[:token] = options[:token] || ENV['TFE_TOKEN']
|
49
|
+
settings[:host] = ENV['TFE_HOST'] if ENV['TFE_HOST']
|
49
50
|
settings[:host] = options[:host] if options[:host]
|
50
|
-
settings[:debug] = options[:debug]
|
51
|
+
settings[:debug] = options[:debug] || ENV['TFE_DEBUG']
|
51
52
|
TerraformEnterprise::API::Client.new(settings)
|
52
53
|
end
|
53
54
|
|
@@ -26,9 +26,10 @@ module TerraformEnterprise
|
|
26
26
|
render client.configuration_versions.get(id: id)
|
27
27
|
end
|
28
28
|
|
29
|
-
desc 'upload <
|
30
|
-
|
31
|
-
|
29
|
+
desc 'upload <upload-url>', CMD_STR[:upload]
|
30
|
+
option :path, default: '.', type: :string, desc: ATTR_STR[:path]
|
31
|
+
def upload(url)
|
32
|
+
content = tarball(options[:path])
|
32
33
|
params = { content: content, url: url }
|
33
34
|
|
34
35
|
render client.configuration_versions.upload(params)
|
@@ -74,6 +74,11 @@ module TerraformEnterprise
|
|
74
74
|
upload_params = { content: content, url: upload_url }
|
75
75
|
render client.configuration_versions.upload(upload_params)
|
76
76
|
end
|
77
|
+
|
78
|
+
desc 'version', STRINGS[:version][:commands][:version]
|
79
|
+
def version
|
80
|
+
puts "Terraform Enterprise CLI #{VERSION}"
|
81
|
+
end
|
77
82
|
end
|
78
83
|
end
|
79
84
|
end
|
@@ -22,6 +22,11 @@ module TerraformEnterprise
|
|
22
22
|
push: 'Pushes the configuration to the workspace'
|
23
23
|
}
|
24
24
|
},
|
25
|
+
version: {
|
26
|
+
commands: {
|
27
|
+
version: 'Show current version'
|
28
|
+
}
|
29
|
+
},
|
25
30
|
workspaces: {
|
26
31
|
attributes: {
|
27
32
|
terraform_version: 'Version of Terraform to use for this workspace.',
|
@@ -47,7 +52,7 @@ module TerraformEnterprise
|
|
47
52
|
configuration_versions: {
|
48
53
|
attributes: {
|
49
54
|
workspace_id: 'Workspace ID of the workspace to which the configuration version belongs to.',
|
50
|
-
path: 'Path
|
55
|
+
path: 'Path of directory or tar.gz file to push to the workspace'
|
51
56
|
},
|
52
57
|
commands: {
|
53
58
|
create: 'Create a new configuration version',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraform-enterprise-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maciej Skierkowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: terraform-enterprise-client
|
@@ -138,8 +138,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
141
|
+
rubygems_version: 2.6.12
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: CLI tool for interacting with Terraform Enterprise
|
145
145
|
test_files: []
|
146
|
+
has_rdoc:
|