Documentation
¶
Overview ¶
Package variable owns global variables, environment materialization, and routes.
Index ¶
- func RegisterMaterializedVariables(api huma.API, variableService *VariableService, ...)
- func RegisterVariables(api huma.API, variableService *VariableService, ...)
- type CreateGlobalVariableInput
- type CreateGlobalVariableOutput
- type DeleteGlobalVariableInput
- type DeleteGlobalVariableOutput
- type GetGlobalVariableSyncStatusInput
- type GetGlobalVariableSyncStatusOutput
- type GetGlobalVariablesInput
- type GetGlobalVariablesOutput
- type ListGlobalVariablesInput
- type ListGlobalVariablesOutput
- type Module
- type SyncGlobalVariablesInput
- type SyncGlobalVariablesOutput
- type UpdateGlobalVariableInput
- type UpdateGlobalVariableOutput
- type UpdateGlobalVariablesInput
- type UpdateGlobalVariablesOutput
- type VariableHandler
- func (h *VariableHandler) CreateVariable(ctx context.Context, input *CreateGlobalVariableInput) (*CreateGlobalVariableOutput, error)
- func (h *VariableHandler) DeleteVariable(ctx context.Context, input *DeleteGlobalVariableInput) (*DeleteGlobalVariableOutput, error)
- func (h *VariableHandler) GetMaterializedVariables(ctx context.Context, input *GetGlobalVariablesInput) (*GetGlobalVariablesOutput, error)
- func (h *VariableHandler) GetSyncStatus(_ context.Context, _ *GetGlobalVariableSyncStatusInput) (*GetGlobalVariableSyncStatusOutput, error)
- func (h *VariableHandler) ListVariables(ctx context.Context, _ *ListGlobalVariablesInput) (*ListGlobalVariablesOutput, error)
- func (h *VariableHandler) SyncVariables(ctx context.Context, _ *SyncGlobalVariablesInput) (*SyncGlobalVariablesOutput, error)
- func (h *VariableHandler) UpdateMaterializedVariables(ctx context.Context, input *UpdateGlobalVariablesInput) (*UpdateGlobalVariablesOutput, error)
- func (h *VariableHandler) UpdateVariable(ctx context.Context, input *UpdateGlobalVariableInput) (*UpdateGlobalVariableOutput, error)
- type VariableService
- func (s *VariableService) CreateVariable(ctx context.Context, req env.CreateGlobalVariableRequest) (*env.GlobalVariable, error)
- func (s *VariableService) DeleteVariable(ctx context.Context, id string) error
- func (s *VariableService) ImportLegacyLocalEnvFile(ctx context.Context) error
- func (s *VariableService) ListVariables(ctx context.Context) ([]env.GlobalVariable, error)
- func (s *VariableService) ReadLocalEnvFile(ctx context.Context) ([]env.Variable, error)
- func (s *VariableService) SyncAll(ctx context.Context) []env.EnvironmentSyncStatus
- func (s *VariableService) SyncAllBackground(ctx context.Context) []env.EnvironmentSyncStatus
- func (s *VariableService) SyncEnvironment(ctx context.Context, envID string) error
- func (s *VariableService) SyncStatuses() []env.EnvironmentSyncStatus
- func (s *VariableService) UpdateVariable(ctx context.Context, id string, req env.UpdateGlobalVariableRequest) (*env.GlobalVariable, error)
- func (s *VariableService) WriteLocalEnvFile(ctx context.Context, vars []env.Variable) error
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 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) 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 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 (h *VariableHandler) CreateVariable(ctx context.Context, input *CreateGlobalVariableInput) (*CreateGlobalVariableOutput, error)
func (*VariableHandler) DeleteVariable ¶
func (h *VariableHandler) DeleteVariable(ctx context.Context, input *DeleteGlobalVariableInput) (*DeleteGlobalVariableOutput, error)
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) GetSyncStatus ¶
func (h *VariableHandler) GetSyncStatus(_ context.Context, _ *GetGlobalVariableSyncStatusInput) (*GetGlobalVariableSyncStatusOutput, error)
func (*VariableHandler) ListVariables ¶
func (h *VariableHandler) ListVariables(ctx context.Context, _ *ListGlobalVariablesInput) (*ListGlobalVariablesOutput, error)
func (*VariableHandler) SyncVariables ¶
func (h *VariableHandler) SyncVariables(ctx context.Context, _ *SyncGlobalVariablesInput) (*SyncGlobalVariablesOutput, error)
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 ¶
func (h *VariableHandler) UpdateVariable(ctx context.Context, input *UpdateGlobalVariableInput) (*UpdateGlobalVariableOutput, error)
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 (s *VariableService) CreateVariable(ctx context.Context, req env.CreateGlobalVariableRequest) (*env.GlobalVariable, error)
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 (*VariableService) SyncAll ¶
func (s *VariableService) SyncAll(ctx context.Context) []env.EnvironmentSyncStatus
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 (s *VariableService) UpdateVariable(ctx context.Context, id string, req env.UpdateGlobalVariableRequest) (*env.GlobalVariable, error)