envbuilder

package
v0.2.50-beta.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultDotenvFile added in v0.2.4

func DefaultDotenvFile() string

func Discover

func Discover(root string, maxDepth int) ([]string, error)

func DotenvFromPrompts added in v0.2.4

func DotenvFromPrompts(prompts []UserPrompt) string

func DotenvFromPromptsMerged added in v0.2.25

func DotenvFromPromptsMerged(prompts []UserPrompt, contents string) string

Types

type Chunk added in v0.2.25

type Chunk struct {
	Prompt      UserPrompt
	PromptIndex int
	Lines       string
	LineIndex   int
}

type DotenvChunks added in v0.2.25

type DotenvChunks []Chunk

func (DotenvChunks) Sort added in v0.2.25

func (ch DotenvChunks) Sort() DotenvChunks

Sort sorts by chunk position in dotenv file

func (DotenvChunks) String added in v0.2.25

func (ch DotenvChunks) String() string

type EnvironmentValidationError added in v0.2.3

type EnvironmentValidationError struct {
	Results []ValidationResult
}

EnvironmentValidationError contains the results of validating environment configuration.

func ValidateEnvironment added in v0.2.3

func ValidateEnvironment(repoRoot string, variables Variables) EnvironmentValidationError

ValidateEnvironment validates that all required environment variables are set according to UserPrompts and core DataRobot requirements. It checks both the provided envValues map (which should contain .env file values) and environment variables (which override .env values).

The validation process: 1. Determines which sections are active based on requires dependencies 2. Validates all required UserPrompts in active sections 3. Validates core DataRobot variables (DATAROBOT_ENDPOINT, DATAROBOT_API_TOKEN)

func (EnvironmentValidationError) Error added in v0.2.3

Error implements the error interface for EnvironmentValidationError.

func (EnvironmentValidationError) HasErrors added in v0.2.3

func (r EnvironmentValidationError) HasErrors() bool

HasErrors returns true if there are any validation errors.

type MissingPromptLineIndex added in v0.2.25

type MissingPromptLineIndex struct {
	LineIndex int
}

type MissingPrompts added in v0.2.25

type MissingPrompts map[string]MissingPromptLineIndex

type ParsedYaml

type ParsedYaml map[string][]UserPrompt

type PromptInstance added in v0.2.28

type PromptInstance struct {
	Prompt      UserPrompt
	PromptIndex int
	HelpLines   []string
}

type PromptInstances added in v0.2.28

type PromptInstances map[string]PromptInstance

type PromptOption

type PromptOption struct {
	Blank    bool
	Checked  bool
	Name     string `yaml:"name"`
	Value    string `yaml:"value,omitempty"`
	Requires string `yaml:"requires,omitempty"`
}

type PromptType added in v0.2.3

type PromptType string
const (
	PromptTypeString PromptType = "string"
	PromptTypeSecret PromptType = "secret_string"
)

func (PromptType) String added in v0.2.3

func (pt PromptType) String() string

type UserPrompt

type UserPrompt struct {
	Section string
	Root    bool
	// Active indicates if this prompt should be processed (based on conditional logic).
	Active bool
	// Commented indicates if the variable should be commented out in the .env file. This
	// can be used for variables that the user may want to set but are not required.
	Commented bool
	// Value is the current value for this prompt (from .env, environment, or user input).
	Value string
	// Hidden indicates if this prompt should never be shown to users (e.g., core variables).
	Hidden bool

	// Env is the environment variable name to set (e.g., "DATABASE_URL").
	Env string `yaml:"env"`
	// Key is an alternative identifier when Env is not set (written as comment).
	Key string `yaml:"key"`
	// Type is the prompt type: "string" (default) or "secret_string" (masked input).
	Type PromptType `yaml:"type"`
	// Multiple allows selecting multiple options (checkbox-style) when Options is set.
	Multiple bool `yaml:"multiple"`
	// Options provides a list of choices for selection-style prompts.
	Options []PromptOption `yaml:"options,omitempty"`
	// Default is the initial value for this prompt. Prompts with defaults are
	// skipped during the wizard unless the value differs or AlwaysPrompt is set.
	Default string `yaml:"default,omitempty"`
	// Help is the description text shown to users when prompting for input.
	Help string `yaml:"help"`
	// Optional allows the prompt to be skipped without providing a value.
	Optional bool `yaml:"optional,omitempty"`
	// Generate auto-generates a cryptographic random value for secret_string types.
	Generate bool `yaml:"generate,omitempty"`
	// AlwaysPrompt forces the prompt to be shown even when a default value is set.
	// Use this for prompts where users should consciously confirm or change the default.
	// This does not affect prompts with options that have "requires" fields -
	// those prompts are always shown regardless of defaults. This also does not
	// affect prompts that are required due to conditional logic, or hidden prompts.
	AlwaysPrompt bool `yaml:"always_prompt,omitempty"`
}

