deployment

package
v0.0.0-...-66c7a0d Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 18 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectionsForConfig

func CollectionsForConfig(c *dc.ConfigRequest) []string

func ContainsAutomateCollection

func ContainsAutomateCollection(c *dc.ConfigRequest) bool

func ContainsCollection

func ContainsCollection(c *dc.ConfigRequest, collectionName string) bool

func ExpectedServiceIDsForConfig

func ExpectedServiceIDsForConfig(c *dc.ConfigRequest) ([]habpkg.HabPkg, error)

func SethealthCheckConfig

func SethealthCheckConfig(config *dc.AutomateConfig)

Types

type Deployment

type Deployment struct {
	ID        string
	CreatedAt time.Time
	// TODO: I wish we had some safety around modifications to this
	Config     *dc.AutomateConfig
	LastAction string
	Deployed   bool
	// ExpectedServices is a map from a string in the form of
	// origin/name to Service structs that represent the desired
	// state of the service per the user's configuration.
	ExpectedServices       []*Service
	CurrentReleaseManifest *manifest.A2
	// contains filtered or unexported fields
}

Deployment represents a given deployment of Chef Automate.

func CreateDeployment

func CreateDeployment() (*Deployment, error)

CreateDeployment creates a new, unconfigured deployment.

func CreateDeploymentWithUserOverrideConfig

func CreateDeploymentWithUserOverrideConfig(config *dc.AutomateConfig) (*Deployment, error)

CreateDeploymentWithUserOverrideConfig creates a configured deployment.

func RestoreDeploymentFromUserOverrideConfig

func RestoreDeploymentFromUserOverrideConfig(config *dc.AutomateConfig) (*Deployment, error)

RestoreDeploymentFromUserOverrideConfig is used by the persistence layer to regenerate the deployment struct from the persisted override config before then restoring the rest of the deployment state

func (*Deployment) BackupGatewayEndpoint

func (d *Deployment) BackupGatewayEndpoint() string

BackupGatewayEndpoint is the listen address of the backup-gateway.

func (*Deployment) CA

CA returns the underlying CertificateAuthority

Currently initializing the CA just depends on the authority_id which is linked to the deployment_id

func (*Deployment) Channel

func (d *Deployment) Channel() string

Channel returns the Habitat channel for deployment

func (*Deployment) EnsureCerts

func (d *Deployment) EnsureCerts() error

EnsureCerts ensures that every ExpectedService has a generated TLS certificate and key

func (*Deployment) FQDN

func (d *Deployment) FQDN() string

FQDN returns the stack's fqdn

func (*Deployment) GetUserOverrideConfigForPersistence

func (d *Deployment) GetUserOverrideConfigForPersistence() *dc.AutomateConfig

GetUserOverrideConfigForPersistence returns the user-provided configuration. This function is used for persistence. Seriously, this function is used for persistence.

func (*Deployment) InitCA

func (d *Deployment) InitCA(dataDir string) error

InitCA initializes the certificate authority for this deployment. Take care to keep this safe to call multiple times.

func (*Deployment) Lock

func (d *Deployment) Lock()

Lock takes an exclusive lock of the deployment struct for writing. It will block until the lock is available.

func (*Deployment) MergeIntoUserOverrideConfig

func (d *Deployment) MergeIntoUserOverrideConfig(config *dc.AutomateConfig, secretStore secrets.SecretStore) error

MergeIntoUserOverrideConfig merges the provided config into the user override config. The input should be a sparse override config.

func (*Deployment) MoveSecretsToSecretStore

func (d *Deployment) MoveSecretsToSecretStore(secretStore secrets.SecretStore) error

func (*Deployment) NotSkippedServiceNames

func (d *Deployment) NotSkippedServiceNames() []string

NotSkippedServiceNames returns a slice of strings that represent services that have not been skipped.

func (*Deployment) ReplaceUserOverrideConfig

func (d *Deployment) ReplaceUserOverrideConfig(config *dc.AutomateConfig, secretStore secrets.SecretStore) error

ReplaceUserOverrideConfig replaces the deployments override config with the given config. The input should be a sparse override config.

func (*Deployment) ServiceByName

func (d *Deployment) ServiceByName(name string) (*Service, bool)

ServiceByName searches for the given service by name, returning a pointer to the service and true if it is found or nil and false if it is not found.

func (*Deployment) ServiceNames

func (d *Deployment) ServiceNames() []string

ServiceNames returns a slice of the expected service names

func (*Deployment) SetInstalledExpectations

func (d *Deployment) SetInstalledExpectations(serviceNames []string) error

SetInstalledExpectations sets the expectation of each named service to Installed.

func (*Deployment) SetRemovedExpectations

func (d *Deployment) SetRemovedExpectations(serviceNames []string) error

SetRemovedExpectations sets the expectation of each named service to Removed

func (*Deployment) SetRunningExpectations

func (d *Deployment) SetRunningExpectations(serviceNames []string) error

SetRunningExpectations sets the expectation of each named service to Running

func (*Deployment) SetTarget

func (d *Deployment) SetTarget(t target.Target)

SetTarget sets the target of the deployment

TODO: this is a not-so-temporary solution to the problem described in Target()

func (*Deployment) Status

func (d *Deployment) Status() api.DeploymentID

Status returns the current status of the Deployment.

func (*Deployment) Target

func (d *Deployment) Target() target.Target

Target returns the deployment's target

TODO: sd 2017/12/07 - we'd like to have target auto-populate based on the AutomateConfig stored in the Deployment, but right now that would cause a nasty go dependency cycle that's better left to a future change

I'd like this to work in the auto-populate fashion so that we have to do less work when restoring the deployment from a the database. e.g. we just come back up, read the struct out, and then when the server needs access to the target or the eventsender then we'll simply create them from the config if needed

func (*Deployment) Unlock

func (d *Deployment) Unlock()

Unlock releases a previously help lock. Panics if called when the lock is not held.

func (*Deployment) UpdateExpectedServicesFromManifest

func (d *Deployment) UpdateExpectedServicesFromManifest() error

UpdateExpectedServicesFromManifest updates the expected services from.....the internal manifest.

func (*Deployment) UpdateWithUserOverrideConfig

func (d *Deployment) UpdateWithUserOverrideConfig(config *dc.AutomateConfig, secretStore secrets.SecretStore) error

UpdateWithUserOverrideConfig creates a new Deployment struct with a user-provided configuration as input. This input is stored internally and is what is persisted when we persist the Deployment to the database. The result of merging the user-provided configuration with the default configuration values is available to use via the Config field. We also initialize the set of expected services

type Service

type Service struct {
	habpkg.Installable
	// TODO(jaym) The things below should be moved out into something about
	// serializing the deployment state
	DeploymentState ServiceDeploymentState
	SSLKey          string
	SSLCert         string
}

A Service represents a Chef Automate service managed by the deployment service.

func NewServiceFromHabPackage

func NewServiceFromHabPackage(habPackage habpkg.HabPkg) (service *Service)

NewServiceFromHabPackage inflates a Service from a habpkg.HabPkg by reading the embedded service data and unmarshaling it into the struct.

func ServiceFromManifest

func ServiceFromManifest(m manifest.ReleaseManifest, name string) *Service

ServiceFromManifest creates a service from the manifest. It will prefer harts if available

type ServiceDeploymentState

type ServiceDeploymentState int

ServiceDeploymentState describes what state we expect a service in

const (
	// Skip describes the default deployment state. We haven't been told what to do
	// with the service, so we'll skip it
	Skip ServiceDeploymentState = iota
	// Installed deployment state says that the service should be installed but not running
	Installed
	// Running deployment state means the service should be running
	Running
	// Removed deployment state means the service should not be running
	Removed
)

WARNING: These are serialized as part of the service state. Be careful

type ServicesByName

type ServicesByName api.ServiceStatus

ServicesByName - Sorting Interface for ServiceStates

func (ServicesByName) Len

func (ss ServicesByName) Len() int

func (ServicesByName) Less

func (ss ServicesByName) Less(i, j int) bool

func (ServicesByName) Swap

func (ss ServicesByName) Swap(i, j int)

type StatusTimeoutError

type StatusTimeoutError struct {
	Status  *api.ServiceStatus
	Timeout time.Duration
}

StatusTimeoutError occurs when not all services come up as expected

func (*StatusTimeoutError) Error

func (e *StatusTimeoutError) Error() string

Jump to

Keyboard shortcuts

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