credential

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package credential handles env template parsing and credential resolution.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoopProvider = errors.New("credential provider is not configured")

Functions

func BuildEnv

func BuildEnv(resolved []Resolved, base []string) []string

BuildEnv converts resolved credentials into environment variable assignments.

func NormalizeEnvValue added in v0.3.0

func NormalizeEnvValue(value string) string

NormalizeEnvValue trims surrounding quotes from dotenv-style values so the launched process receives the literal token, not the quote characters.

Types

type Entry

type Entry struct {
	EnvVar   string // e.g., "GITHUB_TOKEN"
	Provider string // e.g., "github"
	Resource string // e.g., "readonly" (optional, after /)
	Raw      string // e.g., "{{kontext:github}}"
}

Entry represents a single credential placeholder from the env template.

func ParseTemplate

func ParseTemplate(path string) ([]Entry, error)

ParseTemplate reads an env template file and extracts credential placeholders.

func (Entry) Target

func (e Entry) Target() string

Target returns the full provider target used for token exchange.

type InvalidPlaceholder added in v0.3.0

type InvalidPlaceholder struct {
	EnvVar string
	Value  string
}

type ManagedProvider added in v0.3.0

type ManagedProvider struct {
	EnvVar         string
	Placeholder    string
	SeedOnFirstRun bool
}

type NoopProvider added in v0.7.0

type NoopProvider struct{}

func (NoopProvider) ResolveCredential added in v0.7.0

func (NoopProvider) ResolveCredential(context.Context, Entry) (Resolved, error)

type Provider added in v0.7.0

type Provider interface {
	ResolveCredential(context.Context, Entry) (Resolved, error)
}

type ProviderFunc added in v0.7.0

type ProviderFunc func(context.Context, Entry) (Resolved, error)

func (ProviderFunc) ResolveCredential added in v0.7.0

func (f ProviderFunc) ResolveCredential(ctx context.Context, entry Entry) (Resolved, error)

type Resolved

type Resolved struct {
	Entry
	Value string // The resolved credential value
}

Resolved is a credential entry with its resolved value.

type SyncResult added in v0.3.0

type SyncResult struct {
	Created          bool
	Updated          bool
	Added            []ManagedProvider
	CollisionSkipped []ManagedProvider
	Template         *TemplateFile
}

func EnsureManagedTemplate added in v0.3.0

func EnsureManagedTemplate(path string, managed []ManagedProvider) (*SyncResult, error)

type TemplateFile added in v0.3.0

type TemplateFile struct {
	Entries              []Entry
	ExistingValues       map[string]string
	InvalidPlaceholders  []InvalidPlaceholder
	SafeToMutate         bool
	MutationWarning      string
	HasManagedPlaceholds bool
}

func LoadTemplateFile added in v0.3.0

func LoadTemplateFile(path string) (*TemplateFile, error)

Jump to

Keyboard shortcuts

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