substrate

package
v0.6.76 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 12 Imported by: 0

Documentation

Overview

Package substrate is a thin client for the Agent Substrate control API (substrate.ateapi.v1.Control), used by the DevboxRunner controller and the devbox gateway.

The protobuf bindings in ./ateapi are vendored from go.ate.dev/substrate@v1.0.0 (see `make substrate-proto`) rather than imported, since that module forces k8s.io/* v0.37 and otel upgrades on the operator module. Both register the proto package substrate.ateapi.v1, so never link go.ate.dev/substrate/api/ateapi/v1 into the same binary as this package.

Index

Constants

View Source
const (
	// DefaultAddress is the in-cluster ate-api-server address.
	DefaultAddress = "api.ate-system.svc:443"
	// TokenAudience is the audience of the projected ServiceAccount token ate-api-server accepts.
	TokenAudience = "api.ate-system.svc"
	// PreviewHeader opts a request into Substrate preview features such as GoldenEgressPolicy.
	PreviewHeader = "Ate-Preview-Allowed"

	RoleOwner  = "owner"
	RoleEditor = "editor"
	RoleViewer = "viewer"
)

Variables

This section is empty.

Functions

func IsAlreadyExists

func IsAlreadyExists(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func MergeBinding

func MergeBinding(policy *ateapi.AccessPolicy, role string, members ...string) bool

MergeBinding adds the members to the role's binding, returning whether the policy changed.

Types

type API

type API interface {
	EnsureAtespace(ctx context.Context, name string) error
	DeleteAtespace(ctx context.Context, name string) error
	// EnsureAtespaceAccessPolicy makes sure every member holds the given role, keeping existing bindings.
	EnsureAtespaceAccessPolicy(ctx context.Context, atespace, role string, members ...string) error

	CreateActorTemplate(ctx context.Context, template *ateapi.ActorTemplate, preview bool) (*ateapi.ActorTemplate, error)
	GetActorTemplate(ctx context.Context, atespace, name string) (*ateapi.ActorTemplate, error)
	ListActorTemplates(ctx context.Context, atespace string) ([]*ateapi.ActorTemplate, error)
	DeleteActorTemplate(ctx context.Context, atespace, name string) error

	ListActors(ctx context.Context, atespace string) ([]*ateapi.Actor, error)
	DeleteActor(ctx context.Context, atespace, name string) error

	ListTags(ctx context.Context, atespace string) ([]*ateapi.Tag, error)
	DeleteTag(ctx context.Context, atespace, name string) error

	ListWorkers(ctx context.Context) ([]*ateapi.Worker, error)
	// DrainWorker stops new actors being placed on the worker. Draining is one-way, and actors already bound
	// to the worker stay.
	DrainWorker(ctx context.Context, name string) (*ateapi.Worker, error)
}

API is the subset of the Control service the devbox components use. Every method is idempotent: creates return the existing object on AlreadyExists, deletes treat NotFound as success.

type Client

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

func Dial

func Dial(cfg Config) (*Client, error)

func DialWith

func DialWith(address, serverName string, roots *x509.CertPool, creds credentials.PerRPCCredentials) (*Client, error)

DialWith connects to ate-api-server at address (DefaultAddress when empty), verifying it against roots and authenticating every call with creds. serverName defaults to the host of address.

func NewFromConn

func NewFromConn(conn *grpc.ClientConn) *Client

func (*Client) Close

func (c *Client) Close() error

func (*Client) CreateActorTemplate

func (c *Client) CreateActorTemplate(ctx context.Context, template *ateapi.ActorTemplate, preview bool) (*ateapi.ActorTemplate, error)

func (*Client) DeleteActor

func (c *Client) DeleteActor(ctx context.Context, atespace, name string) error

func (*Client) DeleteActorTemplate

func (c *Client) DeleteActorTemplate(ctx context.Context, atespace, name string) error

func (*Client) DeleteAtespace

func (c *Client) DeleteAtespace(ctx context.Context, name string) error

func (*Client) DeleteTag

func (c *Client) DeleteTag(ctx context.Context, atespace, name string) error

func (*Client) DrainWorker

func (c *Client) DrainWorker(ctx context.Context, name string) (*ateapi.Worker, error)

func (*Client) EnsureAtespace

func (c *Client) EnsureAtespace(ctx context.Context, name string) error

func (*Client) EnsureAtespaceAccessPolicy

func (c *Client) EnsureAtespaceAccessPolicy(ctx context.Context, atespace, role string, members ...string) error

func (*Client) GetActorTemplate

func (c *Client) GetActorTemplate(ctx context.Context, atespace, name string) (*ateapi.ActorTemplate, error)

func (*Client) ListActorTemplates

func (c *Client) ListActorTemplates(ctx context.Context, atespace string) ([]*ateapi.ActorTemplate, error)

func (*Client) ListActors

func (c *Client) ListActors(ctx context.Context, atespace string) ([]*ateapi.Actor, error)

func (*Client) ListTags

func (c *Client) ListTags(ctx context.Context, atespace string) ([]*ateapi.Tag, error)

func (*Client) ListWorkers

func (c *Client) ListWorkers(ctx context.Context) ([]*ateapi.Worker, error)

type Config

type Config struct {
	// Address of ate-api-server, defaults to DefaultAddress.
	Address string
	// TokenFile is a projected ServiceAccount token with audience TokenAudience. It is re-read on every call,
	// so kubelet rotation is picked up.
	TokenFile string
	// CAFile is the trust bundle of the servicedns.podcert.ate.dev signer.
	CAFile string
	// ServerName overrides the TLS server name, defaults to the host of Address.
	ServerName string
}

Config locates ate-api-server and the credentials used to reach it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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