variables

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package variables keeps global and per-stack variables (#35, ADR-0049). They are encrypted in the database and passed to `nerdctl compose` as environment variables, so compose files interpolate them as ${NAME} and they take precedence over the stack's .env file. Secret values are never returned by the API.

Index

Constants

View Source
const Global = ""

Global is the scope of variables shared by all stacks.

View Source
const (
	// MaxValue is the largest value in bytes.
	MaxValue = 64 << 10
)

Variables

This section is empty.

Functions

func ValidateName

func ValidateName(name string) error

ValidateName checks a variable name.

Types

type Input

type Input struct {
	Value  *string `json:"value"`
	Secret bool    `json:"secret"`
}

Input changes a variable. A nil Value keeps the stored one; it is required for a new variable and to make a secret visible.

type Service

type Service struct {
	Store Store
	Box   *secretbox.Box
	// contains filtered or unexported fields
}

Service manages variables.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, stack, name string) error

Delete removes a variable.

func (*Service) DeleteStack

func (s *Service) DeleteStack(ctx context.Context, stack string) error

DeleteStack removes the variables of a stack that nerdui forgets, so a later stack of the same name does not get them.

func (*Service) List

func (s *Service) List(ctx context.Context, stack string) ([]Variable, error)

List returns the variables of a scope (Global or a stack name) without secret values.

func (*Service) Put

func (s *Service) Put(ctx context.Context, stack, name string, in Input, user string) (Variable, error)

Put creates or changes a variable.

func (*Service) Values

func (s *Service) Values(ctx context.Context, stack string) (map[string]string, error)

Values returns the variables of a stack as NAME=value: the global ones, overridden by the stack's own.

type Store

type Store interface {
	ListVariables(ctx context.Context, stack string) ([]db.Variable, error)
	GetVariable(ctx context.Context, arg db.GetVariableParams) (db.Variable, error)
	PutVariable(ctx context.Context, arg db.PutVariableParams) error
	DeleteVariable(ctx context.Context, arg db.DeleteVariableParams) (int64, error)
	DeleteStackVariables(ctx context.Context, stack string) error
}

Store is the database; *db.Queries implements it.

type Variable

type Variable struct {
	Name string `json:"name"`
	// Value is empty for secrets.
	Value     string    `json:"value"`
	Secret    bool      `json:"secret"`
	UpdatedBy string    `json:"updatedBy,omitempty"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Variable as the API shows it. Keep in sync with api/openapi.yaml.

Jump to

Keyboard shortcuts

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