variable

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: BSD-3-Clause Imports: 33 Imported by: 0

Documentation

Overview

Package variable owns global variables, environment materialization, and routes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMaterializedVariables

func RegisterMaterializedVariables(api huma.API, variableService *VariableService, environmentService *environment.EnvironmentService)

RegisterMaterializedVariables registers the plaintext synchronization channel on agents. It must never be registered on a manager API because its response intentionally contains decrypted values for .env.global.

func RegisterVariables

func RegisterVariables(api huma.API, variableService *VariableService, environmentService *environment.EnvironmentService)

Types

type CreateGlobalVariableInput

type CreateGlobalVariableInput struct {
	Body env.CreateGlobalVariableRequest
}

type CreateGlobalVariableOutput

type CreateGlobalVariableOutput struct {
	Body base.ApiResponse[env.GlobalVariableMutationResponse]
}

type DeleteGlobalVariableInput

type DeleteGlobalVariableInput struct {
	ID string `path:"id" doc:"Variable ID"`
}

type DeleteGlobalVariableOutput

type DeleteGlobalVariableOutput struct {
	Body base.ApiResponse[env.GlobalVariableMutationResponse]
}

type GetGlobalVariableSyncStatusInput

type GetGlobalVariableSyncStatusInput struct{}

type GetGlobalVariableSyncStatusOutput

type GetGlobalVariableSyncStatusOutput struct {
	Body base.ApiResponse[[]env.EnvironmentSyncStatus]
}

type GetGlobalVariablesInput

type GetGlobalVariablesInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
}

type GetGlobalVariablesOutput

type GetGlobalVariablesOutput struct {
	Body base.ApiResponse[[]env.Variable]
}

type GlobalVariable added in v2.8.1

type GlobalVariable struct {
	database.BaseModel

	Key      string `json:"key" gorm:"column:key" sortable:"true"`
	Value    string `json:"-" gorm:"column:value"`
	IsSecret bool   `json:"isSecret" gorm:"column:is_secret"`
	// No gorm default tag: a default:true tag would make GORM omit false on
	// insert and the column default would silently win.
	AllEnvironments bool                      `json:"allEnvironments" gorm:"column:all_environments"`
	Environments    []environment.Environment `json:"-" gorm:"many2many:global_variable_environments;joinForeignKey:GlobalVariableID;joinReferences:EnvironmentID"`
}

GlobalVariable is a manager-level key/value variable materialized into each environment's .env.global file. Value holds ciphertext when IsSecret is true.

func (GlobalVariable) TableName added in v2.8.1

func (GlobalVariable) TableName() string

type ListGlobalVariablesInput

type ListGlobalVariablesInput struct{}

type ListGlobalVariablesOutput

type ListGlobalVariablesOutput struct {
	Body base.ApiResponse[[]env.GlobalVariable]
}

type Module

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

func New

func New(service *VariableService, environmentService *environment.EnvironmentService) *Module

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api huma.API, cfg *config.Config)

func (*Module) Service

func (m *Module) Service() *VariableService

type SyncGlobalVariablesInput

type SyncGlobalVariablesInput struct{}

type SyncGlobalVariablesOutput

type SyncGlobalVariablesOutput struct {
	Body base.ApiResponse[[]env.EnvironmentSyncStatus]
}

type UpdateGlobalVariableInput

type UpdateGlobalVariableInput struct {
	ID   string `path:"id" doc:"Variable ID"`
	Body env.UpdateGlobalVariableRequest
}

type UpdateGlobalVariableOutput

type UpdateGlobalVariableOutput struct {
	Body base.ApiResponse[env.GlobalVariableMutationResponse]
}

type UpdateGlobalVariablesInput

type UpdateGlobalVariablesInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	Body          env.Summary
}

type UpdateGlobalVariablesOutput

type UpdateGlobalVariablesOutput struct {
	Body base.ApiResponse[base.MessageResponse]
}

type VariableHandler

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

VariableHandler handles manager-level global variables and the separate agent-only materialization channel used to push effective values.

func (*VariableHandler) CreateVariable

func (*VariableHandler) DeleteVariable

func (*VariableHandler) GetMaterializedVariables

func (h *VariableHandler) GetMaterializedVariables(ctx context.Context, input *GetGlobalVariablesInput) (*GetGlobalVariablesOutput, error)

GetMaterializedVariables returns the environment's materialized .env.global content (local file for environment "0", proxied to the agent otherwise).

func (*VariableHandler) ListVariables

func (*VariableHandler) SyncVariables

func (*VariableHandler) UpdateMaterializedVariables

func (h *VariableHandler) UpdateMaterializedVariables(ctx context.Context, input *UpdateGlobalVariablesInput) (*UpdateGlobalVariablesOutput, error)

UpdateMaterializedVariables replaces the environment's materialized .env.global content (local file for environment "0", proxied otherwise).

func (*VariableHandler) UpdateVariable

type VariableService

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

VariableService manages manager-level global variables (DB source of truth) and materializes each environment's effective set into that environment's .env.global file: locally via template.TemplateService, remotely via the existing agent variables endpoint.

func NewVariableService

func NewVariableService(db *database.DB, environmentService *environment.EnvironmentService, settingsService *settings.SettingsService, kvService *kv.KVService) *VariableService

func (*VariableService) CreateVariable

func (*VariableService) DeleteVariable

func (s *VariableService) DeleteVariable(ctx context.Context, id string) error

func (*VariableService) ImportLegacyLocalEnvFile

func (s *VariableService) ImportLegacyLocalEnvFile(ctx context.Context) error

ImportLegacyLocalEnvFile imports the manager's existing .env.global entries as all-environment readable variables before the first materialization overwrites the file. Runs once, guarded by a KV flag.

func (*VariableService) ListVariables

func (s *VariableService) ListVariables(ctx context.Context) ([]env.GlobalVariable, error)

func (*VariableService) ReadLocalEnvFile

func (s *VariableService) ReadLocalEnvFile(ctx context.Context) ([]env.Variable, error)

func (*VariableService) SyncAll

SyncAll pushes the effective variable set to the local environment and every enabled remote environment in parallel, waiting for all of them. Failures are recorded per environment and never abort the other pushes.

func (*VariableService) SyncAllBackground

func (s *VariableService) SyncAllBackground(ctx context.Context) []env.EnvironmentSyncStatus

SyncAllBackground materializes the local environment synchronously (a fast file write, no network) and pushes to remote environments in the background, so mutation requests never block on slow or unreachable agents. Remotes are reported as "pending" until the background push records their result.

func (*VariableService) SyncEnvironment

func (s *VariableService) SyncEnvironment(ctx context.Context, envID string) error

SyncEnvironment materializes the effective variable set into one environment's .env.global. Remote environments are imported once before the first overwrite so pre-existing per-env variables are preserved.

func (*VariableService) SyncStatuses

func (s *VariableService) SyncStatuses() []env.EnvironmentSyncStatus

func (*VariableService) UpdateVariable

func (*VariableService) WriteLocalEnvFile

func (s *VariableService) WriteLocalEnvFile(ctx context.Context, vars []env.Variable) error

Jump to

Keyboard shortcuts

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