provider

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MPL-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LastVersionsKey = "last_versions"
View Source
var UUIDType = uuidType{}

Functions

func CheckGroupEntitlements

func CheckGroupEntitlements(ctx context.Context, features map[codersdk.FeatureName]codersdk.Feature) (diags diag.Diagnostics)

func New

func New(version string) func() provider.Provider

func NewActiveVersionValidator

func NewActiveVersionValidator() validator.List

func NewGroupDataSource

func NewGroupDataSource() datasource.DataSource

func NewGroupResource

func NewGroupResource() resource.Resource

func NewLicenseResource added in v0.0.5

func NewLicenseResource() resource.Resource

func NewOrganizationDataSource

func NewOrganizationDataSource() datasource.DataSource

func NewTemplateDataSource

func NewTemplateDataSource() datasource.DataSource

func NewTemplateResource

func NewTemplateResource() resource.Resource

func NewUserDataSource

func NewUserDataSource() datasource.DataSource

func NewUserResource

func NewUserResource() resource.Resource

func NewVersionsPlanModifier

func NewVersionsPlanModifier() planmodifier.List

func NewWorkspaceProxyResource

func NewWorkspaceProxyResource() resource.Resource

func PrintOrNull

func PrintOrNull(v any) string

func PtrTo

func PtrTo[T any](v T) *T

Types

type ACL

type ACL struct {
	UserPermissions  []Permission `tfsdk:"users"`
	GroupPermissions []Permission `tfsdk:"groups"`
}

type AutostopRequirement

type AutostopRequirement struct {
	DaysOfWeek []string `tfsdk:"days_of_week"`
	Weeks      int64    `tfsdk:"weeks"`
}

type CoderdProvider

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

CoderdProvider defines the provider implementation.

func (*CoderdProvider) Configure

func (*CoderdProvider) DataSources

func (p *CoderdProvider) DataSources(ctx context.Context) []func() datasource.DataSource

func (*CoderdProvider) Functions

func (p *CoderdProvider) Functions(ctx context.Context) []func() function.Function

func (*CoderdProvider) Metadata

func (*CoderdProvider) Resources

func (p *CoderdProvider) Resources(ctx context.Context) []func() resource.Resource

func (*CoderdProvider) Schema

type CoderdProviderData

type CoderdProviderData struct {
	Client                *codersdk.Client
	DefaultOrganizationID uuid.UUID
	Features              map[codersdk.FeatureName]codersdk.Feature
}

type CoderdProviderModel

type CoderdProviderModel struct {
	URL   types.String `tfsdk:"url"`
	Token types.String `tfsdk:"token"`

	DefaultOrganizationID UUID `tfsdk:"default_organization_id"`
}

CoderdProviderModel describes the provider data model.

type GroupDataSource

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

GroupDataSource defines the data source implementation.

func (*GroupDataSource) Configure

func (*GroupDataSource) Metadata

func (*GroupDataSource) Read

func (*GroupDataSource) Schema

type GroupDataSourceModel

type GroupDataSourceModel struct {
	// ID or name and organization ID must be set
	ID             UUID         `tfsdk:"id"`
	Name           types.String `tfsdk:"name"`
	OrganizationID UUID         `tfsdk:"organization_id"`

	DisplayName    types.String `tfsdk:"display_name"`
	AvatarURL      types.String `tfsdk:"avatar_url"`
	QuotaAllowance types.Int32  `tfsdk:"quota_allowance"`
	Source         types.String `tfsdk:"source"`
	Members        []Member     `tfsdk:"members"`
}

GroupDataSourceModel describes the data source data model.

type GroupResource

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

GroupResource defines the resource implementation.

func (*GroupResource) Configure

func (*GroupResource) Create

func (*GroupResource) Delete

func (*GroupResource) ImportState

func (*GroupResource) Metadata

func (*GroupResource) Read

func (*GroupResource) Schema

func (*GroupResource) Update

type GroupResourceModel

type GroupResourceModel struct {
	ID UUID `tfsdk:"id"`

	Name           types.String `tfsdk:"name"`
	DisplayName    types.String `tfsdk:"display_name"`
	AvatarURL      types.String `tfsdk:"avatar_url"`
	QuotaAllowance types.Int32  `tfsdk:"quota_allowance"`
	OrganizationID UUID         `tfsdk:"organization_id"`
	Members        types.Set    `tfsdk:"members"`
}

GroupResourceModel describes the resource data model.

