Documentation
¶
Overview ¶
Package user synchronises users in a Terraform Cloud team.
Requirements ¶
In order to synchronise with Terraform cloud, you will need an Organization API token: https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/api-tokens#organization-api-tokens
Examples ¶
See [New] and Init.
Index ¶
Examples ¶
Constants ¶
const Organisation gosync.ConfigKey = "terraform_cloud_organisation"
Organisation sets the Terraform Cloud organisation.
const Team gosync.ConfigKey = "team"
Team is the name of the team to sync with.
const Token gosync.ConfigKey = "terraform_cloud_token"
Token sets the authentication token for Terraform Cloud.
Variables ¶
var ErrTeamNotFound = errors.New("team_not_found")
ErrTeamNotFound is returned if the team cannot be found in the Terraform Cloud organisation.
Functions ¶
func WithClient ¶ added in v0.14.0
WithClient passes a custom Terraform Cloud client to the adapter.
Example ¶
package main
import (
"context"
"log"
"github.com/hashicorp/go-tfe"
gosync "github.com/ovotech/go-sync"
"github.com/ovotech/go-sync/adapters/terraformcloud/user"
)
func main() {
ctx := context.Background()
client, err := tfe.NewClient(&tfe.Config{Token: "token"})
if err != nil {
log.Fatal(err)
}
adapter, err := user.Init(ctx, map[gosync.ConfigKey]string{
user.Organisation: "ovotech",
user.Team: "my-team",
}, user.WithClient(client))
if err != nil {
log.Fatal(err)
}
gosync.New(adapter)
}
Output:
func WithLogger ¶ added in v0.14.0
WithLogger passes a custom logger to the adapter.
Example ¶
package main
import (
"context"
"log"
"os"
gosync "github.com/ovotech/go-sync"
"github.com/ovotech/go-sync/adapters/terraformcloud/user"
)
func main() {
ctx := context.Background()
logger := log.New(os.Stdout, "", log.LstdFlags)
adapter, err := user.Init(ctx, map[gosync.ConfigKey]string{
user.Token: "my-org-token",
user.Organisation: "ovotech",
user.Team: "my-team",
}, user.WithLogger(logger))
if err != nil {
log.Fatal(err)
}
gosync.New(adapter)
}
Output:
Types ¶
type User ¶
func Init ¶
func Init(_ context.Context, config map[gosync.ConfigKey]string, configFns ...gosync.ConfigFn[*User]) (*User, error)
Init a new Terraform Cloud User gosync.Adapter.
Required config:
Example ¶
package main
import (
"context"
"log"
gosync "github.com/ovotech/go-sync"
"github.com/ovotech/go-sync/adapters/terraformcloud/user"
)
func main() {
ctx := context.Background()
adapter, err := user.Init(ctx, map[gosync.ConfigKey]string{
user.Token: "my-org-token",
user.Organisation: "ovotech",
user.Team: "my-team",
})
if err != nil {
log.Fatal(err)
}
gosync.New(adapter)
}
Output: