![]() Signed-off-by: Paul Thrasher <pthrasher@hashicorp.com> |
||
---|---|---|
.. | ||
examples | ||
test-fixtures | ||
LICENSE | ||
README.md | ||
apply.go | ||
apply_test.go | ||
configuration_version.go | ||
configuration_version_test.go | ||
cost_estimation.go | ||
cost_estimation_test.go | ||
go.mod | ||
go.sum | ||
helper_test.go | ||
logreader.go | ||
logreader_test.go | ||
notification_configuration.go | ||
notification_configuration_test.go | ||
oauth_client.go | ||
oauth_client_test.go | ||
oauth_token.go | ||
oauth_token_test.go | ||
organization.go | ||
organization_test.go | ||
organization_token.go | ||
organization_token_test.go | ||
plan.go | ||
plan_test.go | ||
policy.go | ||
policy_check.go | ||
policy_check_test.go | ||
policy_set.go | ||
policy_set_test.go | ||
policy_test.go | ||
run.go | ||
run_test.go | ||
ssh_key.go | ||
ssh_key_test.go | ||
state_version.go | ||
state_version_test.go | ||
team.go | ||
team_access.go | ||
team_access_test.go | ||
team_member.go | ||
team_member_test.go | ||
team_test.go | ||
team_token.go | ||
team_token_test.go | ||
tfe.go | ||
tfe_test.go | ||
type_helpers.go | ||
user.go | ||
user_test.go | ||
validations.go | ||
variable.go | ||
variable_test.go | ||
workspace.go | ||
workspace_test.go |
README.md
Terraform Enterprise Go Client
This is an API client for Terraform Enterprise.
NOTE
The Terraform Enterprise API endpoints are in beta and are subject to change! So that means this API client is also in beta and is also subject to change. We will indicate any breaking changes by releasing new versions. Until the release of v1.0, any minor version changes will indicate possible breaking changes. Patch version changes will be used for both bugfixes and non-breaking changes.
Coverage
Currently the following endpoints are supported:
- Accounts
- Configuration Versions
- OAuth Clients
- OAuth Tokens
- Organizations
- Organization Tokens
- Policies
- Policy Sets
- Policy Checks
- Registry Modules
- Runs
- SSH Keys
- State Versions
- Team Access
- Team Memberships
- Team Tokens
- Teams
- Variables
- Workspaces
- Admin
Installation
Installation can be done with a normal go get
:
go get -u github.com/hashicorp/go-tfe
Documentation
For complete usage of the API client, see the full package docs.
Usage
import tfe "github.com/hashicorp/go-tfe"
Construct a new TFE client, then use the various endpoints on the client to access different parts of the Terraform Enterprise API. For example, to list all organizations:
config := &tfe.Config{
Token: "insert-your-token-here",
}
client, err := tfe.NewClient(config)
if err != nil {
log.Fatal(err)
}
orgs, err := client.Organizations.List(context.Background(), OrganizationListOptions{})
if err != nil {
log.Fatal(err)
}
Examples
The examples directory contains a couple of examples. One of which is listed here as well:
package main
import (
"log"
tfe "github.com/hashicorp/go-tfe"
)
func main() {
config := &tfe.Config{
Token: "insert-your-token-here",
}
client, err := tfe.NewClient(config)
if err != nil {
log.Fatal(err)
}
// Create a context
ctx := context.Background()
// Create a new organization
options := tfe.OrganizationCreateOptions{
Name: tfe.String("example"),
Email: tfe.String("info@example.com"),
}
org, err := client.Organizations.Create(ctx, options)
if err != nil {
log.Fatal(err)
}
// Delete an organization
err = client.Organizations.Delete(ctx, org.Name)
if err != nil {
log.Fatal(err)
}
}
Running tests
Tests are run against an actual backend so they require a valid backend address and token. In addition it also needs a Github token for running the OAuth Client tests:
$ export TFE_ADDRESS=https://tfe.local
$ export TFE_TOKEN=xxxxxxxxxxxxxxxxxxx
$ export GITHUB_TOKEN=xxxxxxxxxxxxxxxx
In order for the tests relating to queuing and capacity to pass, FRQ should be enabled with a limit of 2 concurrent runs per organization.
As running the tests takes about ~10 minutes, make sure to add a timeout to your command (as the default timeout is 10m):
$ go test ./... -timeout=15m
Issues and Contributing
If you find an issue with this package, please report an issue. If you'd like, we welcome any contributions. Fork this repository and submit a pull request.