state

package
v0.49.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: Apache-2.0 Imports: 24 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GithubContent added in v0.47.0

type GithubContent struct {
	Repo  string       `json:"repo"`
	Path  string       `json:"path"`
	Ref   string       `json:"ref"`
	Files []GithubFile `json:"files"`
}

type GithubFile added in v0.47.0

type GithubFile struct {
	Name string `json:"name"`
	Path string `json:"path"`
	Sha  string `json:"sha"`
	Size int64  `json:"size"`
	Data string `json:"data"`
}

type Image added in v0.47.0

type Image struct {
	URL      string `json:"url"`
	Source   string `json:"source"`
	AppSlug  string `json:"appSlug"`
	ImageKey string `json:"imageKey"`
}

type Kustomize

type Kustomize struct {
	Overlays map[string]Overlay `json:"overlays,omitempty" yaml:"overlays,omitempty" hcl:"overlays,omitempty"`
}

func (*Kustomize) Ship

func (k *Kustomize) Ship() Overlay

type License added in v0.47.0

type License struct {
	ID        string    `json:"id" yaml:"id" hcl:"id"`
	Assignee  string    `json:"assignee" yaml:"assignee" hcl:"assignee"`
	CreatedAt time.Time `json:"createdAt" yaml:"createdAt" hcl:"createdAt"`
	ExpiresAt time.Time `json:"expiresAt" yaml:"expiresAt" hcl:"expiresAt"`
	Type      string    `json:"type" yaml:"type" hcl:"type"`
}

type Lifeycle

type Lifeycle struct {
	StepsCompleted StepsCompleted `json:"stepsCompleted,omitempty" yaml:"stepsCompleted,omitempty" hcl:"stepsCompleted,omitempty"`
}

func (*Lifeycle) WithCompletedStep

func (l *Lifeycle) WithCompletedStep(step api.Step) *Lifeycle

type MManager

type MManager struct {
	Logger log.Logger
	FS     afero.Afero
	V      *viper.Viper

	StateRWMut sync.RWMutex
	// contains filtered or unexported fields
}

MManager is the saved output of a plan run to load on future runs

func (*MManager) AddCA added in v0.26.0

func (m *MManager) AddCA(name string, newCA util.CAType) error

func (*MManager) AddCert added in v0.26.0

func (m *MManager) AddCert(name string, newCert util.CertType) error

func (*MManager) CachedState added in v0.48.0

func (m *MManager) CachedState() (State, error)

CachedState will return currently chached state.

func (*MManager) CommitState added in v0.48.0

func (m *MManager) CommitState() error

func (*MManager) ReloadFile added in v0.48.0

func (m *MManager) ReloadFile() error

func (*MManager) RemoveStateFile

func (m *MManager) RemoveStateFile() error

RemoveStateFile will attempt to remove the state file from disk

func (*MManager) ResetLifecycle added in v0.16.0

func (m *MManager) ResetLifecycle() error

ResetLifecycle is used by `ship update --headed` to reset the saved stepsCompleted in the state.json

func (*MManager) Save

func (m *MManager) Save(v State) error

func (*MManager) SaveKustomize

func (m *MManager) SaveKustomize(kustomize *Kustomize) error

func (*MManager) SerializeAppMetadata added in v0.16.0

func (m *MManager) SerializeAppMetadata(metadata api.ReleaseMetadata) error

SerializeAppMetadata is used by `ship app` to serialize replicated app metadata to state file

func (*MManager) SerializeConfig

func (m *MManager) SerializeConfig(assets []api.Asset, meta api.ReleaseMetadata, templateContext map[string]interface{}) error

SerializeConfig takes the application data and input params and serializes a state file to disk

func (*MManager) SerializeContentSHA

func (m *MManager) SerializeContentSHA(contentSHA string) error

SerializeContentSHA writes the contentSHA to the state file

func (*MManager) SerializeHelmValues

func (m *MManager) SerializeHelmValues(values string, defaults string) error

SerializeHelmValues takes user input helm values and serializes a state file to disk

func (*MManager) SerializeNamespace added in v0.30.0

func (m *MManager) SerializeNamespace(namespace string) error

SerializeNamespace serializes to disk the namespace to use for helm template

func (*MManager) SerializeReleaseName added in v0.20.0

func (m *MManager) SerializeReleaseName(name string) error

SerializeReleaseName serializes to disk the name to use for helm template

func (*MManager) SerializeShipMetadata added in v0.16.0

func (m *MManager) SerializeShipMetadata(metadata api.ShipAppMetadata, applicationType string) error

SerializeShipMetadata is used by `ship init` to serialize metadata from ship applications to state file

func (*MManager) SerializeUpstream

func (m *MManager) SerializeUpstream(upstream string) error

SerializeUpstream is used by `ship init` to serialize a state file with ChartURL to disk

func (*MManager) SerializeUpstreamContents added in v0.47.0

func (m *MManager) SerializeUpstreamContents(contents *UpstreamContents) error

SerializeConfig takes the application data and input params and serializes a state file to disk

func (*MManager) StateUpdate added in v0.47.0

func (m *MManager) StateUpdate(updater Update) (State, error)

