model

package
v0.0.0-...-db657e9 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2017 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleTypeBoshTask = RoleType("bosh-task") // A role that is a BOSH task
	RoleTypeBosh     = RoleType("bosh")      // A role that is a BOSH job
	RoleTypeDocker   = RoleType("docker")    // A role that is a raw Docker image
)

These are the types of roles available

View Source
const (
	FlightStagePreFlight  = FlightStage("pre-flight")  // A role that runs before the main jobs start
	FlightStageFlight     = FlightStage("flight")      // A role that is a main job
	FlightStagePostFlight = FlightStage("post-flight") // A role that runs after the main jobs are up
	FlightStageManual     = FlightStage("manual")      // A role that only runs via user intervention
)

These are the flight stages available

View Source
const (
	// CVTypeUser is for user-specified variables (default)
	CVTypeUser = CVType("user")
	// CVTypeEnv is for script-specified variables
	CVTypeEnv = CVType("environment")
)

Variables

This section is empty.

Functions

func AggregateSignatures

func AggregateSignatures(signatures []string) string

AggregateSignatures returns the SHA1 for a slice of strings

func FlattenOpinions

func FlattenOpinions(opinions map[string]interface{}, total bool) map[string]string

FlattenOpinions converts the incoming nested map of opinions into a flat map of properties to values (strings). When 'total' is set (to true) array values are recursed into and flattened as well.

Types

type CVMap

type CVMap map[string]*ConfigurationVariable

CVMap is a map from variable name to ConfigurationVariable, for various places which require quick access/search/existence check.

func MakeMapOfVariables

func MakeMapOfVariables(rolesManifest *RoleManifest) CVMap

MakeMapOfVariables converts the sequence of configuration variables into a map we can manipulate more directly by name.

type CVType

type CVType string

CVType is the type of the configuration variable; see the constants below

type Configuration

type Configuration struct {
	Templates map[string]string          `yaml:"templates"`
	Variables ConfigurationVariableSlice `yaml:"variables"`
}

Configuration contains information about how to configure the resulting images

type ConfigurationVariable

type ConfigurationVariable struct {
	Name        string                          `yaml:"name"`
	Default     interface{}                     `yaml:"default"`
	Description string                          `yaml:"description"`
	Generator   *ConfigurationVariableGenerator `yaml:"generator"`
	Type        CVType                          `yaml:"type"`
	Internal    bool                            `yaml:"internal,omitempty"`
	Secret      bool                            `yaml:"secret,omitempty"`
}

ConfigurationVariable is a configuration to be exposed to the IaaS

Notes on the fields Type and Internal.

  1. Type's legal values are `user` and `environment`. `user` is default.

    A `user` CV is rendered into k8s yml config files, etc. to make it available to roles who need it. - An internal CV is rendered to all roles. - A public CV is rendered only to the roles whose templates refer to the CV.

    An `environment` CV comes from a script, not the user. Being internal this way it is not rendered to any configuration files.

  1. Internal's legal values are all YAML boolean values. A public CV is used in templates An internal CV is not, consumed in a script instead.

type ConfigurationVariableGenerator

type ConfigurationVariableGenerator struct {
	ID        string `yaml:"id"`
	Type      string `yaml:"type"`
	ValueType string `yaml:"value_type"`
}

ConfigurationVariableGenerator describes how to automatically generate values for a configuration variable

type ConfigurationVariableSlice

type ConfigurationVariableSlice []*ConfigurationVariable

ConfigurationVariableSlice is a sortable slice of ConfigurationVariables

func (ConfigurationVariableSlice) Len

func (confVars ConfigurationVariableSlice) Len() int

Len is the number of ConfigurationVariables in the slice

func (ConfigurationVariableSlice) Less

func (confVars ConfigurationVariableSlice) Less(i, j int) bool

Less reports whether config variable at index i sort before the one at index j

func (ConfigurationVariableSlice) Swap

func (confVars ConfigurationVariableSlice) Swap(i, j int)

Swap exchanges configuration variables at index i and index j

type FlightStage

type FlightStage string

FlightStage describes when a role should be executed

type HealthCheck

