utils

package
v0.5.61 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const BuildImagePrefix = "jumppad.dev/localcache"

BuildImagePrefix is the default prefix added to any image built by jumppad

View Source
const CacheResourceName string = "docker-cache"

Name of the Cache resource

View Source
const ImageVolumeName string = "images"

ImageVolumeName is the name of the volume which stores the images for clusters

View Source
const MaxRandomPort = 32767
View Source
const MinRandomPort = 30000
View Source
const ProxyBypass string = "localhost,127.0.0.1,cluster.local,jumppad.dev,svc,consul"

Addresses to bypass when using a HTTP Proxy

Variables

View Source
var InvalidBlueprintURIError = fmt.Errorf("Inavlid blueprint URI")
View Source
var NameContainsInvalidCharactersError = fmt.Errorf("Name contains invalid characters characters must be either a-z, A-Z, 0-9, -, _")
View Source
var NameExceedsMaxLengthError = fmt.Errorf("Name exceeds the max length of 128 characters")

Functions

func BlueprintFolder added in v0.5.52

func BlueprintFolder(blueprint string) (string, error)

BlueprintFolder parses a blueprint uri and returns the top level blueprint folder if the URI is not a blueprint will return an error

func BlueprintLocalFolder added in v0.5.52

func BlueprintLocalFolder(blueprint string) string

BlueprintLocalFolder returns the full storage path for the given blueprint URI

func CacheFolder added in v0.5.52

func CacheFolder(p string, perms os.FileMode) string

CacheFolder creates the cache directory used by the a provider unlike DataFolders, cache folders are not removed when down is called

func CertsDir

func CertsDir(name string) string

CertsDir returns the location of the certificates for the given resource used to secure the Jumppad ingress, usually rooted at $HOME/.jumppad/certs

func ChecksumFromInterface added in v0.5.60

func ChecksumFromInterface(i interface{}) (string, error)

InterfaceChecksum returns a checksum of the given interface Note: the checksum is positional, should an element in a map or list change position then a different checksum will be returned.

func CreateFolders

func CreateFolders()

Creates the required file structure in the users Home directory

func CreateKubeConfigPath

func CreateKubeConfigPath(name string) (dir, filePath string, dockerPath string)

CreateKubeConfigPath creates the file path for the KubeConfig file when using Kubernetes cluster

func DataFolder added in v0.5.52

func DataFolder(p string, perms os.FileMode) string

DataFolder creates the data directory used by the application

func EnsureAbsolute added in v0.5.38

func EnsureAbsolute(path, file string) string

EnsureAbsolute ensure that the given path is either absolute or if relative is converted to abasolute based on the path of the config

func FQDN

func FQDN(name, module, typeName string) string

FQDN generates the full qualified name for a container

func FQDNVolumeName

func FQDNVolumeName(name string) string

FQDNVolumeName creates a full qualified volume name

func GetConnectorLogFile

func GetConnectorLogFile() string

GetConnectorLogFile returns the log file used by the connector

func GetConnectorPIDFile

func GetConnectorPIDFile() string

GetConnectorPIDFile returns the connector PID file used by the connector

func GetDockerHost

func GetDockerHost() string

GetDockerHost returns the location of the Docker API depending on the platform

func GetDockerIP

func GetDockerIP() string

GetDockerIP returns the location of the Docker Server IP address

func GetHostname

func GetHostname() string

GetHostname returns the hostname for the current machine

func GetJumppadBinaryPath added in v0.5.55

func GetJumppadBinaryPath() string

GetJumppadBinaryPath returns the path to the running Jumppad binary

func GetLocalIPAddresses

func GetLocalIPAddresses() []string

GetLocalIPAddress returns a list of ip addressses for the local machine

func GetLocalIPAndHostname

func GetLocalIPAndHostname() (string, string)

GetLocalIPAndHostname returns the IP Address of the machine

func HashDir added in v0.5.36

func HashDir(dir string, ignore ...string) (string, error)

HashDir generates a hash of the given directory optionally a list of arguments to be ignored can be passed these arguments are expresed as a glob pattern

func HashFile added in v0.5.36

func HashFile(file string) (string, error)

HashFile returns a sha256 hash of the given file

func HashString added in v0.5.40

func HashString(content string) (string, error)

HashString returns a sha256 hash of the given string

