env

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package env manages per-project environment variables for cloop. Variables are stored in .cloop/env.yaml. Secret values are stored base64-encoded with an "enc:" prefix so they are not in plain text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeValue

func DecodeValue(v Var) string

DecodeValue returns the plain-text value for a Var, decoding "enc:" secrets.

func EnvLines

func EnvLines(vars []Var) []string

EnvLines returns the vars as KEY=value pairs suitable for os/exec Env. Secret values are decoded before being returned.

func Expand

func Expand(vars []Var) map[string]string

Expand returns a key→plain-text-value map, decoding any "enc:" secrets.

func InjectIntoPrompt

func InjectIntoPrompt(prompt string, vars []Var) string

InjectIntoPrompt replaces {{KEY}} placeholders in prompt with the corresponding values from vars. Unknown placeholders are left intact.

func Save

func Save(workDir string, vars []Var) error

Save writes vars to .cloop/env.yaml, encoding Secret values. Secret values that are not already encoded are base64-encoded and stored with the "enc:" prefix.

Types

type Var

type Var struct {
	Key         string `yaml:"key"`
	Value       string `yaml:"value"`
	Description string `yaml:"description,omitempty"`
	Secret      bool   `yaml:"secret,omitempty"`
}

Var is a single environment variable entry.

func Delete

func Delete(vars []Var, key string) ([]Var, bool)

Delete removes the var with the given key from vars and returns the new slice. Returns the slice unchanged and false if the key was not found.

func Get

func Get(vars []Var, key string) (Var, bool)

Get returns the Var for the given key and true if found.

func Load

func Load(workDir string) ([]Var, error)

Load reads .cloop/env.yaml and returns all vars. Returns an empty slice (not an error) if the file does not exist.

func Upsert

func Upsert(vars []Var, v Var) []Var

Upsert adds or replaces the var with v.Key in vars and returns the new slice.

Jump to

Keyboard shortcuts

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