team

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MPL-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package team manages teams, which are groups of users with shared privileges.

Index

Constants

View Source
const TeamTokenKind tokens.Kind = "team_token"

Variables

View Source
var ErrRemovingOwnersTeamNotPermitted = errors.New("the owners team cannot be deleted")

Functions

func NewTeamCommand

func NewTeamCommand(apiClient *otfapi.Client) *cobra.Command

Types

type Client

type Client struct {
	*otfapi.Client
}

func (*Client) Create added in v0.2.2

func (c *Client) Create(ctx context.Context, organization string, opts CreateTeamOptions) (*Team, error)

Create creates a team via HTTP/JSONAPI.

func (*Client) Delete added in v0.2.2

func (c *Client) Delete(ctx context.Context, id string) error

Delete deletes a team via HTTP/JSONAPI.

func (*Client) Get added in v0.2.2

func (c *Client) Get(ctx context.Context, organization, name string) (*Team, error)

Get retrieves a team via HTTP/JSONAPI.

type CreateTeamOptions

type CreateTeamOptions struct {
	// Name of team to create
	Name *string `json:"name" schema:"name,required"`

	OrganizationAccessOptions

	// TFE fields that OTF does not support but persists merely to pass the
	// go-tfe integration tests
	SSOTeamID  *string
	Visibility *string
}

type CreateTokenOptions

type CreateTokenOptions struct {
	TeamID string
	Expiry *time.Time
}

CreateTokenOptions are options for creating an team token via the service endpoint

type Options

type Options struct {
	*sql.DB
	*tfeapi.Responder
	html.Renderer
	logr.Logger

	OrganizationService *organization.Service
	TokensService       *tokens.Service
}

type OrganizationAccess

type OrganizationAccess struct {
	ManageWorkspaces bool // admin access on all workspaces
	ManageVCS        bool // manage VCS providers
	ManageModules    bool // manage module registry

	// TFE fields that OTF does not support but persists merely to pass the
	// go-tfe integration tests
	ManageProviders       bool
	ManagePolicies        bool
	ManagePolicyOverrides bool
}

OrganizationAccess defines a team's organization access.

type OrganizationAccessOptions

type OrganizationAccessOptions struct {
	ManageWorkspaces *bool `schema:"manage_workspaces"`
	ManageVCS        *bool `schema:"manage_vcs"`
	ManageModules    *bool `schema:"manage_modules"`

	// TFE fields that OTF does not support but persists merely to pass the
	// go-tfe integration tests
	ManageProviders       *bool
	ManagePolicies        *bool
	ManagePolicyOverrides *bool
}

OrganizationAccessOptions defines access to be granted upon team creation or to grant/rescind to/from an existing team.

type Service added in v0.2.2

type Service struct {
	logr.Logger
	// contains filtered or unexported fields
}

func NewService

func NewService(opts Options) *Service

func (*Service) AddHandlers added in v0.2.2

func (a *Service) AddHandlers(r *mux.Router)

func (*Service) AfterCreateTeam added in v0.2.2

func (a *Service) AfterCreateTeam(hook func(context.Context, *Team) error)

func (*Service) Create added in v0.2.2

func (a *Service) Create(ctx context.Context, organization string, opts CreateTeamOptions) (*Team, error)

func (*Service) CreateTeamToken added in v0.2.2

func (a *Service) CreateTeamToken(ctx context.Context, opts CreateTokenOptions) (*Token, []byte, error)

func (*Service) Delete added in v0.2.2

func (a *Service) Delete(ctx context.Context, teamID string) error

func (*Service) DeleteTeamToken added in v0.2.2

func (a *Service) DeleteTeamToken(ctx context.Context, teamID string) error

func (*Service) Get added in v0.2.2

func (a *Service) Get(ctx context.Context, organization, name string) (*Team, error)

func (*Service) GetByID added in v0.2.2

func (a *Service) GetByID(ctx context.Context, teamID string) (*Team, error)

func (*Service) GetTeamByTokenID added in v0.2.2

