team

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: 6 Imported by: 0

Documentation

Overview

Package team synchronises teams with a Terraform Cloud organisation.

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 Token gosync.ConfigKey = "terraform_cloud_token"

Token sets the authentication token for Terraform Cloud.

Variables

This section is empty.

Functions

func WithClient added in v0.14.0

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

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/team"
)

func main() {
	ctx := context.Background()

	client, err := tfe.NewClient(&tfe.Config{Token: "token"})
	if err != nil {
		log.Fatal(err)
	}

	adapter, err := team.Init(ctx, map[gosync.ConfigKey]string{
		team.Organisation: "ovotech",
	}, team.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[*Team]

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/team"
)

func main() {
	ctx := context.Background()

	logger := log.New(os.Stdout, "", log.LstdFlags)

	adapter, err := team.Init(ctx, map[gosync.ConfigKey]string{
		team.Token:        "my-org-token",
		team.Organisation: "ovotech",
	}, team.WithLogger(logger))
	if err != nil {
		log.Fatal(err)
	}

	gosync.New(adapter)
}

Types

type Team

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

func Init

func Init(_ context.Context, config map[gosync.ConfigKey]string, configFns ...gosync.ConfigFn[*Team]) (*Team, error)

Init a new Terraform Cloud Team gosync.Adapter.

Required config:

Example
package main

import (
	"context"
	"log"

	gosync "github.com/ovotech/go-sync"
	"github.com/ovotech/go-sync/adapters/terraformcloud/team"
)

func main() {
	ctx := context.Background()

	adapter, err := team.Init(ctx, map[gosync.ConfigKey]string{
		team.Token:        "my-org-token",
		team.Organisation: "ovotech",
	})
	if err != nil {
		log.Fatal(err)
	}

	gosync.New(adapter)
}

func (*Team) Add

func (t *Team) Add(ctx context.Context, teams []string) error

Add teams to a Terraform Cloud organisation.

func (*Team) Get

func (t *Team) Get(ctx context.Context) ([]string, error)

Get teams in a Terraform Cloud organisation.

func (*Team) Remove

func (t *Team) Remove(ctx context.Context, teams []string) error

Remove teams from a Terraform Cloud organisation.

Jump to

Keyboard shortcuts

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