env

package
v0.6.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package env provides utilities for parsing and manipulating .env files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountLines

func CountLines(content string) int

CountLines counts non-empty, non-comment lines in env content.

func DeriveEnvFromFile

func DeriveEnvFromFile(file string) string

DeriveEnvFromFile derives the environment name from a filename. Examples:

  • ".env" -> "development"
  • ".env.production" -> "production"
  • ".env.staging" -> "staging"

func Merge

func Merge(vaultContent string, local, vault map[string]string) string

Merge merges vault content with local-only secrets. Returns the merged content with local-only secrets appended.

func Parse

func Parse(content string) map[string]string

Parse parses env file content and returns a map of key-value pairs. It handles comments, empty lines, and quoted values.

Types

type Candidate

type Candidate struct {
	File string
	Env  string
}

Candidate represents a discovered .env file with its derived environment.

func Discover

func Discover() []Candidate

Discover finds .env files in the current directory. It excludes template files like .env.example, .env.sample, etc.

type PullDiff

type PullDiff struct {
	Added     []string // in vault, not in local
	Changed   []string // in both, different values
	LocalOnly []string // in local, not in vault
	Unchanged []string // in both, same values
}

PullDiff represents the difference between local and vault secrets for a pull operation.

func CalculatePullDiff

func CalculatePullDiff(local, vault map[string]string) *PullDiff

CalculatePullDiff calculates the differences between local and vault secrets for pulling.

func (*PullDiff) HasChanges

func (d *PullDiff) HasChanges() bool

HasChanges returns true if there are any differences.

type PushDiff

type PushDiff struct {
	Added   []string // in local, not in vault (will be created)
	Changed []string // in both, different values (will be updated)
	Removed []string // in vault, not in local (will be deleted)
}

PushDiff represents the difference between local and vault secrets for a push operation.

func CalculatePushDiff

func CalculatePushDiff(local, vault map[string]string) *PushDiff

CalculatePushDiff calculates the differences between local and vault secrets for pushing.

func (*PushDiff) HasChanges

func (d *PushDiff) HasChanges() bool

HasChanges returns true if there are any differences.

Jump to

Keyboard shortcuts

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