func HelmLocalFolder added in v0.5.52

func HelmLocalFolder(chart string) string

HelmLocalFolder returns the full storage path for the given blueprint URI

func HomeEnvName

func HomeEnvName() string

HomeEnvName returns the environment variable used to store the home path

func HomeFolder

func HomeFolder() string

HomeFolder returns the users homefolder this will be $HOME on windows and mac and USERPROFILE on windows

func ImageCacheAddress added in v0.5.60

func ImageCacheAddress() string

ImageCacheADDR returns the default Image cache used by Nomad and Kubernetes clusters unless the environment variable IMAGE_CACHE_ADDR is set when it returns this value

func ImageCacheLog

func ImageCacheLog() string

ImageCacheLog returns the location of the image cache log

func IsHCLFile

func IsHCLFile(path string) bool

IsHCLFile tests if the given path resolves to a HCL config file

func IsLocalFolder

func IsLocalFolder(path string) bool

IsLocalFolder tests if the given path is a localfolder and can exist in the current filesystem TODO make more robust with error messages to improve UX

func JumppadHome added in v0.5.16

func JumppadHome() string

JumppadHome returns the location of the jumppad folder, usually $HOME/.jumppad

func JumppadTemp added in v0.5.55

func JumppadTemp() string

JumppadTemp returns a temporary folder

func LibraryFolder added in v0.5.52

func LibraryFolder(p string, perms os.FileMode) string

LibraryFolder creates the library directory used by the application

func LogsDir

func LogsDir() string

LogsDir returns the location of the logs used to secure the Jumppad ingress, usually $HOME/.jumppad/logs

func PluginsDir added in v0.5.60

func PluginsDir() string

PluginsDir returns the location of the plugins

func RandomAvailablePort added in v0.5.60

func RandomAvailablePort(from, to int) (int, error)

RandomAvailablePort returns a random free port in the given range

func ReleasesFolder added in v0.5.52

func ReleasesFolder() string

ReleasesFolder return the path of the Shipyard releases

func ReplaceNonURIChars

func ReplaceNonURIChars(s string) (string, error)

ReplaceNonURIChars replaces any characters in the resource name which can not be used in a URI

func StateDir

func StateDir() string

StateDir returns the location of the jumppad state, usually $HOME/.jumppad/state

func StatePath

func StatePath() string

StatePath returns the full path for the state file

func SubnetIPs

func SubnetIPs(subnet string) ([]string, error)

get all ipaddresses in a subnet

func ValidateName

func ValidateName(name string) (bool, error)

ValidateName ensures that the name for a resource is within certain boundaries Valid characters: [a-z] [A-Z] _ - [0-9] Max length: 128

Types

type ClusterConfig

type ClusterConfig struct {
	// Location of the Cluster
	LocalAddress  string `json:"local_address"`
	RemoteAddress string `json:"remote_address"`

	// Port the API Server is running on
	APIPort int `json:"api_port"`

	// Port the API Server is running on reachable from
	// a remote network
	RemoteAPIPort int `json:"remote_api_port"`

	// Port where the connector is running
	ConnectorPort int `json:"connector_port"`

	// Number of nodes in the cluster
	NodeCount int `json:"node_count"`

	// Does the API use SSL?
	SSL bool `json:"ssl"`
	// contains filtered or unexported fields
}

ClusterConfig defines a config file which is used to store Nomad cluster connection info

func (*ClusterConfig) APIAddress

func (n *ClusterConfig) APIAddress(context Context) string

APIAddress returns the FQDN for the API server

func (*ClusterConfig) ConnectorAddress

func (n *ClusterConfig) ConnectorAddress(context Context) string

ConnectorAddress returns the FQDN for the gRPC endpoing of the Connector

func (*ClusterConfig) Load

func (n *ClusterConfig) Load(file string) error

Load the config from a file

func (*ClusterConfig) Save

func (n *ClusterConfig) Save(file string) error

Save the config to a file

type Context

type Context string

Context is a type which stores the context for the cluster

const LocalContext Context = "local"

LocalContext defines a constant for the local context

const RemoteContext Context = "remote"

RemoteContext defines a constant for the remote context

Directories

Path Synopsis
Package dirhash defines hashes over directory trees.
Package dirhash defines hashes over directory trees.

Jump to

Keyboard shortcuts

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