organization

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 organization is responsible for OTF organizations

Index

Constants

View Source
const (
	DefaultSessionTimeout    = 20160
	DefaultSessionExpiration = 20160
)
View Source
const OrganizationTokenKind tokens.Kind = "organization_token"

Variables

This section is empty.

Functions

func NewCommand added in v0.1.9

func NewCommand(client *otfapi.Client) *cobra.Command

Types

type Authorizer

type Authorizer struct {
	logr.Logger
}

Authorizer authorizes access to an organization

func (*Authorizer) CanAccess

func (a *Authorizer) CanAccess(ctx context.Context, action rbac.Action, name string) (internal.Subject, error)

type CLI added in v0.1.9

type CLI struct {
	// contains filtered or unexported fields
}

type Client

type Client struct {
	*otfapi.Client

	Service
}

func (*Client) CreateOrganization added in v0.1.0

func (c *Client) CreateOrganization(ctx context.Context, options CreateOptions) (*Organization, error)

CreateOrganization creates a new organization with the given options.

func (*Client) DeleteOrganization

func (c *Client) DeleteOrganization(ctx context.Context, organization string) error

DeleteOrganization deletes an organization via http.

type CreateOptions added in v0.1.8

type CreateOptions struct {
	Name *string

	// TFE fields that OTF does not support but persists merely to pass the
	// go-tfe integration tests
	Email                      *string
	CollaboratorAuthPolicy     *string
	CostEstimationEnabled      *bool
	SessionRemember            *int
	SessionTimeout             *int
	AllowForceDeleteWorkspaces *bool
}

CreateOptions represents the options for creating an organization. See types.CreateOptions for more details.

type CreateOrganizationTokenOptions added in v0.2.0

type CreateOrganizationTokenOptions struct {
	Organization string `schema:"organization_name,required"`
	Expiry       *time.Time
}

CreateOrganizationTokenOptions are options for creating an organization token via the service endpoint

type Entitlements

type Entitlements struct {
	ID                    string
	Agents                bool
	AuditLogging          bool
	CostEstimation        bool
	Operations            bool
	PrivateModuleRegistry bool
	SSO                   bool
	Sentinel              bool
	StateStorage          bool
	Teams                 bool
	VCSIntegrations       bool
}

OTF is free and therefore the user is entitled to all currently supported services.

type ListOptions added in v0.0.51

type ListOptions struct {
	resource.PageOptions
}

ListOptions represents the options for listing organizations.

type Options

type Options struct {
	RestrictOrganizationCreation bool
	TokensService                *tokens.Service

	*sql.DB
	*tfeapi.Responder
	*sql.Listener
	html.Renderer
	logr.Logger
}

type Organization

type Organization struct {
	ID        string    `jsonapi:"primary,organizations"`
	CreatedAt time.Time `jsonapi:"attribute" json:"created-at"`
	UpdatedAt time.Time `jsonapi:"attribute" json:"updated-at"`
	Name      string    `jsonapi:"attribute" json:"name"`

	// TFE fields that OTF does not support but persists merely to pass the
	// go-tfe integration tests
	Email                      *string
	CollaboratorAuthPolicy     *string
	SessionRemember            *int
	SessionTimeout             *int
	AllowForceDeleteWorkspaces bool
	CostEstimationEnabled      bool
}

Organization is an OTF organization, comprising workspaces, users, etc.

func NewOrganization added in v0.1.0

func NewOrganization(opts CreateOptions) (*Organization, error)

func (*Organization) String

func (org *Organization) String() string

func (*Organization) Update

func (org *Organization) Update(opts UpdateOptions) error

type OrganizationPage

type OrganizationPage struct {
	html.SitePage

	Organization string
}

OrganizationPage contains data shared by all organization-based pages.

func NewPage

func NewPage(r *http.Request, title, organization string) OrganizationPage

type OrganizationToken added in v0.2.0

type OrganizationToken struct {
	ID        string
	CreatedAt time.Time
	// Token belongs to an organization
	Organization string
	// Optional expiry.
	Expiry *time.Time
}

OrganizationToken provides information about an API token for an organization

