user

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

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

View Source
const Organisation gosync.ConfigKey = "terraform_cloud_organisation"

Organisation sets the Terraform Cloud organisation.

View Source
const Team gosync.ConfigKey = "team"

Team is the name of the team to sync with.

View Source
const Token gosync.ConfigKey = "terraform_cloud_token"

Token sets the authentication token for Terraform Cloud.

Variables

View Source
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

func WithClient(client *tfe.Client) gosync.ConfigFn[*User]

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)
}

func WithLogger added in v0.14.0

func WithLogger(logger *log.Logger) gosync.ConfigFn[*User]

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)
}

Types

type User

type User struct {
	Logger *log.Logger
	// contains filtered or unexported fields
}

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)
}

func (*User) Add

func (u *User) Add(ctx context.Context, emails []string) error

Add users to a Terraform Cloud team.

func (*User) Get

func (u *User) Get(ctx context.Context) ([]string, error)

Get users in a Terraform Cloud team.

func (*User) Remove

func (u *User) Remove(ctx context.Context, emails []string) error

Remove users from a Terraform Cloud team.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL