Documentation
¶
Overview ¶
Package provider runs the provider plugins that manage the services declared with a provider, and speaks the JSON message protocol they use to publish variables and endpoints, and to ask Compose for the service configuration, the relay information or an image.
Index ¶
Constants ¶
View Source
const ( ErrorType = "error" InfoType = "info" SetEnvType = "setenv" RawSetEnvType = "rawsetenv" DebugType = "debug" PublishEndpointType = "publish-endpoint" // GetServiceConfigType is a message the provider sends to receive, on // its stdin, one JSON line holding the resolved canonical configuration // of the service it manages — answered from the in-memory model. GetServiceConfigType = "get-service-config" // GetRelayInfoType is a message the provider sends to receive, on its // stdin, one JSON line describing the project networks the relay // standing in for this service would join, with each network's gateway // address. Only meaningful for a provider running its service LOCALLY: // the gateway is an address the host owns on the network's bridge, so // an endpoint bound to it is reachable from the relay without being // exposed on the LAN. A provider backing the service with a remote // resource has no use for it. GetRelayInfoType = "get-relay-info" // GetImageType is a message the provider sends during its pull command // to receive the service image from the local daemon: compose answers on // the provider's stdin with one ImageStreamType JSON line, then — unless // that line carries an error — the image tar encoded as an HTTP/1.1 // chunked body (see streamImageTo). GetImageType = "get-image" // ImageStreamType is the type of the JSON line answering a get-image // request. ImageStreamType = "image-stream" // ComposeProviderMessagesEnv announces to the provider process, as a // comma-separated list, every message type this compose accepts on the // provider's stdout — so a provider can adapt to the compose it runs // under instead of emitting a message that would fail the command // (an unknown message type is a protocol error by design: a provider // REQUIRING an unsupported message must fail rather than degrade // silently). ComposeProviderMessagesEnv = "COMPOSE_PROVIDER_MESSAGES" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
// The Docker client, the event bus and the Docker Desktop detection, which
// serve the relay deployed for providers that publish endpoints.
relay.Backend
// CLI is the Docker CLI, which finds the plugin binary.
CLI() command.Cli
// PrepareShellOut sets the environment of a command Compose runs, from the project's.
PrepareShellOut(ctx context.Context, env types.Mapping, cmd *exec.Cmd) error
// DryRun tells that the Docker API client is a dry-run one, which cannot intercept the provider processes.
DryRun() bool
// ProjectLock guards the project model, which every concurrent provider run mutates.
ProjectLock() sync.Locker
}
Backend is what running a provider plugin needs from the engine.
type CommandMetadata ¶
type CommandMetadata struct {
Parameters []ParameterMetadata `json:"parameters"`
}
func (CommandMetadata) CheckRequiredParameters ¶
func (c CommandMetadata) CheckRequiredParameters(provider types.ServiceProviderConfig) error
func (CommandMetadata) GetParameter ¶
func (c CommandMetadata) GetParameter(paramName string) (ParameterMetadata, bool)
type JsonMessage ¶
type ParameterMetadata ¶
type ProviderMetadata ¶
type ProviderMetadata struct {
Description string `json:"description"`
Up CommandMetadata `json:"up"`
Down CommandMetadata `json:"down"`
Stop *CommandMetadata `json:"stop,omitempty"`
// Pull declares support for the image-distribution command; like Stop,
// the presence of the block is what opts the provider in.
Pull *CommandMetadata `json:"pull,omitempty"`
}
func (ProviderMetadata) IsEmpty ¶
func (p ProviderMetadata) IsEmpty() bool
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs provider plugins on a Backend.
func (*Service) Run ¶
func (s *Service) Run(ctx context.Context, project *types.Project, service types.ServiceConfig, command string, extraArgs ...string) error
Run runs the provider plugin of a service for one command (up, down, stop or pull): it executes the plugin, serves the messages it sends, and applies the variables and endpoints it publishes to the services depending on it.
Click to show internal directories.
Click to hide internal directories.