func (a *Service) GetTeamByTokenID(ctx context.Context, tokenID string) (*Team, error)

func (*Service) GetTeamToken added in v0.2.2

func (a *Service) GetTeamToken(ctx context.Context, teamID string) (*Token, error)

func (*Service) List added in v0.2.2

func (a *Service) List(ctx context.Context, organization string) ([]*Team, error)

List lists teams in the organization.

func (Service) NewTeamToken added in v0.2.2

func (f Service) NewTeamToken(opts CreateTokenOptions) (*Token, []byte, error)

func (*Service) Update added in v0.2.2

func (a *Service) Update(ctx context.Context, teamID string, opts UpdateTeamOptions) (*Team, error)

type Team

type Team struct {
	ID           string    `jsonapi:"primary,teams"`
	CreatedAt    time.Time `jsonapi:"attribute" json:"created-at"`
	Name         string    `jsonapi:"attribute" json:"name"`
	Organization string    `jsonapi:"attribute" json:"organization"`

	Access OrganizationAccess

	// TFE fields that OTF does not support but persists merely to pass the
	// go-tfe integration tests
	Visibility string
	SSOTeamID  *string
}

Team is a group of users sharing a level of authorization.

func (*Team) CanAccessOrganization

func (t *Team) CanAccessOrganization(action rbac.Action, org string) bool

func (*Team) CanAccessSite

func (t *Team) CanAccessSite(action rbac.Action) bool

func (*Team) CanAccessTeam

func (t *Team) CanAccessTeam(action rbac.Action, id string) bool

func (*Team) CanAccessWorkspace

func (t *Team) CanAccessWorkspace(action rbac.Action, policy internal.WorkspacePolicy) bool

func (*Team) IsOwner

func (t *Team) IsOwner(organization string) bool

func (*Team) IsOwners

func (t *Team) IsOwners() bool

func (*Team) IsSiteAdmin

func (t *Team) IsSiteAdmin() bool

func (*Team) OrganizationAccess

func (t *Team) OrganizationAccess() OrganizationAccess

func (*Team) Organizations

func (t *Team) Organizations() []string

func (*Team) String

func (t *Team) String() string

func (*Team) Update

func (t *Team) Update(opts UpdateTeamOptions) error

type TeamRow

type TeamRow struct {
	TeamID                          pgtype.Text        `json:"team_id"`
	Name                            pgtype.Text        `json:"name"`
	CreatedAt                       pgtype.Timestamptz `json:"created_at"`
	PermissionManageWorkspaces      pgtype.Bool        `json:"permission_manage_workspaces"`
	PermissionManageVCS             pgtype.Bool        `json:"permission_manage_vcs"`
	PermissionManageModules         pgtype.Bool        `json:"permission_manage_modules"`
	OrganizationName                pgtype.Text        `json:"organization_name"`
	SSOTeamID                       pgtype.Text        `json:"sso_team_id"`
	Visibility                      pgtype.Text        `json:"visibility"`
	PermissionManagePolicies        pgtype.Bool        `json:"permission_manage_policies"`
	PermissionManagePolicyOverrides pgtype.Bool        `json:"permission_manage_policy_overrides"`
	PermissionManageProviders       pgtype.Bool        `json:"permission_manage_providers"`
}

TeamRow represents the result of a database query for a team.

func (TeamRow) ToTeam

func (row TeamRow) ToTeam() *Team

type Token

type Token struct {
	ID        string
	CreatedAt time.Time

	// Token belongs to a team
	TeamID string
	// Optional expiry.
	Expiry *time.Time
}

Token provides information about an API token for a team.

func (*Token) LogValue

func (t *Token) LogValue() slog.Value

type UpdateTeamOptions

type UpdateTeamOptions struct {
	Name *string

	OrganizationAccessOptions

	// TFE fields that OTF does not support but persists merely to pass the
	// go-tfe integration tests
	SSOTeamID  *string
	Visibility *string
}

Jump to

Keyboard shortcuts

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