UserPrompt represents a configuration prompt that can be displayed to users during the dotenv setup wizard. Prompts are defined in YAML files within the .datarobot directory of a given template.

func DetermineRequiredSections added in v0.2.3

func DetermineRequiredSections(userPrompts []UserPrompt) []UserPrompt

DetermineRequiredSections calculates which sections are required based on the requires dependencies in selected options.

func GatherUserPrompts

func GatherUserPrompts(rootDir string, variables Variables) ([]UserPrompt, error)

func (UserPrompt) HasEnvValue added in v0.2.3

func (up UserPrompt) HasEnvValue() bool

HasEnvValue returns true if prompt has effective value when written to .env file

func (UserPrompt) HasRequiresOptions added in v0.2.47

func (up UserPrompt) HasRequiresOptions() bool

HasRequiresOptions returns true if any option has a requires field set.

func (UserPrompt) HelpLines added in v0.2.25

func (up UserPrompt) HelpLines() []string

func (UserPrompt) ShouldAsk added in v0.2.4

func (up UserPrompt) ShouldAsk(showAll bool) bool

ShouldAsk returns true if this prompt should be shown to the user. Prompts with defaults are skipped unless AlwaysPrompt is set, showAll is true, or the prompt has options with requires (which control conditional sections).

func (UserPrompt) SkipSaving added in v0.2.3

func (up UserPrompt) SkipSaving() bool

func (UserPrompt) String added in v0.2.3

func (up UserPrompt) String() string

It will render as:

# The path to the VertexAI application credentials JSON file.
VERTEXAI_APPLICATION_CREDENTIALS=whatever-user-entered

func (UserPrompt) StringWithoutHelp added in v0.2.3

func (up UserPrompt) StringWithoutHelp() string

func (UserPrompt) Valid added in v0.2.3

func (up UserPrompt) Valid() bool

func (UserPrompt) VarName added in v0.2.3

func (up UserPrompt) VarName() string

type ValidationResult added in v0.2.3

type ValidationResult struct {
	Field   string // The environment variable name or key
	Value   string // The actual value (empty if not set)
	Valid   bool   // Whether the variable is valid
	Message string // Error message if invalid, or success message if valid
	Help    string // Optional help text describing the variable
}

ValidationResult represents the validation status of a single variable.

type Variable added in v0.2.3

type Variable struct {
	Name        string
	Value       string
	Description string
	Secret      bool
	Commented   bool
}

Variable represents a parsed environment variable from a .env file or template.

func NewFromLine added in v0.2.3

func NewFromLine(line string, unquotedValues map[string]string) Variable

func ParseVariablesOnly added in v0.2.3

func ParseVariablesOnly(dotenvLines []string) []Variable

ParseVariablesOnly parses variables from lines without attempting to auto-populate them. This is used when parsing .env files to extract variable names and values. Commented lines (starting with #) are marked as such.

func VariablesFromLines added in v0.2.4

func VariablesFromLines(lines []string) ([]Variable, string)

func (*Variable) String added in v0.2.3

func (v *Variable) String() string

func (*Variable) StringSecret added in v0.2.13

func (v *Variable) StringSecret() string

type Variables added in v0.2.3

type Variables []Variable

Jump to

Keyboard shortcuts

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