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
- func IsAlreadyExists(err error) bool
- func IsNotFound(err error) bool
- func MergeBinding(policy *ateapi.AccessPolicy, role string, members ...string) bool
- type API
- type Client
- func (c *Client) Close() error
- func (c *Client) CreateActorTemplate(ctx context.Context, template *ateapi.ActorTemplate, preview bool) (*ateapi.ActorTemplate, error)
- func (c *Client) DeleteActor(ctx context.Context, atespace, name string) error
- func (c *Client) DeleteActorTemplate(ctx context.Context, atespace, name string) error
- func (c *Client) DeleteAtespace(ctx context.Context, name string) error
- func (c *Client) DeleteTag(ctx context.Context, atespace, name string) error
- func (c *Client) DrainWorker(ctx context.Context, name string) (*ateapi.Worker, error)
- func (c *Client) EnsureAtespace(ctx context.Context, name string) error
- func (c *Client) EnsureAtespaceAccessPolicy(ctx context.Context, atespace, role string, members ...string) error
- func (c *Client) GetActorTemplate(ctx context.Context, atespace, name string) (*ateapi.ActorTemplate, error)
- func (c *Client) ListActorTemplates(ctx context.Context, atespace string) ([]*ateapi.ActorTemplate, error)
- func (c *Client) ListActors(ctx context.Context, atespace string) ([]*ateapi.Actor, error)
- func (c *Client) ListTags(ctx context.Context, atespace string) ([]*ateapi.Tag, error)
- func (c *Client) ListWorkers(ctx context.Context) ([]*ateapi.Worker, error)
- type Config
Constants ¶
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 IsNotFound ¶
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 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) CreateActorTemplate ¶
func (c *Client) CreateActorTemplate(ctx context.Context, template *ateapi.ActorTemplate, preview bool) (*ateapi.ActorTemplate, error)
func (*Client) DeleteActor ¶
func (*Client) DeleteActorTemplate ¶
func (*Client) DeleteAtespace ¶
func (*Client) DrainWorker ¶
func (*Client) EnsureAtespace ¶
func (*Client) EnsureAtespaceAccessPolicy ¶
func (*Client) GetActorTemplate ¶
func (*Client) ListActorTemplates ¶
func (*Client) ListActors ¶
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.