envprof

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package envprof loads and unmarshals environment profile configurations from various file formats. It supports YAML, TOML and JSON formats for defining environment profiles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Template

func Template(data []byte, env env.Env) ([]byte, error)

Template renders a Go text/template using the provided env map. Template usage: {{ .FOO }} or {{ .FOO | default "fallback" }}.

func Unmarshal

func Unmarshal(data []byte, format Type) (profiles profiles.Profiles, err error)

Unmarshal decodes the data into profiles.

Types

type EnvProf

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

EnvProf represents an environment profile file and its loaded content.

func New

func New(file file.File) *EnvProf

New creates a new EnvProf instance from the given file.

func NewFrom

func NewFrom(files files.Files) (*EnvProf, error)

NewFrom creates a new EnvProf instance from the first found among the given files.

func (*EnvProf) File

func (e *EnvProf) File() file.File

File returns the resolved file.

func (*EnvProf) GetOrDefault

func (e *EnvProf) GetOrDefault(name string) (string, error)

GetOrDefault returns the profile name if it exists, or the default profile if none is specified.

func (*EnvProf) Load

func (e *EnvProf) Load() error

Load reads the file and unmarshals it into the store.

func (*EnvProf) Profiles

func (e *EnvProf) Profiles() profiles.Profiles

Profiles returns the loaded profiles.

func (*EnvProf) TryParse

func (e *EnvProf) TryParse(data []byte) error

TryParse attempts to parse the given data into the supported profile formats.

func (*EnvProf) Type

func (e *EnvProf) Type() error

Type determines and sets the file format based on the file extension.

type Type

type Type string

Type represents the type of the profile file.

const (
	// YAML is the YAML file type.
	YAML Type = "yaml"
	// TOML is the TOML file type.
	TOML Type = "toml"
)

Jump to

Keyboard shortcuts

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