userstr

package
v0.60.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_TOTAL_LEN = 128 // maximum allowed length for the entire userstr

Variables

View Source
var (
	ErrTooLong           = errors.New("identifier too long")
	ErrB64UserStrInvalid = errors.New("base64 userstr invalid")
	ErrUserStrMalformed  = errors.New("userstr malformed")
	ErrUserStrInvalid    = errors.New("userstr invalid")
)

Functions

This section is empty.

Types

type BlueprintKind

type BlueprintKind int

BlueprintKind represents the kind of blueprint used for a workspace.

const (
	BlueprintKindImplicit BlueprintKind = iota // no explicit blueprint
	BlueprintKindExplicit                      // user-defined blueprint in userstr
	BlueprintKindCustom                        // user-defined blueprint name from repo
)

func (BlueprintKind) String

func (k BlueprintKind) String() string

type CanonicalUserStr

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

func (*CanonicalUserStr) Aliases

func (c *CanonicalUserStr) Aliases() []string

func (*CanonicalUserStr) CanonicalId

func (c *CanonicalUserStr) CanonicalId() string

CanonicalId returns a unique identifier for the workspace based on the username and canonical key

func (*CanonicalUserStr) CanonicalKey

func (c *CanonicalUserStr) CanonicalKey() string

func (*CanonicalUserStr) CanonicalUserStr

func (c *CanonicalUserStr) CanonicalUserStr() string

func (*CanonicalUserStr) CanonicalUserStrObj

func (c *CanonicalUserStr) CanonicalUserStrObj() *UserStr

func (*CanonicalUserStr) Identity

func (c *CanonicalUserStr) Identity() WorkspaceIdentity

Getters for CanonicalUserStr

func (*CanonicalUserStr) WorkspaceName

func (c *CanonicalUserStr) WorkspaceName() string

type UserStr

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

UserStr is the parsed user string object.

func ParseUserStr

func ParseUserStr(input string) (*UserStr, error)

func ParseUserStrWithGrammar

func ParseUserStrWithGrammar(input string, grammar UserStrGrammar) (*UserStr, error)

func (*UserStr) Blueprint

func (u *UserStr) Blueprint() string

func (*UserStr) BlueprintKind

func (u *UserStr) BlueprintKind() BlueprintKind

func (*UserStr) Canonicalize

func (u *UserStr) Canonicalize() (*CanonicalUserStr, error)

func (*UserStr) Form

func (u *UserStr) Form() UserStrForm

func (*UserStr) Namespace

func (u *UserStr) Namespace(defaultValue string) string

func (*UserStr) ParamsRaw

func (u *UserStr) ParamsRaw() map[string]string

func (*UserStr) Pod

func (u *UserStr) Pod() string

func (*UserStr) Raw

func (u *UserStr) Raw() string

Getters for UserStr

func (*UserStr) RepoName

func (u *UserStr) RepoName() string

func (*UserStr) RepoOwner

func (u *UserStr) RepoOwner() string

func (*UserStr) RepoRef

func (u *UserStr) RepoRef() string

func (*UserStr) User

func (u *UserStr) User() string

func (*UserStr) Username

func (u *UserStr) Username() string

func (*UserStr) WorkloadKind

func (u *UserStr) WorkloadKind() string

func (*UserStr) WorkloadName

func (u *UserStr) WorkloadName() string

type UserStrFields

type UserStrFields struct {
	Username     string `json:"username"`
	Blueprint    string `json:"blueprint,omitempty"`
	WorkloadKind string `json:"workloadKind,omitempty"`
	WorkloadName string `json:"workloadName,omitempty"`
	Pod          string `json:"pod,omitempty"`
	Namespace    string `json:"namespace,omitempty"`
	RepoOwner    string `json:"repoOwner,omitempty"`
	RepoName     string `json:"repoName,omitempty"`
	RepoRef      string `json:"repoRef,omitempty"`
}

UserStrFields is a JSON-friendly representation.

func UserStrFieldsFromUserStr

func UserStrFieldsFromUserStr(u *UserStr) UserStrFields

UserStrFieldsFromUserStr creates a payload from a parsed *UserStr. Note: Blueprint will be populated from u.Blueprint() (even for repo-derived blueprints).

func (UserStrFields) ToRawUserStr

func (f UserStrFields) ToRawUserStr() (string, error)

ToRawUserStr returns the serialized userstr that would be parsed.

func (UserStrFields) ToUserStr

func (f UserStrFields) ToUserStr() (*UserStr, error)

ToUserStr builds a userstr from the fields and parses it (single source of validation truth).

type UserStrForm

type UserStrForm int

UserStrForm describes the semantic shape of a parsed user string.

const (
	UserStrFormImplicit UserStrForm = iota
	UserStrFormExplicitBlueprint
	UserStrFormNamedWorkspace
	UserStrFormRepoWorkspace
)

type UserStrGrammar

type UserStrGrammar struct {
	MaxTotalLen int
	Params      map[string]UserStrParamSpec
}

func DefaultGrammar

func DefaultGrammar() UserStrGrammar

type UserStrParamSpec

type UserStrParamSpec struct {
	AllowedIn map[UserStrForm]bool
}

type WorkspaceIdentity

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

WorkspaceIdentity is the canonical identity model.

func (*WorkspaceIdentity) Blueprint

func (w *WorkspaceIdentity) Blueprint() string

func (*WorkspaceIdentity) BlueprintKind

func (w *WorkspaceIdentity) BlueprintKind() BlueprintKind

func (*WorkspaceIdentity) Namespace

func (w *WorkspaceIdentity) Namespace() string

func (*WorkspaceIdentity) RepoName

func (w *WorkspaceIdentity) RepoName() string

func (*WorkspaceIdentity) RepoOwner

func (w *WorkspaceIdentity) RepoOwner() string

func (*WorkspaceIdentity) RepoRef

func (w *WorkspaceIdentity) RepoRef() string

func (*WorkspaceIdentity) Username

func (w *WorkspaceIdentity) Username() string

Getters for WorkspaceIdentity

func (*WorkspaceIdentity) WorkloadKind

func (w *WorkspaceIdentity) WorkloadKind() string

func (*WorkspaceIdentity) WorkloadName

func (w *WorkspaceIdentity) WorkloadName() string

Jump to

Keyboard shortcuts

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