Documentation
¶
Index ¶
- Variables
- func NormalizeConfigBySchema(schema ConfigSchema, raw map[string]any) map[string]any
- func ValidateConfigBySchema(schema ConfigSchema, raw map[string]any) error
- type ActionType
- type AttachmentRequest
- type AttachmentStatus
- type BindingResolver
- type BotActionRequest
- type BotOverlayConfig
- type BotStatus
- type ConfigConstraint
- type ConfigField
- type ConfigSchema
- type Controller
- type FieldType
- type NetworkJoinTarget
- type NodeListResponse
- type NodeOption
- type NoopOverlayDriver
- func (NoopOverlayDriver) Detach(context.Context, AttachmentRequest) error
- func (NoopOverlayDriver) EnsureAttached(context.Context, AttachmentRequest) (OverlayStatus, error)
- func (NoopOverlayDriver) Kind() string
- func (NoopOverlayDriver) Status(context.Context, AttachmentRequest) (OverlayStatus, error)
- type OverlayDriver
- type OverlayState
- type OverlayStatus
- type Provider
- type ProviderAction
- type ProviderActionExecution
- type ProviderActionStatus
- type ProviderCapabilities
- type ProviderDescriptor
- type ProviderStatus
- type Registry
- func (r *Registry) Get(kind string) (Provider, bool)
- func (r *Registry) GetCapabilities(kind string) (ProviderCapabilities, bool)
- func (r *Registry) GetDescriptor(kind string) (ProviderDescriptor, bool)
- func (r *Registry) List() []Provider
- func (r *Registry) ListDescriptors() []ProviderDescriptor
- func (r *Registry) MustRegister(provider Provider)
- func (r *Registry) Register(provider Provider) error
- type Runtime
- type RuntimeCapabilities
- type RuntimeDescriptor
- type RuntimeNetworkRequest
- type RuntimeNetworkStatus
- type Service
- func (s *Service) ExecuteActionBot(ctx context.Context, botID, actionID string, input map[string]any) (ProviderActionExecution, error)
- func (s *Service) GetBotConfig(ctx context.Context, botID string) (BotOverlayConfig, error)
- func (s *Service) ListBotNodes(ctx context.Context, botID string) (NodeListResponse, error)
- func (s *Service) ListMeta(_ context.Context) []ProviderDescriptor
- func (s *Service) PrepareBotConfigForWrite(cfg BotOverlayConfig) (BotOverlayConfig, error)
- func (s *Service) ReconcileBot(ctx context.Context, botID string, previous, next BotOverlayConfig) error
- func (s *Service) Resolve(ctx context.Context, botID string) (BotOverlayConfig, error)
- func (s *Service) SetController(ctrl Controller)
- func (s *Service) StatusBot(ctx context.Context, botID string) (BotStatus, error)
- type WorkspaceRuntimeStatus
Constants ¶
This section is empty.
Variables ¶
var ( // ErrProviderNotConfigured means the bot has no network provider selected. ErrProviderNotConfigured = errors.New("network provider is not configured") // ErrUnsupportedAction means the provider does not offer the requested action. ErrUnsupportedAction = errors.New("unsupported network action") )
var ErrNotSupported = errors.New("network operation not supported")
ErrNotSupported indicates the selected runtime or overlay driver cannot report a requested capability yet.
var ErrWorkspaceContainerMissing = errors.New("workspace is not created")
Functions ¶
func NormalizeConfigBySchema ¶
func NormalizeConfigBySchema(schema ConfigSchema, raw map[string]any) map[string]any
func ValidateConfigBySchema ¶
func ValidateConfigBySchema(schema ConfigSchema, raw map[string]any) error
Types ¶
type ActionType ¶
type ActionType string
const ActionTypeTestConnection ActionType = "test_connection"
type AttachmentRequest ¶
type AttachmentRequest struct {
BotID string
ContainerID string
Runtime RuntimeNetworkRequest
Overlay BotOverlayConfig
OverlayOnly bool // When true, skip runtime network setup/teardown (overlay-only mutation).
}
type AttachmentStatus ¶
type AttachmentStatus struct {
Runtime RuntimeNetworkStatus
Overlay OverlayStatus
}
AttachmentStatus reports the outcome of runtime network and overlay attachment.
type BindingResolver ¶
type BindingResolver interface {
Resolve(ctx context.Context, botID string) (BotOverlayConfig, error)
}
type BotActionRequest ¶
type BotOverlayConfig ¶
type BotStatus ¶
type BotStatus struct {
Provider string `json:"provider,omitempty"`
Attached bool `json:"attached" validate:"required"`
State OverlayState `json:"state" validate:"required"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Message string `json:"message,omitempty"`
NetworkIP string `json:"network_ip,omitempty"`
ProxyAddress string `json:"proxy_address,omitempty"`
Details map[string]any `json:"details,omitempty"`
Workspace *WorkspaceRuntimeStatus `json:"workspace,omitempty"`
}
type ConfigConstraint ¶
type ConfigField ¶
type ConfigField struct {
Key string `json:"key" validate:"required"`
Type FieldType `json:"type" validate:"required"`
Required bool `json:"required,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Default any `json:"default,omitempty"`
Example any `json:"example,omitempty"`
Order int `json:"order,omitempty"`
Enum []string `json:"enum,omitempty"`
Multiline bool `json:"multiline,omitempty"`
Readonly bool `json:"readonly,omitempty"`
Secret bool `json:"secret,omitempty"`
Collapsed bool `json:"collapsed,omitempty"`
Constraint *ConfigConstraint `json:"constraint,omitempty"`
}
func (ConfigField) Validate ¶
func (f ConfigField) Validate() error
type ConfigSchema ¶
type ConfigSchema struct {
Version int `json:"version" validate:"required"`
Title string `json:"title,omitempty"`
Fields []ConfigField `json:"fields" validate:"required"`
}
func (ConfigSchema) Validate ¶
func (s ConfigSchema) Validate() error
type Controller ¶
type Controller interface {
EnsureAttached(ctx context.Context, req AttachmentRequest) (AttachmentStatus, error)
Detach(ctx context.Context, req AttachmentRequest) error
Status(ctx context.Context, req AttachmentRequest) (AttachmentStatus, error)
}
Controller coordinates container runtime networking and optional overlay attachment behind a single workspace-facing surface.
func NewController ¶
func NewController(runtime Runtime, resolver BindingResolver, registry *Registry) Controller
NewController creates a controller with runtime networking and optional bot binding resolution for overlay providers.
type NetworkJoinTarget ¶
type NodeListResponse ¶
type NodeListResponse struct {
Provider string `json:"provider,omitempty"`
Items []NodeOption `json:"items,omitempty"`
Message string `json:"message,omitempty"`
}
type NodeOption ¶
type NodeOption struct {
ID string `json:"id" validate:"required"`
Value string `json:"value" validate:"required"`
DisplayName string `json:"display_name" validate:"required"`
Description string `json:"description,omitempty"`
Online bool `json:"online" validate:"required"`
Addresses []string `json:"addresses,omitempty"`
CanExitNode bool `json:"can_exit_node" validate:"required"`
Selected bool `json:"selected" validate:"required"`
Details map[string]any `json:"details,omitempty"`
}
type NoopOverlayDriver ¶
type NoopOverlayDriver struct{}
NoopOverlayDriver is the default overlay driver until a real SD-WAN provider is selected. It preserves current behavior by leaving overlay state untouched.
func (NoopOverlayDriver) Detach ¶
func (NoopOverlayDriver) Detach(context.Context, AttachmentRequest) error
func (NoopOverlayDriver) EnsureAttached ¶
func (NoopOverlayDriver) EnsureAttached(context.Context, AttachmentRequest) (OverlayStatus, error)
func (NoopOverlayDriver) Kind ¶
func (NoopOverlayDriver) Kind() string
func (NoopOverlayDriver) Status ¶
func (NoopOverlayDriver) Status(context.Context, AttachmentRequest) (OverlayStatus, error)
type OverlayDriver ¶
type OverlayDriver interface {
Kind() string
EnsureAttached(ctx context.Context, req AttachmentRequest) (OverlayStatus, error)
Detach(ctx context.Context, req AttachmentRequest) error
Status(ctx context.Context, req AttachmentRequest) (OverlayStatus, error)
}
OverlayDriver is the runtime surface for a concrete configured provider instance bound to a bot.
type OverlayState ¶ added in v1.0.2
type OverlayState string
OverlayState is the state of a bot's network overlay as reported by the status API. The web UI keys its labels on these values.
const ( // OverlayStateReady means the client is logged in, has an address and // reports no connectivity-impacting health warnings. OverlayStateReady OverlayState = "ready" // OverlayStateStarting means the client is up but has not reached a // steady state yet. OverlayStateStarting OverlayState = "starting" // OverlayStateNeedsLogin means the client waits for an interactive login // or for an administrator to approve the node. OverlayStateNeedsLogin OverlayState = "needs_login" // OverlayStateDegraded means the client is connected but reports a // health problem that affects connectivity. OverlayStateDegraded OverlayState = "degraded" // OverlayStateStopped means the sidecar exists but is not running. OverlayStateStopped OverlayState = "stopped" // OverlayStateMissing means no sidecar has been created yet. OverlayStateMissing OverlayState = "missing" // OverlayStateUnsupported means the workspace runtime cannot host the // provider's sidecar. OverlayStateUnsupported OverlayState = "unsupported" // OverlayStateDisabled means bot networking is turned off. OverlayStateDisabled OverlayState = "disabled" // OverlayStateWorkspaceMissing means the bot workspace has not been // created yet. OverlayStateWorkspaceMissing OverlayState = "workspace_missing" // OverlayStateNeedsConfig means the provider configuration is incomplete. OverlayStateNeedsConfig OverlayState = "needs_config" OverlayStateUnauthorized OverlayState = "unauthorized" // OverlayStateUnknown means the state could not be determined. OverlayStateUnknown OverlayState = "unknown" )
type OverlayStatus ¶
type OverlayStatus struct {
Provider string `json:"provider,omitempty"`
Attached bool `json:"attached"`
State OverlayState `json:"state,omitempty"`
Message string `json:"message,omitempty"`
NetworkIP string `json:"network_ip,omitempty"`
ProxyAddress string `json:"proxy_address,omitempty"`
Details map[string]any `json:"details,omitempty"`
}
type Provider ¶
type Provider interface {
Kind() string
Descriptor() ProviderDescriptor
NormalizeConfig(raw map[string]any) (map[string]any, error)
Status(ctx context.Context, cfg BotOverlayConfig) (ProviderStatus, error)
ExecuteAction(ctx context.Context, cfg BotOverlayConfig, actionID string, input map[string]any) (ProviderActionExecution, error)
ListNodes(ctx context.Context, botID string, cfg BotOverlayConfig) ([]NodeOption, error)
BuildDriver(cfg BotOverlayConfig) (OverlayDriver, error)
}
Provider describes a supported network backend family such as Tailscale or NetBird. It is registered globally and later instantiated from stored provider records.
type ProviderAction ¶
type ProviderAction struct {
ID string `json:"id" validate:"required"`
Type ActionType `json:"type" validate:"required"`
Label string `json:"label" validate:"required"`
Description string `json:"description,omitempty"`
Primary bool `json:"primary,omitempty"`
Status *ProviderActionStatus `json:"status,omitempty"`
}
type ProviderActionExecution ¶
type ProviderActionExecution struct {
ActionID string `json:"action_id" validate:"required"`
Status ProviderStatus `json:"status" validate:"required"`
Output map[string]any `json:"output,omitempty"`
}
type ProviderActionStatus ¶
type ProviderCapabilities ¶
type ProviderCapabilities struct {
Mesh bool `json:"mesh" validate:"required"`
PrivateDNS bool `json:"private_dns" validate:"required"`
ServiceProxy bool `json:"service_proxy" validate:"required"`
EgressProxy bool `json:"egress_proxy" validate:"required"`
TransparentProxy bool `json:"transparent_proxy" validate:"required"`
ExitNode bool `json:"exit_node" validate:"required"`
Userspace bool `json:"userspace" validate:"required"`
KernelTUN bool `json:"kernel_tun" validate:"required"`
NativeClient bool `json:"native_client" validate:"required"`
SidecarWorker bool `json:"sidecar_worker" validate:"required"`
}
type ProviderDescriptor ¶
type ProviderDescriptor struct {
Kind string `json:"kind" validate:"required"`
DisplayName string `json:"display_name" validate:"required"`
Description string `json:"description,omitempty"`
ConfigSchema ConfigSchema `json:"config_schema" validate:"required"`
Capabilities ProviderCapabilities `json:"capabilities" validate:"required"`
Actions []ProviderAction `json:"actions,omitempty"`
}
type ProviderStatus ¶
type ProviderStatus struct {
State OverlayState `json:"state" validate:"required"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Details map[string]any `json:"details,omitempty"`
}
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores overlay providers and exposes descriptor/capability queries.
func (*Registry) GetCapabilities ¶
func (r *Registry) GetCapabilities(kind string) (ProviderCapabilities, bool)
GetCapabilities returns the capability matrix for the given provider kind.
func (*Registry) GetDescriptor ¶
func (r *Registry) GetDescriptor(kind string) (ProviderDescriptor, bool)
GetDescriptor returns the read-only descriptor for the given provider kind.
func (*Registry) ListDescriptors ¶
func (r *Registry) ListDescriptors() []ProviderDescriptor
ListDescriptors returns all registered provider descriptors.
func (*Registry) MustRegister ¶
MustRegister calls Register and panics on error.
type Runtime ¶
type Runtime interface {
Kind() string
Descriptor() RuntimeDescriptor
EnsureNetwork(ctx context.Context, req RuntimeNetworkRequest) (RuntimeNetworkStatus, error)
RemoveNetwork(ctx context.Context, req RuntimeNetworkRequest) error
StatusNetwork(ctx context.Context, req RuntimeNetworkRequest) (RuntimeNetworkStatus, error)
}
Runtime is the behavioral surface exposed by a container/runtime adapter to the network controller.
func NewContainerRuntimeFromBackend ¶
NewContainerRuntimeFromBackend wraps the current runtime network service with the network package's runtime abstraction.
type RuntimeCapabilities ¶
type RuntimeCapabilities struct {
SidecarWorker bool `json:"sidecar_worker"`
RuntimeNetworkSetup bool `json:"runtime_network_setup"`
JoinContainerNetwork bool `json:"join_container_network"`
JoinNamespacePath bool `json:"join_namespace_path"`
CNI bool `json:"cni"`
Devices bool `json:"devices"`
Capabilities bool `json:"capabilities"`
Privileged bool `json:"privileged"`
}
RuntimeCapabilities describes how a runtime can host or join networking.
type RuntimeDescriptor ¶
type RuntimeDescriptor struct {
Kind string `json:"kind"`
DisplayName string `json:"display_name"`
Capabilities RuntimeCapabilities `json:"capabilities"`
}
RuntimeDescriptor is the read-only metadata exported by a runtime adapter.
type RuntimeNetworkRequest ¶
type RuntimeNetworkRequest struct {
ContainerID string
JoinTarget NetworkJoinTarget
}
RuntimeNetworkRequest describes the container network attachment target for a runtime adapter.
type RuntimeNetworkStatus ¶
RuntimeNetworkStatus describes the current state of the container runtime network attachment.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) ExecuteActionBot ¶
func (*Service) GetBotConfig ¶
func (*Service) ListBotNodes ¶
func (*Service) PrepareBotConfigForWrite ¶
func (s *Service) PrepareBotConfigForWrite(cfg BotOverlayConfig) (BotOverlayConfig, error)
func (*Service) ReconcileBot ¶
func (s *Service) ReconcileBot(ctx context.Context, botID string, previous, next BotOverlayConfig) error
ReconcileBot moves a bot from its previous network config to the next one. The sidecar is only torn down when the provider changes or networking is turned off; within the same provider the driver recreates the sidecar if its process settings changed and applies the rest through the client API.
func (*Service) SetController ¶
func (s *Service) SetController(ctrl Controller)
SetController injects the network controller after construction to break the Service ↔ Controller circular dependency (Controller depends on Service as its BindingResolver).
type WorkspaceRuntimeStatus ¶
type WorkspaceRuntimeStatus struct {
State string `json:"state" validate:"required"` // workspace_missing | runtime_unavailable | task_stopped | network_target_ready | unknown
ContainerID string `json:"container_id,omitempty"`
TaskStatus string `json:"task_status,omitempty"`
PID uint32 `json:"pid,omitempty"`
NetworkTargetKind string `json:"network_target_kind,omitempty"`
NetworkTarget string `json:"network_target,omitempty"`
NetworkAttached bool `json:"network_attached,omitempty"`
Message string `json:"message,omitempty"`
}
WorkspaceRuntimeStatus describes the bot workspace runtime state (foundation before SD-WAN overlay).