type LastVersionsByHash

type LastVersionsByHash = map[string][]PreviousTemplateVersion

type LicenseResource added in v0.0.5

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

LicenseResource defines the resource implementation.

func (*LicenseResource) Configure added in v0.0.5

func (*LicenseResource) Create added in v0.0.5

func (*LicenseResource) Delete added in v0.0.5

func (*LicenseResource) Metadata added in v0.0.5

func (*LicenseResource) Read added in v0.0.5

func (*LicenseResource) Schema added in v0.0.5

func (*LicenseResource) Update added in v0.0.5

type LicenseResourceModel added in v0.0.5

type LicenseResourceModel struct {
	ID        types.Int32  `tfsdk:"id"`
	ExpiresAt types.Int64  `tfsdk:"expires_at"`
	License   types.String `tfsdk:"license"`
}

LicenseResourceModel describes the resource data model.

type Member

type Member struct {
	ID              UUID         `tfsdk:"id"`
	Username        types.String `tfsdk:"username"`
	Email           types.String `tfsdk:"email"`
	CreatedAt       types.Int64  `tfsdk:"created_at"`
	LastSeenAt      types.Int64  `tfsdk:"last_seen_at"`
	Status          types.String `tfsdk:"status"`
	LoginType       types.String `tfsdk:"login_type"`
	ThemePreference types.String `tfsdk:"theme_preference"`
}

type OrganizationDataSource

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

OrganizationDataSource defines the data source implementation.

func (*OrganizationDataSource) ConfigValidators

func (*OrganizationDataSource) Configure

func (*OrganizationDataSource) Metadata

func (*OrganizationDataSource) Read

func (*OrganizationDataSource) Schema

type OrganizationDataSourceModel

type OrganizationDataSourceModel struct {
	// Exactly one of ID, IsDefault, or Name must be set.
	ID        UUID         `tfsdk:"id"`
	IsDefault types.Bool   `tfsdk:"is_default"`
	Name      types.String `tfsdk:"name"`

	CreatedAt types.Int64 `tfsdk:"created_at"`
	UpdatedAt types.Int64 `tfsdk:"updated_at"`
	// TODO: This could reasonably store some User object - though we may need to make additional queries depending on what fields we
	// want, or to have one consistent user type for all data sources.
	Members types.Set `tfsdk:"members"`
}

OrganizationDataSourceModel describes the data source data model.

type Permission

type Permission struct {
	// Purposefully left as a string so we can later support an `everyone` shortcut
	// identifier for the Everyone group.
	ID   types.String `tfsdk:"id"`
	Role types.String `tfsdk:"role"`
}

type PreviousTemplateVersion

type PreviousTemplateVersion struct {
	ID     uuid.UUID         `json:"id"`
	Name   string            `json:"name"`
	TFVars map[string]string `json:"tf_vars"`
}

type TemplateDataSource

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

TemplateDataSource defines the data source implementation.

func (*TemplateDataSource) Configure

func (*TemplateDataSource) Metadata

func (*TemplateDataSource) Read

func (*TemplateDataSource) Schema

type TemplateDataSourceModel

type TemplateDataSourceModel struct {
	// ((Organization and Name) or ID) must be set
	OrganizationID UUID         `tfsdk:"organization_id"`
	ID             UUID         `tfsdk:"id"`
	Name           types.String `tfsdk:"name"`

	DisplayName types.String `tfsdk:"display_name"`
	// TODO: Provisioner
	Description        types.String `tfsdk:"description"`
	ActiveVersionID    UUID         `tfsdk:"active_version_id"`
	ActiveUserCount    types.Int64  `tfsdk:"active_user_count"`
	Deprecated         types.Bool   `tfsdk:"deprecated"`
	DeprecationMessage types.String `tfsdk:"deprecation_message"`
	Icon               types.String `tfsdk:"icon"`

	DefaultTTLMillis             types.Int64  `tfsdk:"default_ttl_ms"`
	ActivityBumpMillis           types.Int64  `tfsdk:"activity_bump_ms"`
	AutostopRequirement          types.Object `tfsdk:"auto_stop_requirement"`
	AutostartPermittedDaysOfWeek types.Set    `tfsdk:"auto_start_permitted_days_of_week"`

	AllowUserAutostart           types.Bool `tfsdk:"allow_user_autostart"`
	AllowUserAutostop            types.Bool `tfsdk:"allow_user_autostop"`
	AllowUserCancelWorkspaceJobs types.Bool `tfsdk:"allow_user_cancel_workspace_jobs"`

	FailureTTLMillis               types.Int64 `tfsdk:"failure_ttl_ms"`
	TimeTilDormantMillis           types.Int64 `tfsdk:"time_til_dormant_ms"`
	TimeTilDormantAutoDeleteMillis types.Int64 `tfsdk:"time_til_dormant_autodelete_ms"`

	RequireActiveVersion types.Bool   `tfsdk:"require_active_version"`
	MaxPortShareLevel    types.String `tfsdk:"max_port_share_level"`

	CreatedByUserID UUID        `tfsdk:"created_by_user_id"`
	CreatedAt       types.Int64 `tfsdk:"created_at"` // Unix timestamp
	UpdatedAt       types.Int64 `tfsdk:"updated_at"` // Unix timestamp

	ACL types.Object `tfsdk:"acl"`
}