applies the provided updater to the current state. Returns the new state and err

func (*MManager) UpdateVersion added in v0.47.0

func (m *MManager) UpdateVersion()

type Manager

type Manager interface {
	SerializeHelmValues(values string, defaults string) error
	SerializeReleaseName(name string) error
	SerializeNamespace(namespace string) error
	SerializeConfig(
		assets []api.Asset,
		meta api.ReleaseMetadata,
		templateContext map[string]interface{},
	) error
	CachedState() (State, error)
	CommitState() error
	ReloadFile() error
	StateUpdate(updater Update) (State, error)
	RemoveStateFile() error
	SaveKustomize(kustomize *Kustomize) error
	SerializeUpstream(URL string) error
	SerializeContentSHA(contentSHA string) error
	SerializeShipMetadata(api.ShipAppMetadata, string) error
	SerializeAppMetadata(api.ReleaseMetadata) error
	SerializeUpstreamContents(contents *UpstreamContents) error
	Save(v State) error
	ResetLifecycle() error
	UpdateVersion()

	AddCert(name string, newCert util.CertType) error
	AddCA(name string, newCA util.CAType) error
}

func GetManager added in v0.48.0

func GetManager(logger log.Logger, fs afero.Afero, v *viper.Viper) (Manager, error)

GetManager will create and return a singleton state manager object. This should be used in everything that isn't a test.

func GetSingleton added in v0.48.0

func GetSingleton() Manager

func NewDisposableManager added in v0.48.0

func NewDisposableManager(logger log.Logger, fs afero.Afero, v *viper.Viper) (Manager, error)

This will create a new state manager that isn't a singleton. Use this for tests, where state needs to be reset.

type Metadata added in v0.17.1

type Metadata struct {
	ApplicationType string  `json:"applicationType" yaml:"applicationType" hcl:"applicationType"`
	Sequence        int64   `json:"sequence" yaml:"sequence" hcl:"sequence" meta:"sequence"`
	Icon            string  `json:"icon,omitempty" yaml:"icon,omitempty" hcl:"icon,omitempty"`
	Name            string  `json:"name,omitempty" yaml:"name,omitempty" hcl:"name,omitempty"`
	ReleaseNotes    string  `json:"releaseNotes" yaml:"releaseNotes" hcl:"releaseNotes"`
	Version         string  `json:"version" yaml:"version" hcl:"version"`
	CustomerID      string  `json:"customerID,omitempty" yaml:"customerID,omitempty" hcl:"customerID,omitempty"`
	InstallationID  string  `json:"installationID,omitempty" yaml:"installationID,omitempty" hcl:"installationID,omitempty"`
	LicenseID       string  `json:"licenseID,omitempty" yaml:"licenseID,omitempty" hcl:"licenseID,omitempty"`
	AppSlug         string  `json:"appSlug,omitempty" yaml:"appSlug,omitempty" hcl:"appSlug,omitempty"`
	License         License `json:"license" yaml:"license" hcl:"license"`
}

type Overlay

type Overlay struct {
	ExcludedBases []string          `json:"excludedBases,omitempty" yaml:"excludedBases,omitempty" hcl:"excludedBases,omitempty"`
	Patches       map[string]string `json:"patches,omitempty" yaml:"patches,omitempty" hcl:"patches,omitempty"`
	Resources     map[string]string `json:"resources,omitempty" yaml:"resources,omitempty" hcl:"resources,omitempty"`
}

func NewOverlay added in v0.17.0

func NewOverlay() Overlay

type ShipRelease added in v0.47.0

type ShipRelease struct {
	ID              string           `json:"id"`
	Sequence        int64            `json:"sequence"`
	ChannelID       string           `json:"channelId"`
	ChannelName     string           `json:"channelName"`
	ChannelIcon     string           `json:"channelIcon"`
	Semver          string           `json:"semver"`
	ReleaseNotes    string           `json:"releaseNotes"`
	Spec            string           `json:"spec"`
	Images          []Image          `json:"images"`
	GithubContents  []GithubContent  `json:"githubContents"`
	Created         string           `json:"created"` // TODO: this time is not in RFC 3339 format
	RegistrySecret  string           `json:"registrySecret,omitempty"`
	EntitlementSpec string           `json:"entitlementSpec,omitempty"`
	Entitlements    api.Entitlements `json:"entitlements,omitempty"`
	ConfigSpec      string           `json:"configSpec,omitempty"`
	CollectSpec     string           `json:"collectSpec,omitempty"`
	AnalyzeSpec     string           `json:"analyzeSpec,omitempty"`
}

ShipRelease is the release response from GQL

func (*ShipRelease) ToReleaseMeta added in v0.47.0

func (r *ShipRelease) ToReleaseMeta() api.ReleaseMetadata

ToReleaseMeta linter

type State

type State struct {
	V1 *V1 `json:"v1,omitempty" yaml:"v1,omitempty" hcl:"v1,omitempty"`
}

func (State) CurrentCAs added in v0.26.0

func (v State) CurrentCAs() map[string]util.CAType

func (State) CurrentCerts added in v0.26.0

func (v State) CurrentCerts() map[string]util.CertType

