Documentation ¶
Index ¶
- Constants
- Variables
- func LoadState() (*hclconfig.Config, error)
- func SaveState(c *hclconfig.Config) error
- func SetupHCLConfig(callback hclconfig.ProcessCallback, variables map[string]string, ...) *hclconfig.Parser
- type Blueprint
- type Build
- type CertificateCA
- type CertificateLeaf
- type Container
- type Copy
- type Docs
- type HealthCheck
- type Helm
- type HelmRepository
- type Image
- type ImageCache
- type Ingress
- type K8sCluster
- type K8sConfig
- type LocalExec
- type Network
- type NetworkAttachment
- type NomadCluster
- type NomadJob
- type Port
- type PortRange
- type RemoteExec
- type Resources
- type Sidecar
- type Template
- type TrafficTarget
- type User
- type Volume
Constants ¶
const ( IngressSourceLocal = "local" IngressSourceK8s = "k8s" IngressSourceDocker = "docker" )
const TypeCertificateCA string = "certificate_ca"
TypeCertificateCA is the resource string for a self-signed CA
const TypeCertificateLeaf string = "certificate_leaf"
TypeCertificateCA is the resource string for a self-signed CA
const TypeContainer string = "container"
TypeContainer is the resource string for a Container resource
const TypeCopy string = "copy"
TypeCopy copies files from one location to another
const TypeDocs string = "docs"
TypeDocs is the resource string for a Docs resource
const TypeHelm string = "helm"
TypeHelm is the string representation of the ResourceType
const TypeImageCache string = "image_cache"
TypeContainer is the resource string for a Container resource
const TypeIngress string = "ingress"
TypeIngress is the resource string for the type
const TypeK8sCluster string = "k8s_cluster"
TypeK8sCluster is the resource string for a Cluster resource
const TypeK8sConfig string = "k8s_config"
TypeK8sConfig defines the string type for the Kubernetes config resource
const TypeLocalExec string = "local_exec"
TypeExecLocal is the resource string for a LocalExec resource
const TypeNetwork string = "network"
TypeNetwork is the string resource type for Network resources
const TypeNomadCluster string = "nomad_cluster"
TypeCluster is the resource string for a Cluster resource
const TypeNomadJob string = "nomad_job"
TypeNomadJob defines the string type for the Kubernetes config resource
const TypeRemoteExec string = "remote_exec"
TypeExecRemote is the resource string for a ExecRemote resource
const TypeSidecar string = "sidecar"
TypeSidecar is the resource string for a Sidecar resource
const TypeTemplate string = "template"
TypeTemplate is the resource string for a Template resource
Variables ¶
var ErrorWANExists = errors.New("a network named 'wan' already exists")
ErrorWANExists is raised when a WAN network already exists
Functions ¶
func SetupHCLConfig ¶
func SetupHCLConfig(callback hclconfig.ProcessCallback, variables map[string]string, variablesFiles []string) *hclconfig.Parser
setupHCLConfig configures the HCLConfig package and registers the custom types
Types ¶
type Blueprint ¶
type Blueprint struct { Title string `hcl:"title,optional" json:"title,omitempty"` Author string `hcl:"author,optional" json:"author,omitempty"` Slug string `hcl:"slug,optional" json:"slug,omitempty"` Intro string `hcl:"intro,optional" json:"intro,omitempty"` BrowserWindows []string `hcl:"browser_windows,optional" json:"browser_windows,omitempty"` HealthCheckTimeout string `hcl:"health_check_timeout,optional" json:"health_check_timeout,omitempty"` Environment map[string]string `hcl:"env,optional" json:"environment,omitempty"` ShipyardVersion string `hcl:"shipyard_version,optional" json:"shipyard_version,omitempty"` }
Blueprint defines a stack blueprint for defining yard configs
type Build ¶
type Build struct { DockerFile string `hcl:"dockerfile,optional" json:"dockerfile,omitempty"` // Location of build file inside build context defaults to ./Dockerfile Context string `hcl:"context" json:"context"` // Path to build context Tag string `hcl:"tag,optional" json:"tag,omitempty"` // Image tag, defaults to latest }
Build allows you to define the conditions for building a container on run from a Dockerfile
type CertificateCA ¶
type CertificateCA struct { types.ResourceMetadata `hcl:",remain"` // Output directory to write the certificate and key too Output string `hcl:"output" json:"output"` // KeyPath is the absolute file path to the key generated by the resource KeyPath string `hcl:"key_path" json:"key_path"` // CertPath is the absolute file path to the certificate generated by the resource CertPath string `hcl:"cert_path" json:"cert_path"` }
CertificateCA allows the generate of CA certificates
func (*CertificateCA) Process ¶
func (c *CertificateCA) Process() error
type CertificateLeaf ¶
type CertificateLeaf struct { types.ResourceMetadata `hcl:",remain"` CAKey string `hcl:"ca_key" json:"ca_key"` // Path to the primary key for the root CA CACert string `hcl:"ca_cert" json:"ca_cert"` // Path to the root CA IPAddresses []string `hcl:"ip_addresses,optional" json:"ip_addresses,omitempty"` // ip addresses to add to the cert DNSNames []string `hcl:"dns_names,optional" json:"dns_names,omitempty"` // DNS names to add to the cert Output string `hcl:"output" json:"output"` // output location for the certificate // KeyPath is the absolute file path to the key generated by the resource KeyPath string `hcl:"key_path" json:"key_path"` // CertPath is the absolute file path to the certificate generated by the resource CertPath string `hcl:"cert_path" json:"cert_path"` }
CertificateCA allows the generate of CA certificates
func (*CertificateLeaf) Process ¶
func (c *CertificateLeaf) Process() error
type Container ¶
type Container struct { // embedded type holding name, etc types.ResourceMetadata `hcl:",remain"` Networks []NetworkAttachment `hcl:"network,block" json:"networks,omitempty"` // Attach to the correct network // only when Image is specified Image *Image `hcl:"image,block" json:"image"` // Image to use for the container Entrypoint []string `hcl:"entrypoint,optional" json:"entrypoint,omitempty"` // entrypoint to use when starting the container Command []string `hcl:"command,optional" json:"command,omitempty"` // command to use when starting the container Environment map[string]string `hcl:"environment,optional" json:"environment,omitempty"` // environment variables to set when starting the container Volumes []Volume `hcl:"volume,block" json:"volumes,omitempty"` // volumes to attach to the container Ports []Port `hcl:"port,block" json:"ports,omitempty"` // ports to expose PortRanges []PortRange `hcl:"port_range,block" json:"port_ranges,omitempty"` // range of ports to expose DNS []string `hcl:"dns,optional" json:"dns,omitempty"` // Add custom DNS servers to the container Privileged bool `hcl:"privileged,optional" json:"privileged,omitempty"` // run the container in privileged mode? MaxRestartCount int `hcl:"max_restart_count,optional" json:"max_restart_count,omitempty"` // resource constraints Resources *Resources `hcl:"resources,block" json:"resources,omitempty"` // resource constraints for the container // health checks for the container HealthCheck *HealthCheck `hcl:"health_check,block" json:"health_check,omitempty"` // User block for mapping the user id and group id inside the container RunAs *User `hcl:"run_as,block" json:"run_as,omitempty"` // Enables containers to be built on the fly Build *Build `hcl:"build,block" json:"build"` // FQRN is the fully qualified domain name for the container, this can be used // to access the container from other sources FQRN string `hcl:"fqrn,optional" json:"fqrn,omitempty"` }
Container defines a structure for creating Docker containers
type Copy ¶
type Copy struct { // embedded type holding name, etc types.ResourceMetadata `hcl:",remain"` Depends []string `hcl:"depends_on,optional" json:"depends,omitempty"` Source string `hcl:"source" json:"source"` // Source file, folder or glob Destination string `hcl:"destination" json:"destination"` // Destination to write file or files to Permissions string `hcl:"permissions,optional" json:"permissions,omitempty"` // Permissions 0777 to set for written file // outputs CopiedFiles []string `hcl:"permissions,optional" json:"copied_files"` }
Docs allows the running of a Docusaurus container which can be used for online tutorials or documentation
type Docs ¶
type Docs struct { types.ResourceMetadata `hcl:",remain"` Networks []NetworkAttachment `hcl:"network,block" json:"networks,omitempty"` // Attach to the correct network // only when Image is specified Image *Image `hcl:"image,block" json:"image,omitempty"` // image to use for the container Path string `hcl:"path" json:"path"` Port int `hcl:"port" json:"port"` OpenInBrowser bool `hcl:"open_in_browser,optional" json:"open_in_browser"` // When a host port is defined open the location in a browser // FQDN is the fully qualified domain name for the container, this can be used // to access the container from other sources FQDN string `hcl:"fqdn,optional" json:"fqdn,omitempty"` }
Docs allows the running of a Docusaurus container which can be used for online tutorials or documentation
type HealthCheck ¶
type HealthCheck struct { Timeout string `hcl:"timeout" json:"timeout"` HTTP string `hcl:"http,optional" json:"http,omitempty"` HTTPSuccessCodes []int `hcl:"http_success_codes,optional" json:"http_success_codes,omitempty"` TCP string `hcl:"tcp,optional" json:"tcp,omitempty"` Services []string `hcl:"services,optional" json:"services,omitempty"` Pods []string `hcl:"pods,optional" json:"pods,omitempty"` NomadJobs []string `hcl:"nomad_jobs,optional" json:"nomad_jobs,omitempty" mapstructure:"nomad_jobs"` }
HealthCheck is an internal block for configuration which allows the user to define the criteria for successful creation example config:
http = "http://consul-consul:8500/v1/leader" // can the http endpoint be reached http_success_codes = [200,429] // https status codes that signal the health of the endpoint tcp = "consul-consul:8500" // can a TCP connection be made services = ["consul-consul"] // does service exist and there are endpoints pods = ["component=server,app=consul", "component=client,app=consul"] // is the pod running and healthy nomad_jobs = ["redis"] // are the Nomad jobs running and healthy
type Helm ¶
type Helm struct { types.ResourceMetadata `hcl:",remain"` Depends []string `hcl:"depends_on,optional" json:"depends,omitempty"` Cluster string `hcl:"cluster" json:"cluster"` // Optional HelmRepository, if specified will try to download the chart from the give repository Repository *HelmRepository `hcl:"repository,block" json:"repository"` // name of the chart within the repository or Go Getter reference to download chart from Chart string `hcl:"chart" json:"chart"` // semver of the chart to install Version string `hcl:"version,optional" json:"version,omitempty"` Values string `hcl:"values,optional" json:"values"` ValuesString map[string]string `hcl:"values_string,optional" json:"values_string"` // Namespace is the Kubernetes namespace Namespace string `hcl:"namespace,optional" json:"namespace,omitempty"` // CreateNamespace when set to true Helm will create the namespace before installing CreateNamespace bool `hcl:"create_namespace,optional" json:"create_namespace,omitempty"` // Skip the install of any CRDs SkipCRDs bool `hcl:"skip_crds,optional" json:"skip_crds,omitempty"` // Retry the install n number of times Retry int `hcl:"retry,optional" json:"retry,omitempty"` // Timeout specifies the maximum time a chart can run, default 300s Timeout string `hcl:"timeout,optional" json:"timeout"` HealthCheck *HealthCheck `hcl:"health_check,block" json:"health_check,omitempty"` }
Helm defines configuration for running Helm charts
type HelmRepository ¶
type Image ¶
type Image struct { Name string `hcl:"name" json:"name"` // Username is the Docker registry user to use for private repositories Username string `hcl:"username,optional" json:"username,omitempty"` // Password is the Docker registry password to use for private repositories Password string `hcl:"password,optional" json:"password,omitempty"` }
Image defines a docker image which will be pushed to the clusters Docker registry
type ImageCache ¶
type ImageCache struct { // embedded type holding name, etc types.ResourceMetadata `hcl:",remain"` Networks []string `json:"networks" state:"true"` // Attach to the correct network // only when Image is specified }
Container defines a structure for creating Docker containers
type Ingress ¶
type Ingress struct { types.ResourceMetadata `hcl:",remain"` // local port to expose the service on Port int `hcl:"port" json:"port"` // details for the destination service Target TrafficTarget `hcl:"target,block" json:"target"` // IngressId stores the ID of the created connector service IngressID string `hcl:"ingress_id,optional" json:"ingress_id,omitempty"` // Address is the fully qualified uri for accessing the resource Address string `hcl:"address,optional" json:"address,omitempty"` }
Ingress defines an ingress service mapping ports between local host and resources like containers and kube cluster
type K8sCluster ¶
type K8sCluster struct { // embedded type holding name, etc. types.ResourceMetadata `hcl:",remain"` Networks []NetworkAttachment `hcl:"network,block" json:"networks,omitempty"` // Attach to the correct network // only when Image is specified Image *Image `hcl:"image,block" json:"images,omitempty"` // optional image to use when creating the cluster Nodes int `hcl:"nodes,optional" json:"nodes,omitempty"` Volumes []Volume `hcl:"volume,block" json:"volumes,omitempty"` // volumes to attach to the cluster // Images that will be copied from the local docker cache to the cluster CopyImages []Image `hcl:"copy_image,block" json:"copy_images,omitempty"` Ports []Port `hcl:"port,block" json:"ports,omitempty"` // ports to expose PortRanges []PortRange `hcl:"port_range,block" json:"port_ranges,omitempty"` // range of ports to expose Environment map[string]string `hcl:"environment,optional" json:"environment,omitempty"` // environment variables to set when starting the container // Path to the Kubernetes config KubeConfig string `hcl:"kubeconfig,optional" json:"kubeconfig,omitempty"` // Port the API server is running on APIPort int `hcl:"api_port,optional" json:"api_port,omitempty"` // Port the connector is running on ConnectorPort int `hcl:"connector_port,optional" json:"connector_port,omitempty"` // Fully qualified domain name for the container, this address can be // used to reference the container within docker and from other containers FQRN string `hcl:"fqrn,optional" json:"fqrn,omitempty"` // ExternalIP is the ip address of the cluster, this generally resolves // to the docker ip ExternalIP string `hcl:"external_ip,optional" json:"external_ip,omitempty"` }
K8sCluster is a config stanza which defines a Kubernetes or a Nomad cluster
func (*K8sCluster) Process ¶
func (k *K8sCluster) Process() error
type K8sConfig ¶
type K8sConfig struct { types.ResourceMetadata `hcl:",remain"` // Cluster is the name of the cluster to apply configuration to Cluster string `hcl:"cluster" json:"cluster"` // Path of a file or directory of Kubernetes config files to apply Paths []string `hcl:"paths" validator:"filepath" json:"paths"` // WaitUntilReady when set to true waits until all resources have been created and are in a "Running" state WaitUntilReady bool `hcl:"wait_until_ready" json:"wait_until_ready"` // HealthCheck defines a health check for the resource HealthCheck *HealthCheck `hcl:"health_check,block" json:"health_check,omitempty"` }
K8sConfig applies and deletes and deletes Kubernetes configuration
type LocalExec ¶
type LocalExec struct { // embedded type holding name, etc types.ResourceMetadata `hcl:",remain"` Command []string `hcl:"command,optional" json:"command,omitempty"` // Command to execute WorkingDirectory string `hcl:"working_directory,optional" json:"working_directory,omitempty"` // Working directory to execute commands Daemon bool `hcl:"daemon,optional" json:"daemon,omitempty"` // Should the process run as a daemon Timeout string `hcl:"timeout,optional" json:"timeout,omitempty"` // Set the timeout for the command Environment map[string]string `hcl:"environment,optional" json:"environment,omitempty"` // environment variables to set // Pid stores the ID of the created connector service Pid int `hcl:"pid,optional" json:"pid,omitempty"` }
ExecLocal allows commands to be executed on the local machine
type Network ¶
type Network struct { // embedded type holding name, etc types.ResourceMetadata `hcl:",remain"` Subnet string `hcl:"subnet" json:"subnet"` }
Network defines a Docker network
type NetworkAttachment ¶
type NetworkAttachment struct { ID string `hcl:"id" json:"id"` IPAddress string `hcl:"ip_address,optional" json:"ip_address,omitempty"` // Optional address to assign Aliases []string `hcl:"aliases,optional" json:"aliases,omitempty"` // Network aliases for the resource // Name will equal the name of the network as created by jumppad Name string `hcl:"name,optional" json:"name,omitempty"` // AssignedAddress will equal if IPAddress is set, else it will be the value automatically // assigned from the network AssignedAddress string `hcl:"assigned_address,optional" json:"assigned_address,omitempty"` }
type NomadCluster ¶
type NomadCluster struct { // embedded type holding name, etc types.ResourceMetadata `hcl:",remain"` Networks []NetworkAttachment `hcl:"network,block" json:"networks,omitempty"` // Attach to the correct network // only when Image is specified Image *Image `hcl:"image,block" json:"images,omitempty"` // optional image to use for the cluster ClientNodes int `hcl:"client_nodes,optional" json:"client_nodes,omitempty"` Environment map[string]string `hcl:"environment,optional" json:"environment,omitempty"` ServerConfig string `hcl:"server_config,optional" json:"server_config,omitempty"` ClientConfig string `hcl:"client_config,optional" json:"client_config,omitempty"` ConsulConfig string `hcl:"consul_config,optional" json:"consul_config,omitempty"` Volumes []Volume `hcl:"volume,block" json:"volumes,omitempty"` // volumes to attach to the cluster OpenInBrowser bool `hcl:"open_in_browser,optional" json:"open_in_browser,omitempty"` // open the UI in the browser after creation // Images that will be copied from the local docker cache to the cluster CopyImages []Image `hcl:"copy_image,block" json:"copy_images,omitempty"` // Additional ports to expose on the nomad sever node Ports []Port `hcl:"port,block" json:"ports,omitempty"` // ports to expose PortRanges []PortRange `hcl:"port_range,block" json:"port_ranges,omitempty"` // range of ports to expose // The APIPort the server is running on APIPort int `hcl:"api_port,optional" json:"api_port,omitempty"` // The Port where the connector is running ConnectorPort int `hcl:"connector_port,optional" json:"connector_port,omitempty"` // The directory where the server and client config is written to ConfigDir string `hcl:"config_dir,optional" json:"config_dir,omitempty"` // The fully qualified docker address for the server ServerFQRN string `hcl:"server_fqrn,optional" json:"server_fqrn,omitempty"` // The fully qualified docker address for the client nodes ClientFQRN []string `hcl:"client_fqrn,optional" json:"client_fqrn,omitempty"` // ExternalIP is the ip address of the cluster, this generally resolves // to the docker ip ExternalIP string `hcl:"external_ip,optional" json:"external_ip,omitempty"` }
Cluster is a config stanza which defines a Kubernetes or a Nomad cluster
func (*NomadCluster) Process ¶
func (n *NomadCluster) Process() error
type NomadJob ¶
type NomadJob struct { // embedded type holding name, etc types.ResourceMetadata `hcl:",remain"` // Cluster is the name of the cluster to apply configuration to Cluster string `hcl:"cluster" json:"cluster"` // Path of a file or directory of Job files to apply Paths []string `hcl:"paths" validator:"filepath" json:"paths"` // HealthCheck defines a health check for the resource HealthCheck *HealthCheck `hcl:"health_check,block" json:"health_check,omitempty"` }
NomadJob applies and deletes and deletes Nomad cluster jobs
type Port ¶
type Port struct { Local string `hcl:"local" json:"local"` // Local port in the container Remote string `hcl:"remote" json:"remote"` // Remote port of the service Host string `hcl:"host,optional" json:"host,omitempty"` // Host port Protocol string `hcl:"protocol,optional" json:"protocol,omitempty"` // Protocol tcp, udp OpenInBrowser string `hcl:"open_in_browser,optional" json:"open_in_browser" mapstructure:"open_in_browser"` // When a host port is defined open this port with the given path in a browser }
Port is a port mapping
type PortRange ¶
type PortRange struct { Range string `hcl:"range" json:"local" mapstructure:"local"` // Local port in the container EnableHost bool `hcl:"enable_host,optional" json:"enable_host,omitempty" mapstructure:"enable_host"` // Host port Protocol string `hcl:"protocol,optional" json:"protocol,omitempty"` // Protocol tcp, udp }
PortRange allows a range of ports to be mapped
type RemoteExec ¶
type RemoteExec struct { types.ResourceMetadata `hcl:",remain"` Networks []NetworkAttachment `hcl:"network,block" json:"networks,omitempty"` // Attach to the correct network // only when Image is specified // Either Image or Target must be specified Image *Image `hcl:"image,block" json:"image,omitempty"` // Create a new container and exec Target string `hcl:"target,optional" json:"target,omitempty"` // Attach to a running target and exec // Either Script or Command must be specified //Script string `hcl:"script,optional" json:"script,omitempty"` // Path to a script to execute Command []string `hcl:"command,optional" json:"command,omitempty"` // Command to execute WorkingDirectory string `hcl:"working_directory,optional" json:"working_directory,omitempty"` // Working directory to execute commands Volumes []Volume `hcl:"volume,block" json:"volumes,omitempty"` // Volumes to mount to container Environment map[string]string `hcl:"environment,optional" json:"environment,omitempty"` // environment variables to set when starting the container // User block for mapping the user id and group id inside the container RunAs *User `hcl:"run_as,block" json:"run_as,omitempty"` }
ExecRemote allows commands to be executed in remote containers
func (*RemoteExec) Process ¶
func (e *RemoteExec) Process() error
type Resources ¶
type Resources struct { CPU int `hcl:"cpu,optional" json:"cpu,omitempty"` // cpu limit for the container where 1 CPU = 1000 CPUPin []int `hcl:"cpu_pin,optional" json:"cpu_pin,omitempty"` // pin the container to one or more cpu cores Memory int `hcl:"memory,optional" json:"memory,omitempty"` // max memory the container can consume in MB }
Resources allows the setting of resource constraints for the Container
type Sidecar ¶
type Sidecar struct { // embedded type holding name, etc types.ResourceMetadata `hcl:",remain"` Target string `hcl:"target" json:"target"` Image Image `hcl:"image,block" json:"image"` // image to use for the container Entrypoint []string `hcl:"entrypoint,optional" json:"entrypoint,omitempty"` // entrypoint to use when starting the container Command []string `hcl:"command,optional" json:"command,omitempty"` // command to use when starting the container Environment map[string]string `hcl:"environment,optional" json:"environment,omitempty"` // environment variables to set when starting the container Volumes []Volume `hcl:"volume,block" json:"volumes,omitempty"` // volumes to attach to the container Privileged bool `hcl:"privileged,optional" json:"privileged,omitempty"` // run the container in privileged mode? // resource constraints Resources *Resources `hcl:"resources,block" json:"resources,omitempty"` // resource constraints for the container // health checks for the container HealthCheck *HealthCheck `hcl:"health_check,block" json:"health_check,omitempty"` MaxRestartCount int `hcl:"max_restart_count,optional" json:"max_restart_count,omitempty"` // FQDN is the fully qualified domain name for the container, this can be used // to access the container from other sources FQDN string `hcl:"fqdn,optional" json:"fqdn,omitempty"` }
Sidecar defines a structure for creating Docker containers
type Template ¶
type Template struct { types.ResourceMetadata `hcl:",remain"` Source string `hcl:"source" json:"source"` // Source template to be processed as string Destination string `hcl:"destination" json:"destination"` // Destination filename to write Variables interface{} `hcl:"variables,optional" json:"variables,omitempty"` // Variables to be processed in the template InternalVars map[string]interface{} // stores a converted go type version of the hcl.Value types }
Template allows the process of user defined templates
type TrafficTarget ¶
type TrafficTarget struct { // ID of the resource that the ingress is linked to ID string `hcl:"id" json:"id"` Port int `hcl:"port,optional" json:"port,omitempty"` NamedPort string `hcl:"named_port,optional" json:"named_port,omitempty"` // Config is an collection which has driver specific content Config map[string]string `hcl:"config" json:"config"` }
Traffic defines either a source or a destination block for ingress traffic
type Volume ¶
type Volume struct { Source string `hcl:"source" json:"source"` // source path on the local machine for the volume Destination string `hcl:"destination" json:"destination"` // path to mount the volume inside the container Type string `hcl:"type,optional" json:"type,omitempty"` // type of the volume to mount [bind, volume, tmpfs] ReadOnly bool `hcl:"read_only,optional" json:"read_only,omitempty"` // specify that the volume is mounted read only BindPropagation string `hcl:"bind_propagation,optional" json:"bind_propagation,omitempty"` // propagation mode for bind mounts [shared, private, slave, rslave, rprivate] BindPropagationNonRecursive bool `hcl:"bind_propagation_non_recursive,optional" json:"bind_propagation_non_recursive,omitempty"` // recursive bind mount, default true }
Volume defines a folder, Docker volume, or temp folder to mount to the Container