type HealthCheck struct {
	Liveness  *HealthProbe `yaml:"liveness,omitempty"`  // Details of liveness probe configuration
	Readiness *HealthProbe `yaml:"readiness,omitempty"` // Ditto for readiness probe
}

HealthCheck describes a non-standard health check endpoint

type HealthProbe

type HealthProbe struct {
	URL              string            `yaml:"url"`                         // URL for a HTTP GET to return 200~399. Cannot be used with other checks.
	Headers          map[string]string `yaml:"headers"`                     // Custom headers; only used for URL.
	Command          []string          `yaml:"command"`                     // Custom command. Cannot be used with other checks.
	Port             int32             `yaml:"port"`                        // Port for a TCP probe. Cannot be used with other checks.
	InitialDelay     int32             `yaml:"initial_delay,omitempty"`     // Initial Delay in seconds, default 3, minimum 1
	Period           int32             `yaml:"period,omitempty"`            // Period in seconds, default 10, minimum 1
	Timeout          int32             `yaml:"timeout,omitempty"`           // Timeout in seconds, default 3, minimum 1
	SuccessThreshold int32             `yaml:"success_threshold,omitempty"` // Success threshold in seconds, default 1, minimum 1
	FailureThreshold int32             `yaml:"failure_threshold,omitempty"` // Failure threshold in seconds, default 3, minimum 1
}

HealthProbe holds the configuration for liveness and readiness probes based on the HealthCheck containing them.

type Job

type Job struct {
	Name        string
	Description string
	Templates   []*JobTemplate
	Packages    Packages
	Path        string
	Fingerprint string
	SHA1        string
	Properties  []*JobProperty
	Version     string
	Release     *Release
	// contains filtered or unexported fields
}

Job represents a BOSH job

func (*Job) Extract

func (j *Job) Extract(destination string) (string, error)

Extract will extract the contents of the job archive to destination It creates a directory with the name of the job Returns the full path of the extracted archive

func (*Job) GetPropertiesForJob

func (j *Job) GetPropertiesForJob(opinions *Opinions) (map[string]interface{}, error)

GetPropertiesForJob returns the parameters for the given job, using its specs and opinions

func (*Job) MergeSpec

func (j *Job) MergeSpec(otherJob *Job)

MergeSpec is used to merge temporary spec patches into each job. otherJob should only be the fissile-compat/patch-properties job. The code assumes package and property objects are immutable, as they're now being shared across jobs. Also, when specified packages or properties are specified in the "other" job, that one takes precedence.

func (*Job) ValidateSHA1

func (j *Job) ValidateSHA1() error

ValidateSHA1 validates that the SHA1 of the actual job archive is the same as the one from the release manifest

func (*Job) WriteConfigs

func (j *Job) WriteConfigs(role *Role, lightOpinionsPath, darkOpinionsPath string) ([]byte, error)

WriteConfigs merges the job's spec with the opinions and returns the result as JSON.

type JobProperty

type JobProperty struct {
	Name        string
	Description string
	Default     interface{}
	Job         *Job
}

JobProperty is a generic key-value property referenced by a job

type JobTemplate

type JobTemplate struct {
	SourcePath      string
	DestinationPath string
	Job             *Job
	Content         string
}

JobTemplate represents a BOSH job template

type Jobs

type Jobs []*Job

Jobs is an array of Job*

func (Jobs) Len

func (slice Jobs) Len() int

Len implements the Len function to satisfy sort.Interface

func (Jobs) Less

func (slice Jobs) Less(i, j int) bool

Less implements the Less function to satisfy sort.Interface

func (Jobs) Swap

func (slice Jobs) Swap(i, j int)

Swap implements the Swap function to satisfy sort.Interface

type Opinions

type Opinions struct {
	Light map[string]interface{}
	Dark  map[string]interface{}
}

Opinions holds the light and dark opinions given to fissile

func NewEmptyOpinions

func NewEmptyOpinions() *Opinions

NewEmptyOpinions returns an empty opinions object, used for testing and generating the version of the package layer, that doesn't change if opinions change

func NewOpinions

func NewOpinions(lightFile, darkFile string) (*Opinions, error)

NewOpinions returns the json opinions for the light and dark opinion files

func (*Opinions) GetOpinionForKey