func (*OrganizationToken) CanAccessOrganization added in v0.2.0

func (u *OrganizationToken) CanAccessOrganization(action rbac.Action, org string) bool

func (*OrganizationToken) CanAccessSite added in v0.2.0

func (u *OrganizationToken) CanAccessSite(action rbac.Action) bool

func (*OrganizationToken) CanAccessTeam added in v0.2.0

func (u *OrganizationToken) CanAccessTeam(rbac.Action, string) bool

func (*OrganizationToken) CanAccessWorkspace added in v0.2.0

func (u *OrganizationToken) CanAccessWorkspace(action rbac.Action, policy internal.WorkspacePolicy) bool

func (*OrganizationToken) IsOwner added in v0.2.0

func (u *OrganizationToken) IsOwner(organization string) bool

func (*OrganizationToken) IsSiteAdmin added in v0.2.0

func (u *OrganizationToken) IsSiteAdmin() bool

func (*OrganizationToken) Organizations added in v0.2.0

func (u *OrganizationToken) Organizations() []string

func (*OrganizationToken) String added in v0.2.0

func (u *OrganizationToken) String() string

type Service

type Service struct {
	RestrictOrganizationCreation bool

	internal.Authorizer // authorize access to org
	logr.Logger
	// contains filtered or unexported fields
}

func NewService

func NewService(opts Options) *Service

func (*Service) AddHandlers added in v0.2.2

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

func (*Service) AfterCreateOrganization added in v0.1.8

func (s *Service) AfterCreateOrganization(hook func(context.Context, *Organization) error)

func (*Service) BeforeDeleteOrganization added in v0.1.8

func (s *Service) BeforeDeleteOrganization(hook func(context.Context, *Organization) error)

func (*Service) Create added in v0.2.2

func (s *Service) Create(ctx context.Context, opts CreateOptions) (*Organization, error)

Create creates an organization. Only users can create organizations, or, if RestrictOrganizationCreation is true, then only the site admin can create organizations. Creating an organization automatically creates an owners team and adds creator as an owner.

func (*Service) CreateToken added in v0.2.2

CreateToken creates an organization token. If an organization token already exists it is replaced.

func (*Service) Delete added in v0.2.2

func (s *Service) Delete(ctx context.Context, name string) error

func (*Service) DeleteToken added in v0.2.2

func (s *Service) DeleteToken(ctx context.Context, organization string) error

func (*Service) Get added in v0.2.2

func (s *Service) Get(ctx context.Context, name string) (*Organization, error)

func (*Service) GetEntitlements

func (s *Service) GetEntitlements(ctx context.Context, organization string) (Entitlements, error)

func (*Service) GetOrganizationToken added in v0.2.0

func (s *Service) GetOrganizationToken(ctx context.Context, organization string) (*OrganizationToken, error)

func (*Service) List added in v0.2.2

func (s *Service) List(ctx context.Context, opts ListOptions) (*resource.Page[*Organization], error)

List lists organizations according to the subject. If the subject has site-wide permission to list organizations then all organizations are listed. Otherwise: Subject is a user: list their organization memberships Subject is an agent: return its organization Subject is an organization token: return its organization Subject is a team: return its organization

func (*Service) ListTokens added in v0.2.2

func (s *Service) ListTokens(ctx context.Context, organization string) ([]*OrganizationToken, error)

func (*Service) Update added in v0.2.2

func (s *Service) Update(ctx context.Context, name string, opts UpdateOptions) (*Organization, error)

func (*Service) WatchOrganizations added in v0.2.0

func (s *Service) WatchOrganizations(ctx context.Context) (<-chan pubsub.Event[*Organization], func())

type UpdateOptions added in v0.1.8

type UpdateOptions struct {
	Name            *string
	SessionRemember *int
	SessionTimeout  *int

	// TFE fields that OTF does not support but persists merely to pass the
	// go-tfe integration tests
	Email                      *string
	CollaboratorAuthPolicy     *string
	CostEstimationEnabled      *bool
	AllowForceDeleteWorkspaces *bool
}

UpdateOptions represents the options for updating an organization.

Jump to

Keyboard shortcuts

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