TemplateDataSourceModel describes the data source data model.

type TemplateResource

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

TemplateResource defines the resource implementation.

func (*TemplateResource) ConfigValidators

func (r *TemplateResource) ConfigValidators(context.Context) []resource.ConfigValidator

ConfigValidators implements resource.ResourceWithConfigValidators.

func (*TemplateResource) Configure

func (*TemplateResource) Create

func (*TemplateResource) Delete

func (*TemplateResource) ImportState

func (*TemplateResource) Metadata

func (*TemplateResource) Read

func (*TemplateResource) Schema

func (*TemplateResource) Update

type TemplateResourceModel

type TemplateResourceModel struct {
	ID UUID `tfsdk:"id"`

	Name                           types.String `tfsdk:"name"`
	DisplayName                    types.String `tfsdk:"display_name"`
	Description                    types.String `tfsdk:"description"`
	OrganizationID                 UUID         `tfsdk:"organization_id"`
	Icon                           types.String `tfsdk:"icon"`
	DefaultTTLMillis               types.Int64  `tfsdk:"default_ttl_ms"`
	ActivityBumpMillis             types.Int64  `tfsdk:"activity_bump_ms"`
	AutostopRequirement            types.Object `tfsdk:"auto_stop_requirement"`
	AutostartPermittedDaysOfWeek   types.Set    `tfsdk:"auto_start_permitted_days_of_week"`
	AllowUserCancelWorkspaceJobs   types.Bool   `tfsdk:"allow_user_cancel_workspace_jobs"`
	AllowUserAutostart             types.Bool   `tfsdk:"allow_user_auto_start"`
	AllowUserAutostop              types.Bool   `tfsdk:"allow_user_auto_stop"`
	FailureTTLMillis               types.Int64  `tfsdk:"failure_ttl_ms"`
	TimeTilDormantMillis           types.Int64  `tfsdk:"time_til_dormant_ms"`
	TimeTilDormantAutoDeleteMillis types.Int64  `tfsdk:"time_til_dormant_autodelete_ms"`
	RequireActiveVersion           types.Bool   `tfsdk:"require_active_version"`
	DeprecationMessage             types.String `tfsdk:"deprecation_message"`
	MaxPortShareLevel              types.String `tfsdk:"max_port_share_level"`

	// If null, we are not managing ACL via Terraform (such as for AGPL).
	ACL      types.Object `tfsdk:"acl"`
	Versions Versions     `tfsdk:"versions"`
}

TemplateResourceModel describes the resource data model.

func (*TemplateResourceModel) CheckEntitlements

func (m *TemplateResourceModel) CheckEntitlements(ctx context.Context, features map[codersdk.FeatureName]codersdk.Feature) (diags diag.Diagnostics)

func (*TemplateResourceModel) EqualTemplateMetadata

func (m *TemplateResourceModel) EqualTemplateMetadata(other *TemplateResourceModel) bool

EqualTemplateMetadata returns true if two templates have identical metadata (excluding ACL).

type TemplateVersion

type TemplateVersion struct {
	ID                 UUID         `tfsdk:"id"`
	Name               types.String `tfsdk:"name"`
	Message            types.String `tfsdk:"message"`
	Directory          types.String `tfsdk:"directory"`
	DirectoryHash      types.String `tfsdk:"directory_hash"`
	Active             types.Bool   `tfsdk:"active"`
	TerraformVariables []Variable   `tfsdk:"tf_vars"`
	ProvisionerTags    []Variable   `tfsdk:"provisioner_tags"`
}

type UUID

