nomad

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package nomad provides a HashiCorp Nomad infrastructure provider for ctrlplane. It maps ctrlplane instances to Nomad jobs.

Index

Constants

This section is empty.

Variables

View Source
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

type Option func(*Provider) error

Option configures a Nomad provider.

func WithAddress

func WithAddress(addr string) Option

WithAddress sets the Nomad API endpoint.

func WithConfig

func WithConfig(cfg Config) Option

WithConfig applies all non-zero fields from a Config struct. This is useful when loading configuration from files or environment variables.

func WithNamespace

func WithNamespace(ns string) Option

WithNamespace sets the Nomad namespace for job submissions.

func WithRegion

func WithRegion(region string) Option

WithRegion sets the Nomad region to target.

func WithToken

func WithToken(token string) Option

WithToken sets the Nomad ACL token for authentication.

type Provider

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

Provider is a HashiCorp Nomad infrastructure provider.

func New

func New(opts ...Option) (*Provider, error)

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

Deploy pushes a new release to the instance.

func (*Provider) Deprovision

func (p *Provider) Deprovision(_ context.Context, _ id.ID) error

Deprovision tears down all resources for an instance.

func (*Provider) Exec

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

Logs streams logs for the instance.

func (*Provider) Provision

Provision creates infrastructure resources for an instance.

func (*Provider) Resources

func (p *Provider) Resources(_ context.Context, _ id.ID) (*provider.ResourceUsage, error)

Resources returns current resource utilization for an instance.

func (*Provider) Restart

func (p *Provider) Restart(_ context.Context, _ id.ID) error

Restart performs a stop followed by start cycle.

func (*Provider) Rollback

func (p *Provider) Rollback(_ context.Context, _ id.ID, _ id.ID) error

Rollback reverts to a previous release.

func (*Provider) Scale

func (p *Provider) Scale(_ context.Context, _ id.ID, _ provider.ResourceSpec) error

Scale adjusts the resource allocation for an instance.

func (*Provider) Start

func (p *Provider) Start(_ context.Context, _ id.ID) error

Start starts a stopped instance.

func (*Provider) Status

func (p *Provider) Status(_ context.Context, _ id.ID) (*provider.InstanceStatus, error)

Status returns the current runtime status of an instance.

func (*Provider) Stop

func (p *Provider) Stop(_ context.Context, _ id.ID) error

Stop gracefully stops a running instance.

Jump to

Keyboard shortcuts

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