func (State) CurrentConfig

func (v State) CurrentConfig() (map[string]interface{}, error)

func (State) CurrentHelmValues

func (v State) CurrentHelmValues() string

func (State) CurrentHelmValuesDefaults

func (v State) CurrentHelmValuesDefaults() string

func (State) CurrentKustomize

func (v State) CurrentKustomize() *Kustomize

func (State) CurrentKustomizeOverlay

func (v State) CurrentKustomizeOverlay(filename string) (contents string, isResource bool)

func (State) CurrentNamespace added in v0.30.0

func (v State) CurrentNamespace() string

func (State) CurrentReleaseName added in v0.20.0

func (v State) CurrentReleaseName() string

func (State) IsEmpty added in v0.16.0

func (v State) IsEmpty() bool

func (State) ReleaseMetadata added in v0.47.0

func (v State) ReleaseMetadata() *api.ReleaseMetadata

func (State) Upstream

func (v State) Upstream() string

func (State) UpstreamContents added in v0.47.0

func (v State) UpstreamContents() *UpstreamContents

func (State) Versioned

func (v State) Versioned() State

func (State) WithCompletedStep added in v0.47.0

func (v State) WithCompletedStep(step api.Step) State

type StepsCompleted

type StepsCompleted map[string]interface{}

func (StepsCompleted) String

func (s StepsCompleted) String() string

type Terraform added in v0.21.0

type Terraform struct {
	RawState string           `json:"rawState,omitempty" yaml:"rawState,omitempty" hcl:"rawState,omitempty"`
	State    *terraform.State `json:"state,omitempty" yaml:"state,omitempty" hcl:"state,omitempty"`
}

type Update added in v0.47.0

type Update func(State) (State, error)

type UpstreamContents added in v0.47.0

type UpstreamContents struct {
	UpstreamFiles []UpstreamFile `json:"upstreamFiles,omitempty" yaml:"upstreamFiles,omitempty" hcl:"upstreamFiles,omitempty"`
	AppRelease    *ShipRelease   `json:"appRelease,omitempty" yaml:"appRelease,omitempty" hcl:"appRelease,omitempty"`
}

type UpstreamFile added in v0.47.0

type UpstreamFile struct {
	FilePath     string `json:"filePath,omitempty" yaml:"filePath,omitempty" hcl:"filePath,omitempty"`
	FileContents string `json:"fileContents,omitempty" yaml:"fileContents,omitempty" hcl:"fileContents,omitempty"`
}

type V1

type V1 struct {
	Config             map[string]interface{} `json:"config" yaml:"config" hcl:"config"`
	Terraform          *Terraform             `json:"terraform,omitempty" yaml:"terraform,omitempty" hcl:"terraform,omitempty"`
	HelmValues         string                 `json:"helmValues,omitempty" yaml:"helmValues,omitempty" hcl:"helmValues,omitempty"`
	ReleaseName        string                 `json:"releaseName,omitempty" yaml:"releaseName,omitempty" hcl:"releaseName,omitempty"`
	Namespace          string                 `json:"namespace,omitempty" yaml:"namespace,omitempty" hcl:"namespace,omitempty"`
	HelmValuesDefaults string                 `json:"helmValuesDefaults,omitempty" yaml:"helmValuesDefaults,omitempty" hcl:"helmValuesDefaults,omitempty"`
	Kustomize          *Kustomize             `json:"kustomize,omitempty" yaml:"kustomize,omitempty" hcl:"kustomize,omitempty"`
	Upstream           string                 `json:"upstream,omitempty" yaml:"upstream,omitempty" hcl:"upstream,omitempty"`
	Metadata           *Metadata              `json:"metadata,omitempty" yaml:"metadata,omitempty" hcl:"metadata,omitempty"`
	UpstreamContents   *UpstreamContents      `json:"upstreamContents,omitempty" yaml:"upstreamContents,omitempty" hcl:"upstreamContents,omitempty"`
	ShipVersion        *version.Build         `json:"shipVersion,omitempty" yaml:"shipVersion,omitempty" hcl:"shipVersion,omitempty"`

	//deprecated in favor of upstream
	ChartURL string `json:"chartURL,omitempty" yaml:"chartURL,omitempty" hcl:"chartURL,omitempty"`

	ChartRepoURL string    `json:"ChartRepoURL,omitempty" yaml:"ChartRepoURL,omitempty" hcl:"ChartRepoURL,omitempty"`
	ChartVersion string    `json:"ChartVersion,omitempty" yaml:"ChartVersion,omitempty" hcl:"ChartVersion,omitempty"`
	ContentSHA   string    `json:"contentSHA,omitempty" yaml:"contentSHA,omitempty" hcl:"contentSHA,omitempty"`
	Lifecycle    *Lifeycle `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty" hcl:"lifecycle,omitempty"`

	CAs   map[string]util.CAType   `json:"cas,omitempty" yaml:"cas,omitempty" hcl:"cas,omitempty"`
	Certs map[string]util.CertType `json:"certs,omitempty" yaml:"certs,omitempty" hcl:"certs,omitempty"`
}

Jump to

Keyboard shortcuts

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