Documentation
¶
Overview ¶
Package nomad provides a HashiCorp Nomad infrastructure provider for ctrlplane. It maps ctrlplane instances to Nomad jobs.
Index ¶
- Variables
- type Config
- type Option
- type Provider
- func (p *Provider) Capabilities() []provider.Capability
- func (p *Provider) Deploy(_ context.Context, req provider.DeployRequest) (*provider.DeployResult, error)
- func (p *Provider) Deprovision(_ context.Context, _ id.ID) error
- func (p *Provider) Exec(_ context.Context, _ id.ID, _ provider.ExecRequest) (*provider.ExecResult, error)
- func (p *Provider) Info() provider.ProviderInfo
- func (p *Provider) Logs(_ context.Context, _ id.ID, _ provider.LogOptions) (io.ReadCloser, error)
- func (p *Provider) Provision(_ context.Context, req provider.ProvisionRequest) (*provider.ProvisionResult, error)
- func (p *Provider) Resources(_ context.Context, _ id.ID) (*provider.ResourceUsage, error)
- func (p *Provider) Restart(_ context.Context, _ id.ID) error
- func (p *Provider) Rollback(_ context.Context, _ id.ID, _ id.ID) error
- func (p *Provider) Scale(_ context.Context, _ id.ID, _ provider.ResourceSpec) error
- func (p *Provider) Start(_ context.Context, _ id.ID) error
- func (p *Provider) Status(_ context.Context, _ id.ID) (*provider.InstanceStatus, error)
- func (p *Provider) Stop(_ context.Context, _ id.ID) error
Constants ¶
This section is empty.
Variables ¶
var ErrLogsNotImplemented = errors.New("nomad: logs not implemented")
ErrLogsNotImplemented is returned when log streaming is not yet available.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Address is the Nomad API endpoint.
Address string `default:"http://localhost:4646" env:"CP_NOMAD_ADDRESS" json:"address,omitempty"`
// Token is the Nomad ACL token for authentication.
Token string `env:"CP_NOMAD_TOKEN" json:"-"`
// Region is the Nomad region to target.
Region string `default:"global" env:"CP_NOMAD_REGION" json:"region"`
// Namespace is the Nomad namespace for job submissions.
Namespace string `default:"default" env:"CP_NOMAD_NAMESPACE" json:"namespace"`
}
Config holds configuration for the Nomad provider.
type Option ¶
Option configures a Nomad provider.
func WithConfig ¶
WithConfig applies all non-zero fields from a Config struct. This is useful when loading configuration from files or environment variables.
func WithNamespace ¶
WithNamespace sets the Nomad namespace for job submissions.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider is a HashiCorp Nomad infrastructure provider.
func New ¶
New creates a new Nomad provider with the given options. Without any options, sane defaults are used (address: localhost:4646, region: global, namespace: default).
func (*Provider) Capabilities ¶
func (p *Provider) Capabilities() []provider.Capability
Capabilities returns the set of features this provider supports.
func (*Provider) Deploy ¶
func (p *Provider) Deploy(_ context.Context, req provider.DeployRequest) (*provider.DeployResult, error)
Deploy pushes a new release to the instance.
func (*Provider) Deprovision ¶
Deprovision tears down all resources for an instance.
func (*Provider) Exec ¶
func (p *Provider) Exec(_ context.Context, _ id.ID, _ provider.ExecRequest) (*provider.ExecResult, error)
Exec runs a command inside the instance.
func (*Provider) Info ¶
func (p *Provider) Info() provider.ProviderInfo
Info returns metadata about this provider.
func (*Provider) Logs ¶
func (p *Provider) Logs(_ context.Context, _ id.ID, _ provider.LogOptions) (io.ReadCloser, error)
Logs streams logs for the instance.
func (*Provider) Provision ¶
func (p *Provider) Provision(_ context.Context, req provider.ProvisionRequest) (*provider.ProvisionResult, error)
Provision creates infrastructure resources for an instance.