type UUID struct {
	// The framework requires custom types extend a primitive or object.
	basetypes.StringValue
	// contains filtered or unexported fields
}

func NewUUIDNull

func NewUUIDNull() UUID

func NewUUIDUnknown

func NewUUIDUnknown() UUID

func UUIDValue

func UUIDValue(value uuid.UUID) UUID

func (UUID) Equal

func (v UUID) Equal(o attr.Value) bool

Equal implements basetypes.StringValuable.

func (UUID) Type

func (v UUID) Type(context.Context) attr.Type

Type implements basetypes.StringValuable.

func (UUID) ValidateAttribute

func (v UUID) ValidateAttribute(ctx context.Context, req xattr.ValidateAttributeRequest, resp *xattr.ValidateAttributeResponse)

ValidateAttribute implements xattr.ValidateableAttribute.

func (UUID) ValueUUID

func (v UUID) ValueUUID() uuid.UUID

ValueUUID returns the UUID value. If the value is null or unknown, returns the Nil UUID.

type UserDataSource

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

UserDataSource defines the data source implementation.

func (*UserDataSource) ConfigValidators

func (d *UserDataSource) ConfigValidators(context.Context) []datasource.ConfigValidator

func (*UserDataSource) Configure

func (*UserDataSource) Metadata

func (*UserDataSource) Read

func (*UserDataSource) Schema

type UserDataSourceModel

type UserDataSourceModel struct {
	// Username or ID must be set
	ID       UUID         `tfsdk:"id"`
	Username types.String `tfsdk:"username"`

	Name            types.String `tfsdk:"name"`
	Email           types.String `tfsdk:"email"`
	Roles           types.Set    `tfsdk:"roles"`      // owner, template-admin, user-admin, auditor (member is implicit)
	LoginType       types.String `tfsdk:"login_type"` // none, password, github, oidc
	Suspended       types.Bool   `tfsdk:"suspended"`
	AvatarURL       types.String `tfsdk:"avatar_url"`
	OrganizationIDs types.Set    `tfsdk:"organization_ids"`
	CreatedAt       types.Int64  `tfsdk:"created_at"` // Unix timestamp
	LastSeenAt      types.Int64  `tfsdk:"last_seen_at"`
	ThemePreference types.String `tfsdk:"theme_preference"`
}

UserDataSourceModel describes the data source data model.

type UserResource

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

UserResource defines the resource implementation.

func (*UserResource) Configure

func (*UserResource) Create

func (*UserResource) Delete

func (*UserResource) ImportState

Req.ID can be either a UUID or a username.

func (*UserResource) Metadata

func (*UserResource) Read

func (*UserResource) Schema

func (*UserResource) Update

type UserResourceModel

type UserResourceModel struct {
	ID UUID `tfsdk:"id"`

	Username  types.String `tfsdk:"username"`
	Name      types.String `tfsdk:"name"`
	Email     types.String `tfsdk:"email"`
	Roles     types.Set    `tfsdk:"roles"`      // owner, template-admin, user-admin, auditor (member is implicit)
	LoginType types.String `tfsdk:"login_type"` // none, password, github, oidc
	Password  types.String `tfsdk:"password"`   // only when login_type is password
	Suspended types.Bool   `tfsdk:"suspended"`
}

UserResourceModel describes the resource data model.

type Variable

type Variable struct {
	Name  types.String `tfsdk:"name"`
	Value types.String `tfsdk:"value"`
}

type Versions

type Versions []TemplateVersion

func (Versions) ByID

func (v Versions) ByID(id UUID) *TemplateVersion

type WorkspaceProxyResource

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

WorkspaceProxyResource defines the resource implementation.

func (*WorkspaceProxyResource) Configure

func (*WorkspaceProxyResource) Create

func (*WorkspaceProxyResource) Delete

func (*WorkspaceProxyResource) Metadata

func (*WorkspaceProxyResource) Read

func (*WorkspaceProxyResource) Schema

func (*WorkspaceProxyResource) Update

type WorkspaceProxyResourceModel

type WorkspaceProxyResourceModel struct {
	ID           UUID         `tfsdk:"id"`
	Name         types.String `tfsdk:"name"`
	DisplayName  types.String `tfsdk:"display_name"`
	Icon         types.String `tfsdk:"icon"`
	SessionToken types.String `tfsdk:"session_token"`
}

WorkspaceProxyResourceModel describes the resource data model.

Jump to

Keyboard shortcuts

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