func (o *Opinions) GetOpinionForKey(opinions map[string]interface{}, keyPieces []string) (result interface{})

GetOpinionForKey pulls an opinion out of the holding container.

type Package

type Package struct {
	Name         string
	Version      string
	Fingerprint  string
	SHA1         string
	Release      *Release
	Path         string
	Dependencies Packages
	// contains filtered or unexported fields
}

Package represents a BOSH package

func (*Package) Extract

func (p *Package) Extract(destination string) (string, error)

Extract will extract the contents of the package archive to destination It creates a directory with the name of the package Returns the full path of the extracted archive

func (*Package) GetPackageCompiledDir

func (p *Package) GetPackageCompiledDir(workDir string) string

GetPackageCompiledDir returns the path to the build result directory of the package, underneath the main cache directory

func (*Package) GetPackageCompiledTempDir

func (p *Package) GetPackageCompiledTempDir(workDir string) string

GetPackageCompiledTempDir returns the path to the build temp directory for the package, underneath the main cache directory

func (*Package) GetTargetPackageSourcesDir

func (p *Package) GetTargetPackageSourcesDir(workDir string) string

GetTargetPackageSourcesDir returns the path to the sources of the package, underneath the main cache directory

func (*Package) ValidateSHA1

func (p *Package) ValidateSHA1() error

ValidateSHA1 validates that the SHA1 of the actual package archive is the same as the one from the release manifest

type Packages

type Packages []*Package

Packages is an array of *Package

func (Packages) Len

func (slice Packages) Len() int

Len implements the Len function to satisfy sort.Interface

func (Packages) Less

func (slice Packages) Less(i, j int) bool

Less implements the Less function to satisfy sort.Interface

func (Packages) Swap

func (slice Packages) Swap(i, j int)

Swap implements the Swap function to satisfy sort.Interface

type Release

type Release struct {
	Jobs               Jobs
	Packages           Packages
	License            ReleaseLicense
	Name               string
	UncommittedChanges bool
	CommitHash         string
	Version            string
	Path               string
	DevBOSHCacheDir    string
	// contains filtered or unexported fields
}

Release represents a BOSH release

func NewDevRelease

func NewDevRelease(path, releaseName, version, boshCacheDir string) (*Release, error)

NewDevRelease will create an instance of a BOSH development release

func (*Release) GetUniqueConfigs

func (r *Release) GetUniqueConfigs() map[string]*ReleaseConfig

GetUniqueConfigs returns all unique configs available in a release

func (*Release) LookupJob

func (r *Release) LookupJob(jobName string) (*Job, error)

LookupJob will find a job within a BOSH release

func (*Release) LookupPackage

func (r *Release) LookupPackage(packageName string) (*Package, error)

LookupPackage will find a package within a BOSH release

type ReleaseConfig

type ReleaseConfig struct {
	Name        string
	Description string
	Jobs        Jobs
	UsageCount  int
}

ReleaseConfig is a global deployment configuration key

type ReleaseLicense

type ReleaseLicense struct {
	// Files is a mapping of license file names to contents
	Files map[string][]byte
	// Release this license belongs to
	Release *Release
}

ReleaseLicense represents the license of a BOSH release

type Role

type Role struct {
	Name              string         `yaml:"name"`
	Jobs              Jobs           `yaml:"_,omitempty"`
	EnvironScripts    []string       `yaml:"environment_scripts"`
	Scripts           []string       `yaml:"scripts"`
	PostConfigScripts []string       `yaml:"post_config_scripts"`
	Type              RoleType       `yaml:"type,omitempty"`
	JobNameList       []*roleJob     `yaml:"jobs"`
	Configuration     *Configuration `yaml:"configuration"`
	Run               *RoleRun       `yaml:"run"`
	Tags              []string       `yaml:"tags"`
	// contains filtered or unexported fields
}

Role represents a collection of jobs that are colocated on a container

func (*Role) GetRoleDevVersion

func (r *Role) GetRoleDevVersion(opinions *Opinions, fissileVersion string) (string, error)

GetRoleDevVersion determines the version hash for the role, using the basic role dev version, and the aggregated spec and opinion information. In this manner opinion changes cause a rebuild of the associated role images.

func (*Role) GetScriptPaths

func (r *Role) GetScriptPaths() map[string]string

GetScriptPaths returns the paths to the startup / post configgin scripts for a role

func (*Role) GetScriptSignatures

func (r *Role) GetScriptSignatures() (string, error)

GetScriptSignatures returns the SHA1 of all of the script file names and contents

func (*Role) GetTemplateSignatures

func (r *Role) GetTemplateSignatures() (string, error)

GetTemplateSignatures returns the SHA1 of all of the templates and contents

func (*Role) GetVariablesForRole

func (r *Role) GetVariablesForRole() (ConfigurationVariableSlice, error)

GetVariablesForRole returns all the environment variables required for calculating all the templates for the role

func (*Role) HasTag

func (r *Role) HasTag(tag string) bool

HasTag returns true if the role has a specific tag

func (*Role) IsDevRole

func (r *Role) IsDevRole() bool

IsDevRole tests if the role is tagged for development, or not. It returns true for development-roles, and false otherwise.

type RoleManifest

type RoleManifest struct {
	Roles         Roles          `yaml:"roles"`
	Configuration *Configuration `yaml:"configuration"`
	// contains filtered or unexported fields
}

RoleManifest represents a collection of roles

func LoadRoleManifest

func LoadRoleManifest(manifestFilePath string, releases []*Release) (*RoleManifest, error)

LoadRoleManifest loads a yaml manifest that details how jobs get grouped into roles

func (*RoleManifest) GetRoleManifestDevPackageVersion

func (m *RoleManifest) GetRoleManifestDevPackageVersion(roles Roles, opinions *Opinions, fissileVersion, extra string) (string, error)

GetRoleManifestDevPackageVersion gets the aggregate signature of all the packages

func (*RoleManifest) LookupRole

func (m *RoleManifest) LookupRole(roleName string) *Role

LookupRole will find the given role in the role manifest

func (*RoleManifest) SelectRoles

func (m *RoleManifest) SelectRoles(roleNames []string) (Roles, error)

SelectRoles will find only the given roles in the role manifest

type RoleRun

type RoleRun struct {
	Scaling           *RoleRunScaling       `yaml:"scaling"`
	Capabilities      []string              `yaml:"capabilities"`
	PersistentVolumes []*RoleRunVolume      `yaml:"persistent-volumes"`
	SharedVolumes     []*RoleRunVolume      `yaml:"shared-volumes"`
	Memory            int                   `yaml:"memory"`
	VirtualCPUs       int                   `yaml:"virtual-cpus"`
	ExposedPorts      []*RoleRunExposedPort `yaml:"exposed-ports"`
	FlightStage       FlightStage           `yaml:"flight-stage"`
	HealthCheck       *HealthCheck          `yaml:"healthcheck,omitempty"`
	Environment       []string              `yaml:"env"`
}

RoleRun describes how a role should behave at runtime

type RoleRunExposedPort

type RoleRunExposedPort struct {
	Name     string `yaml:"name"`
	Protocol string `yaml:"protocol"`
	External string `yaml:"external"`
	Internal string `yaml:"internal"`
	Public   bool   `yaml:"public"`
}

RoleRunExposedPort describes a port to be available to other roles, or the outside world

type RoleRunScaling

type RoleRunScaling struct {
	Min int32 `yaml:"min"`
	Max int32 `yaml:"max"`
}

RoleRunScaling describes how a role should scale out at runtime

type RoleRunVolume

type RoleRunVolume struct {
	Path string `yaml:"path"`
	Tag  string `yaml:"tag"`
	Size int    `yaml:"size"`
}

RoleRunVolume describes a volume to be attached at runtime

type RoleType

type RoleType string

RoleType is the type of the role; see the constants below

type Roles

type Roles []*Role

Roles is an array of Role*

func (Roles) Len

func (roles Roles) Len() int

Len is the number of roles in the slice

func (Roles) Less

func (roles Roles) Less(i, j int) bool

Less reports whether role at index i sort before role at index j

func (Roles) Swap

func (roles Roles) Swap(i, j int)

Swap exchanges roles at index i and index j

Jump to

Keyboard shortcuts

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