store

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: May 14, 2020 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const TiltfileManifestName = model.TiltfileManifestName

Variables

View Source
var (
	// "up" is an interactive dev mode that watches files and resources.
	EngineModeUp = EngineMode{}

	// "apply" is a dev mode that builds and applies all resources,
	// but doesn't wait to see if they come up.
	EngineModeApply = EngineMode{Name: "apply"}

	// "CI" is a mode that builds and applies all resources,
	// waits until they come up, then exits.
	EngineModeCI = EngineMode{Name: "ci"}
)
View Source
var BuildStateClean = BuildState{}
View Source
var EmptyReducer = Reducer(func(ctx context.Context, s *EngineState, action Action) {})

Functions

func AfterOrEqual added in v0.13.5

func AfterOrEqual(a, b time.Time) bool

Helper functions for comparing times in the store. On Windows, time instants aren't monotonic, so we need to be more tolerant of equal times.

func BeforeOrEqual added in v0.13.5

func BeforeOrEqual(a, b time.Time) bool

func ClusterImageRefFromBuildResult added in v0.11.4

func ClusterImageRefFromBuildResult(r BuildResult) reference.NamedTagged

func CreateEngineStateEncoder added in v0.10.18

func CreateEngineStateEncoder(w io.Writer) *json.Encoder

func IDsForInfos added in v0.9.7

func IDsForInfos(infos []ContainerInfo) []container.ID

func LocalImageRefFromBuildResult added in v0.11.4

func LocalImageRefFromBuildResult(r BuildResult) reference.NamedTagged

func ManifestTargetEndpoints added in v0.5.0

func ManifestTargetEndpoints(mt *ManifestTarget) (endpoints []string)

func NewLogActionLogger added in v0.8.9

func NewLogActionLogger(ctx context.Context, dispatch func(action Action)) logger.Logger

func SafeGo added in v0.10.22

func SafeGo(store RStore, f func())

Execute the function from a goroutine, recovering any panics and exiting the program gracefully.

This helps tcell reset the terminal to a state where we can print the error correctly, see https://github.com/gdamore/tcell/issues/147 for more discussion.

Otherwise, a panic() would just blow up the terminal and force a reset.

func StateToView

func StateToView(s EngineState, mu *sync.RWMutex) view.View

Types

type Action

type Action interface {
	Action()
}

func AssertNoActionOfType added in v0.8.10

func AssertNoActionOfType(t testing.TB, typ reflect.Type, getActions func() []Action) Action

for use by tests (with a real channel-based store, NOT a TestingStore). Assert that we don't see an action of the given type

func WaitForAction added in v0.8.1

func WaitForAction(t testing.TB, typ reflect.Type, getActions func() []Action) Action

for use by tests (with a real channel-based store, NOT a TestingStore), to wait until an action of the specified type comes out of the given chan at some point we might want it to return the index it was found at, and then take an index, so that we can start searching from the next index

type AnalyticsNudgeSurfacedAction added in v0.8.7

type AnalyticsNudgeSurfacedAction struct{}

func (AnalyticsNudgeSurfacedAction) Action added in v0.8.7

type AnalyticsUserOptAction added in v0.10.16

type AnalyticsUserOptAction struct {
	Opt analytics.Opt
}

func (AnalyticsUserOptAction) Action added in v0.10.16

func (AnalyticsUserOptAction) Action()

type BuildResult

type BuildResult interface {
	TargetID() model.TargetID
	BuildType() model.BuildType
	Facets() []model.Facet
}

The results of a successful build.

func NewK8sDeployResult added in v0.10.5

func NewK8sDeployResult(id model.TargetID, uids []types.UID, hashes []k8s.PodTemplateSpecHash, appliedEntities []k8s.K8sEntity) BuildResult

For kubernetes deploy targets.

type BuildResultSet added in v0.5.1

type BuildResultSet map[model.TargetID]BuildResult

func MergeBuildResultsSet added in v0.10.0

func MergeBuildResultsSet(a, b BuildResultSet) BuildResultSet

func (BuildResultSet) BuildTypes added in v0.10.14

func (set BuildResultSet) BuildTypes() []model.BuildType

func (BuildResultSet) DeployedPodTemplateSpecHashes added in v0.10.16

func (set BuildResultSet) DeployedPodTemplateSpecHashes() PodTemplateSpecHashSet

func (BuildResultSet) DeployedUIDSet added in v0.10.5

func (set BuildResultSet) DeployedUIDSet() UIDSet

func (BuildResultSet) LiveUpdatedContainerIDs added in v0.10.0

func (set BuildResultSet) LiveUpdatedContainerIDs() []container.ID

func (BuildResultSet) OneAndOnlyLiveUpdatedContainerID added in v0.10.0

func (set BuildResultSet) OneAndOnlyLiveUpdatedContainerID() container.ID

Returns a container ID iff it's the only container ID in the result set. If there are multiple container IDs, we have to give up.

type BuildState

type BuildState struct {
	// The last successful build.
	LastSuccessfulResult BuildResult

	// Files changed since the last result was build.
	// This must be liberal: it's ok if this has too many files, but not ok if it has too few.
	FilesChangedSet map[string]bool

	// There are three kinds of triggers:
	//
	// 1) If a resource is in trigger_mode=TRIGGER_MODE_AUTO, then the resource auto-builds.
	//    Pressing the trigger will always do a full image build.
	//
	// 2) If a resource is in trigger_mode=TRIGGER_MODE_MANUAL and there are no pending changes,
	//    then pressing the trigger will do a full image build.
	//
	// 3) If a resource is in trigger_mode=TRIGGER_MODE_MANUAL, and there are
	//    pending changes, then pressing the trigger will do a live_update (if one
	//    is configured; otherwise, will do an image build as normal)
	//
	// This field indicates case 1 || case 2 -- i.e. that we should skip
	// live_update, and force an image build (even if there are no changed files)
	ImageBuildTriggered bool

	RunningContainers []ContainerInfo

	// If we had an error retrieving running containers
	RunningContainerError error
}

The state of the system since the last successful build. This data structure should be considered immutable. All methods that return a new BuildState should first clone the existing build state.

func NewBuildState

func NewBuildState(result BuildResult, files []string) BuildState

func (BuildState) FilesChanged

func (b BuildState) FilesChanged() []string

Return the files changed since the last result in sorted order. The sorting helps ensure that this is deterministic, both for testing and for deterministic builds.

func (BuildState) HasLastSuccessfulResult added in v0.11.4

func (b BuildState) HasLastSuccessfulResult() bool

func (BuildState) IsEmpty

func (b BuildState) IsEmpty() bool

A build state is empty if there are no previous results.

func (BuildState) LastLocalImageAsString added in v0.11.4

func (b BuildState) LastLocalImageAsString() string

func (BuildState) NeedsImageBuild added in v0.7.7

func (b BuildState) NeedsImageBuild() bool

Whether the image represented by this state needs to be built. If the image has already been built, and no files have been changed since then, then we can re-use the previous result.

func (BuildState) OneContainerInfo added in v0.9.7

func (b BuildState) OneContainerInfo() ContainerInfo

NOTE(maia): Interim method to replicate old behavior where every BuildState had a single ContainerInfo

func (BuildState) WithImageBuildTriggered added in v0.12.6

func (b BuildState) WithImageBuildTriggered(isImageBuildTrigger bool) BuildState

func (BuildState) WithRunningContainerError added in v0.10.15

func (b BuildState) WithRunningContainerError(err error) BuildState

func (BuildState) WithRunningContainers added in v0.9.7

func (b BuildState) WithRunningContainers(cInfos []ContainerInfo) BuildState

type BuildStateSet added in v0.5.1

type BuildStateSet map[model.TargetID]BuildState

func (BuildStateSet) Empty added in v0.5.1

func (set BuildStateSet) Empty() bool

func (BuildStateSet) FilesChanged added in v0.5.1

func (set BuildStateSet) FilesChanged() []string

type BuildStatus added in v0.5.1

type BuildStatus struct {
	// Stores the times of all the pending changes,
	// so we can prioritize the oldest one first.
	// This map is mutable.
	PendingFileChanges map[string]time.Time

	LastSuccessfulResult BuildResult
	LastResult           BuildResult
}

TODO(nick): This will eventually implement TargetStatus

func (BuildStatus) IsEmpty added in v0.7.7

func (s BuildStatus) IsEmpty() bool

type CloudStatus added in v0.12.10

type CloudStatus struct {
	Username                         string
	TeamName                         string
	TokenKnownUnregistered           bool // to distinguish whether an empty Username means "we haven't checked" or "we checked and the token isn't registered"
	WaitingForStatusPostRegistration bool
}

type Container added in v0.9.6

type Container struct {
	Name     container.Name
	ID       container.ID
	Ports    []int32
	Ready    bool
	Running  bool
	ImageRef reference.Named
	Restarts int
	Status   model.RuntimeStatus
}

func (Container) Empty added in v0.9.6

func (c Container) Empty() bool

type ContainerInfo added in v0.7.7

type ContainerInfo struct {
	PodID         k8s.PodID
	ContainerID   container.ID
	ContainerName container.Name
	Namespace     k8s.Namespace
}

Information describing a single running & ready container

func AllRunningContainers added in v0.10.0

func AllRunningContainers(mt *ManifestTarget) []ContainerInfo

func RunningContainersForDC added in v0.9.7

func RunningContainersForDC(state dockercompose.State) []ContainerInfo

func RunningContainersForTargetForOnePod added in v0.10.0

func RunningContainersForTargetForOnePod(iTarget model.ImageTarget, runtimeState K8sRuntimeState) ([]ContainerInfo, error)

If all containers running the given image are ready, returns info for them. (If this image is running on multiple pods, return an error.)

func (ContainerInfo) Empty added in v0.9.7

func (c ContainerInfo) Empty() bool

type DockerComposeBuildResult added in v0.10.14

type DockerComposeBuildResult struct {

	// The ID of the container that Docker Compose created.
	//
	// When we deploy a Docker Compose service, we wait synchronously for the
	// container to start. Note that this is a different concurrency model than
	// we use for Kubernetes, where the pods appear some time later via an
	// asynchronous event.
	DockerComposeContainerID container.ID

	// The initial state of the container.
	ContainerState *dockertypes.ContainerState
	// contains filtered or unexported fields
}

func NewDockerComposeDeployResult added in v0.10.0

func NewDockerComposeDeployResult(id model.TargetID, containerID container.ID, state *dockertypes.ContainerState) DockerComposeBuildResult

For docker compose deploy targets.

func (DockerComposeBuildResult) BuildType added in v0.10.14

func (DockerComposeBuildResult) Facets added in v0.10.16

func (r DockerComposeBuildResult) Facets() []model.Facet

func (DockerComposeBuildResult) TargetID added in v0.10.14

type EngineMode added in v0.12.11

type EngineMode struct {
	Name string
}

Defines different executions modes for running Tilt, and deciding when to exit.

func (EngineMode) IsApplyMode added in v0.12.11

func (m EngineMode) IsApplyMode() bool

func (EngineMode) IsCIMode added in v0.12.11

func (m EngineMode) IsCIMode() bool

func (EngineMode) WatchesFiles added in v0.12.11

func (m EngineMode) WatchesFiles() bool

func (EngineMode) WatchesRuntime added in v0.12.11

func (m EngineMode) WatchesRuntime() bool

type EngineState

type EngineState struct {
	TiltBuildInfo model.TiltBuild
	TiltStartTime time.Time

	// saved so that we can render in order
	ManifestDefinitionOrder []model.ManifestName

	// TODO(nick): This will eventually be a general Target index.
	ManifestTargets map[model.ManifestName]*ManifestTarget

	CurrentlyBuilding map[model.ManifestName]bool
	EngineMode        EngineMode

	// For synchronizing BuildController -- wait until engine records all builds started
	// so far before starting another build
	StartedBuildCount int

	// How many builds have been completed (pass or fail) since starting tilt
	CompletedBuildCount int

	MaxParallelUpdates int

	FatalError error

	HUDEnabled bool

	// The user has indicated they want to exit
	UserExited bool

	// We recovered from a panic(). We need to clean up the RTY and print the error.
	PanicExited error

	// Normal process termination. Either Tilt completed all its work,
	// or it determined that it was unable to complete the work it was assigned.
	//
	// Note that ExitSignal/ExitError is never triggered in normal
	// 'tilt up`/dev mode. It's more for CI modes and tilt up --watch=false modes.
	//
	// We don't provide the ability to customize exit codes. Either the
	// process exited successfully, or with an error. In the future, we might
	// add the ability to put an exit code in the error.
	ExitSignal bool
	ExitError  error

	// All logs in Tilt, stored in a structured format.
	LogStore *logstore.LogStore `testdiff:"ignore"`

	TiltfilePath             string
	ConfigFiles              []string
	TiltIgnoreContents       string
	PendingConfigFileChanges map[string]time.Time

	TriggerQueue []model.ManifestName

	IsProfiling bool

	TiltfileState ManifestState

	SuggestedTiltVersion string
	VersionSettings      model.VersionSettings

	// Analytics Info
	AnalyticsEnvOpt        analytics.Opt
	AnalyticsUserOpt       analytics.Opt // changes to this field will propagate into the TiltAnalytics subscriber + we'll record them as user choice
	AnalyticsTiltfileOpt   analytics.Opt // Set by the Tiltfile. Overrides the UserOpt.
	AnalyticsNudgeSurfaced bool          // this flag is set the first time we show the analytics nudge to the user.

	Features map[string]bool

	Secrets model.SecretSet

	CloudAddress string
	Token        token.Token
	TeamID       string

	CloudStatus CloudStatus

	DockerPruneSettings model.DockerPruneSettings

	TelemetrySettings model.TelemetrySettings

	UserConfigState model.UserConfigState
}

func NewState

func NewState() *EngineState

func (*EngineState) AnalyticsEffectiveOpt added in v0.10.16

func (e *EngineState) AnalyticsEffectiveOpt() analytics.Opt

Merge analytics opt-in status from different sources. The Tiltfile opt-in takes precedence over the user opt-in.

func (*EngineState) AvailableBuildSlots added in v0.11.0

func (e *EngineState) AvailableBuildSlots() int

func (*EngineState) BuildStatus added in v0.5.1

func (e *EngineState) BuildStatus(id model.TargetID) BuildStatus

func (EngineState) DockerComposeConfigPath added in v0.4.1

func (s EngineState) DockerComposeConfigPath() []string

DockerComposeConfigPath returns the path to the docker-compose yaml file of any docker-compose manifests on this EngineState. NOTE(maia): current assumption is only one d-c.yaml per run, so we take the path from the first d-c manifest we see.

func (*EngineState) HasDockerBuild added in v0.10.14

func (e *EngineState) HasDockerBuild() bool

func (*EngineState) InitialBuildsCompleted added in v0.10.18

func (e *EngineState) InitialBuildsCompleted() bool

func (*EngineState) IsCurrentlyBuilding added in v0.10.26

func (e *EngineState) IsCurrentlyBuilding(name model.ManifestName) bool

func (EngineState) IsEmpty added in v0.4.1

func (e EngineState) IsEmpty() bool

func (EngineState) LastTiltfileError added in v0.2.0

func (e EngineState) LastTiltfileError() error

func (EngineState) Manifest added in v0.5.0

func (e EngineState) Manifest(mn model.ManifestName) (model.Manifest, bool)

func (*EngineState) ManifestInTriggerQueue added in v0.10.18

func (e *EngineState) ManifestInTriggerQueue(mn model.ManifestName) bool

func (*EngineState) ManifestNamesForTargetID added in v0.7.7

func (e *EngineState) ManifestNamesForTargetID(id model.TargetID) []model.ManifestName

func (EngineState) ManifestState added in v0.5.0

func (e EngineState) ManifestState(mn model.ManifestName) (*ManifestState, bool)

func (EngineState) ManifestStates

func (e EngineState) ManifestStates() []*ManifestState

Returns ManifestStates in a stable order

func (EngineState) Manifests

func (e EngineState) Manifests() []model.Manifest

Returns Manifests in a stable order

func (EngineState) RelativeTiltfilePath added in v0.4.1

func (e EngineState) RelativeTiltfilePath() (string, error)

func (EngineState) Targets added in v0.5.0

func (e EngineState) Targets() []*ManifestTarget

Returns ManifestTargets in a stable order

func (*EngineState) UpsertManifestTarget added in v0.5.0

func (e *EngineState) UpsertManifestTarget(mt *ManifestTarget)

type ErrorAction added in v0.7.10

type ErrorAction struct {
	Error error
}

func NewErrorAction added in v0.7.10

func NewErrorAction(err error) ErrorAction

func (ErrorAction) Action added in v0.7.10

func (ErrorAction) Action()

type ImageBuildResult added in v0.10.14

type ImageBuildResult struct {

	// TODO(maia): it would make the most sense for the ImageBuildResult to know what it BUILT, and for us
	//   to calculate the ClusterRef (if different from LocalRef) when we have to inject it, but
	//   storing all the info on ImageBuildResult for now was the fastest/safest way to ship this.
	// Note: image tag is derived from a content-addressable digest.
	ImageLocalRef   reference.NamedTagged // built image, as referenced from outside the cluster (in Dockerfile, docker push etc.)
	ImageClusterRef reference.NamedTagged // built image, as referenced from the cluster (in K8s YAML, etc.)
	// contains filtered or unexported fields
}

func NewImageBuildResult added in v0.7.8

func NewImageBuildResult(id model.TargetID, localRef, clusterRef reference.NamedTagged) ImageBuildResult

For image targets.

func NewImageBuildResultSingleRef added in v0.11.4

func NewImageBuildResultSingleRef(id model.TargetID, ref reference.NamedTagged) ImageBuildResult

When localRef == ClusterRef

func (ImageBuildResult) BuildType added in v0.10.14

func (r ImageBuildResult) BuildType() model.BuildType

func (ImageBuildResult) Facets added in v0.10.16

func (r ImageBuildResult) Facets() []model.Facet

func (ImageBuildResult) TargetID added in v0.10.14

func (r ImageBuildResult) TargetID() model.TargetID

type K8sBuildResult added in v0.10.14

type K8sBuildResult struct {

	// The UIDs that we deployed to a Kubernetes cluster.
	DeployedUIDs []types.UID

	// Hashes of the pod template specs that we deployed to a Kubernetes cluster.
	PodTemplateSpecHashes []k8s.PodTemplateSpecHash

	AppliedEntitiesText string
	// contains filtered or unexported fields
}

func (K8sBuildResult) BuildType added in v0.10.14

func (r K8sBuildResult) BuildType() model.BuildType

func (K8sBuildResult) Facets added in v0.10.16

func (r K8sBuildResult) Facets() []model.Facet

func (K8sBuildResult) TargetID added in v0.10.14

func (r K8sBuildResult) TargetID() model.TargetID

type K8sEventAction added in v0.8.10

type K8sEventAction struct {
	Event        *v1.Event
	ManifestName model.ManifestName
}

func NewK8sEventAction added in v0.8.10

func NewK8sEventAction(event *v1.Event, manifestName model.ManifestName) K8sEventAction

func (K8sEventAction) Action added in v0.8.10

func (K8sEventAction) Action()

func (K8sEventAction) ToLogAction added in v0.8.10

func (kEvt K8sEventAction) ToLogAction(mn model.ManifestName) LogAction

type K8sRuntimeState added in v0.10.5

type K8sRuntimeState struct {
	// The ancestor that we match pods against to associate them with this manifest.
	// If we deployed Pod YAML, this will be the Pod UID.
	// In many cases, this will be a Deployment UID.
	PodAncestorUID types.UID

	Pods                           map[k8s.PodID]*Pod
	LBs                            map[k8s.ServiceName]*url.URL
	DeployedUIDSet                 UIDSet                 // for the most recent successful deploy
	DeployedPodTemplateSpecHashSet PodTemplateSpecHashSet // for the most recent successful deploy

	LastReadyOrSucceededTime time.Time

	// NOTE(nick): This is a dumb hack to handle the UnresourcedYAML
	// case. Long-term, a better way to handle this would be to watch
	// all K8s resources we deploy and have some notion of health for
	// each type.
	IsUnresourced bool
}

func NewK8sRuntimeState added in v0.10.5

func NewK8sRuntimeState(mn model.ManifestName, pods ...Pod) K8sRuntimeState

func (K8sRuntimeState) ContainsID added in v0.10.5

func (s K8sRuntimeState) ContainsID(id k8s.PodID) bool

func (K8sRuntimeState) HasEverBeenReadyOrSucceeded added in v0.10.26

func (s K8sRuntimeState) HasEverBeenReadyOrSucceeded() bool

func (K8sRuntimeState) HasOKPodTemplateSpecHash added in v0.10.19

func (s K8sRuntimeState) HasOKPodTemplateSpecHash(pod *v1.Pod) bool

func (K8sRuntimeState) MostRecentPod added in v0.10.5

func (s K8sRuntimeState) MostRecentPod() Pod

Get the "most recent pod" from the K8sRuntimeState. For most users, we believe there will be only one pod per manifest. So most of this time, this will return the only pod. And in other cases, it will return a reasonable, consistent default.

func (K8sRuntimeState) PodLen added in v0.10.5

func (s K8sRuntimeState) PodLen() int

func (K8sRuntimeState) PodList added in v0.10.5

func (s K8sRuntimeState) PodList() []Pod

func (K8sRuntimeState) RuntimeState added in v0.10.5

func (K8sRuntimeState) RuntimeState()

func (K8sRuntimeState) RuntimeStatus added in v0.12.11

func (s K8sRuntimeState) RuntimeStatus() model.RuntimeStatus

func (K8sRuntimeState) RuntimeStatusError added in v0.12.11

func (s K8sRuntimeState) RuntimeStatusError() error

type LiveUpdateBuildResult added in v0.10.14

type LiveUpdateBuildResult struct {

	// The ID of the container(s) that we live-updated in-place.
	//
	// The contents of the container have diverged from the image it's built on,
	// so we need to keep track of that.
	LiveUpdatedContainerIDs []container.ID
	// contains filtered or unexported fields
}

func NewLiveUpdateBuildResult added in v0.10.0

func NewLiveUpdateBuildResult(id model.TargetID, containerIDs []container.ID) LiveUpdateBuildResult

For in-place container updates.

func (LiveUpdateBuildResult) BuildType added in v0.10.14

func (r LiveUpdateBuildResult) BuildType() model.BuildType

func (LiveUpdateBuildResult) Facets added in v0.10.16

func (r LiveUpdateBuildResult) Facets() []model.Facet

func (LiveUpdateBuildResult) TargetID added in v0.10.14

func (r LiveUpdateBuildResult) TargetID() model.TargetID

type LocalBuildResult added in v0.10.14

type LocalBuildResult struct {
	// contains filtered or unexported fields
}

func NewLocalBuildResult added in v0.10.14

func NewLocalBuildResult(id model.TargetID) LocalBuildResult

func (LocalBuildResult) BuildType added in v0.10.14

func (r LocalBuildResult) BuildType() model.BuildType

func (LocalBuildResult) Facets added in v0.10.16

func (r LocalBuildResult) Facets() []model.Facet

func (LocalBuildResult) TargetID added in v0.10.14

func (r LocalBuildResult) TargetID() model.TargetID

type LocalRuntimeState added in v0.10.9

type LocalRuntimeState struct {
	Status                  model.RuntimeStatus
	HasSucceededAtLeastOnce bool
	PID                     int
	SpanID                  model.LogSpanID
}

func (LocalRuntimeState) HasEverBeenReadyOrSucceeded added in v0.10.26

func (l LocalRuntimeState) HasEverBeenReadyOrSucceeded() bool

func (LocalRuntimeState) RuntimeState added in v0.10.9

func (LocalRuntimeState) RuntimeState()

func (LocalRuntimeState) RuntimeStatus added in v0.12.11

func (l LocalRuntimeState) RuntimeStatus() model.RuntimeStatus

func (LocalRuntimeState) RuntimeStatusError added in v0.12.11

func (l LocalRuntimeState) RuntimeStatusError() error

type LogAction added in v0.8.1

type LogAction struct {
	// contains filtered or unexported fields
}

func NewGlobalLogAction added in v0.11.2

func NewGlobalLogAction(level logger.Level, b []byte) LogAction

func NewLogAction added in v0.11.2

func NewLogAction(mn model.ManifestName, spanID logstore.SpanID, level logger.Level, fields logger.Fields, b []byte) LogAction

func (LogAction) Action added in v0.8.1

func (LogAction) Action()

func (LogAction) Fields added in v0.11.2

func (le LogAction) Fields() logger.Fields

func (LogAction) Level added in v0.11.2

func (le LogAction) Level() logger.Level

func (LogAction) ManifestName added in v0.11.2

func (le LogAction) ManifestName() model.ManifestName

func (LogAction) Message added in v0.11.2

func (le LogAction) Message() []byte

func (LogAction) SpanID added in v0.11.2

func (le LogAction) SpanID() logstore.SpanID

func (LogAction) String added in v0.11.2

func (le LogAction) String() string

func (LogAction) Time added in v0.11.2

func (le LogAction) Time() time.Time

type LogActionsFlag added in v0.2.0

type LogActionsFlag bool

type ManifestState

type ManifestState struct {
	Name model.ManifestName

	BuildStatuses map[model.TargetID]*BuildStatus
	RuntimeState  RuntimeState

	PendingManifestChange time.Time

	// The current build
	CurrentBuild model.BuildRecord

	LastSuccessfulDeployTime time.Time

	// The last `BuildHistoryLimit` builds. The most recent build is first in the slice.
	BuildHistory []model.BuildRecord

	// The container IDs that we've run a LiveUpdate on, if any. Their contents have
	// diverged from the image they are built on. If these container don't appear on
	// the pod, we've lost that state and need to rebuild.
	LiveUpdatedContainerIDs map[container.ID]bool

	// We detected stale code and are currently doing an image build
	NeedsRebuildFromCrash bool

	// If a pod had to be killed because it was crashing, we keep the old log
	// around for a little while so we can show it in the UX.
	CrashLog model.Log

	// If this manifest was changed, which config files led to the most recent change in manifest definition
	ConfigFilesThatCausedChange []string

	// If the build was manually triggered, record why.
	TriggerReason model.BuildReason
}

func (*ManifestState) ActiveBuild added in v0.4.3

func (ms *ManifestState) ActiveBuild() model.BuildRecord

func (*ManifestState) AddCompletedBuild added in v0.4.1

func (ms *ManifestState) AddCompletedBuild(bs model.BuildRecord)

func (*ManifestState) BuildStatus added in v0.5.1

func (ms *ManifestState) BuildStatus(id model.TargetID) BuildStatus

func (*ManifestState) DCRuntimeState added in v0.10.5

func (ms *ManifestState) DCRuntimeState() dockercompose.State

func (*ManifestState) GetOrCreateK8sRuntimeState added in v0.10.5

func (ms *ManifestState) GetOrCreateK8sRuntimeState() K8sRuntimeState

func (*ManifestState) GetOrCreateLocalRuntimeState added in v0.11.0

func (ms *ManifestState) GetOrCreateLocalRuntimeState() LocalRuntimeState

func (*ManifestState) HasPendingChanges added in v0.4.1

func (ms *ManifestState) HasPendingChanges() (bool, time.Time)

Whether changes have been made to this Manifest's synced files or config since the last build.

Returns: bool: whether changes have been made Time: the time of the earliest change

func (*ManifestState) HasPendingChangesBeforeOrEqual added in v0.13.5

func (ms *ManifestState) HasPendingChangesBeforeOrEqual(highWaterMark time.Time) (bool, time.Time)

Like HasPendingChanges, but relative to a particular time.

func (*ManifestState) HasPendingFileChanges added in v0.7.3

func (ms *ManifestState) HasPendingFileChanges() bool

func (*ManifestState) IsBuilding added in v0.10.26

func (ms *ManifestState) IsBuilding() bool

func (*ManifestState) IsDC added in v0.4.1

func (ms *ManifestState) IsDC() bool

func (*ManifestState) IsK8s added in v0.10.5

func (ms *ManifestState) IsK8s() bool

func (*ManifestState) K8sRuntimeState added in v0.10.5

func (ms *ManifestState) K8sRuntimeState() K8sRuntimeState

func (*ManifestState) LastBuild

func (ms *ManifestState) LastBuild() model.BuildRecord

func (*ManifestState) LocalRuntimeState added in v0.11.0

func (ms *ManifestState) LocalRuntimeState() LocalRuntimeState

func (*ManifestState) MostRecentPod added in v0.2.0

func (ms *ManifestState) MostRecentPod() Pod

func (*ManifestState) MutableBuildStatus added in v0.5.1

func (ms *ManifestState) MutableBuildStatus(id model.TargetID) *BuildStatus

func (*ManifestState) PodWithID added in v0.10.19

func (ms *ManifestState) PodWithID(pid k8s.PodID) (*Pod, bool)

func (*ManifestState) StartedFirstBuild added in v0.2.0

func (ms *ManifestState) StartedFirstBuild() bool

func (*ManifestState) TargetID added in v0.4.3

func (ms *ManifestState) TargetID() model.TargetID

type ManifestTarget added in v0.5.0

type ManifestTarget struct {
	Manifest model.Manifest
	State    *ManifestState
}

func NewManifestTarget added in v0.5.0

func NewManifestTarget(m model.Manifest) *ManifestTarget

func (*ManifestTarget) Facets added in v0.10.16

func (t *ManifestTarget) Facets(secrets model.SecretSet) []model.Facet

func (*ManifestTarget) NextBuildReason added in v0.10.19

func (mt *ManifestTarget) NextBuildReason() model.BuildReason

func (ManifestTarget) Spec added in v0.5.0

func (t ManifestTarget) Spec() model.TargetSpec

func (ManifestTarget) Status added in v0.5.0

func (t ManifestTarget) Status() model.TargetStatus

type PanicAction added in v0.10.22

type PanicAction struct {
	Err error
}

func (PanicAction) Action added in v0.10.22

func (PanicAction) Action()

type Pod

type Pod struct {
	PodID     k8s.PodID
	Namespace k8s.Namespace
	StartedAt time.Time
	Status    string
	Phase     v1.PodPhase

	// Error messages from the pod state if it's in an error state.
	StatusMessages []string

	// Set when we get ready to replace a pod. We may do the update in-place.
	UpdateStartTime time.Time

	// If a pod is being deleted, Kubernetes marks it as Running
	// until it actually gets removed.
	Deleting bool

	HasSynclet bool

	Containers     []Container
	InitContainers []Container

	// We want to show the user # of restarts since some baseline time
	// i.e. Total Restarts - BaselineRestarts
	BaselineRestarts int

	Conditions []v1.PodCondition

	SpanID model.LogSpanID
}

func (Pod) AllContainerPorts added in v0.10.0

func (p Pod) AllContainerPorts() []int32

func (Pod) AllContainerRestarts added in v0.10.0

func (p Pod) AllContainerRestarts() int

func (Pod) AllContainers added in v0.13.1

func (p Pod) AllContainers() []Container

func (Pod) AllContainersReady added in v0.10.0

func (p Pod) AllContainersReady() bool

func (Pod) Empty added in v0.2.0

func (p Pod) Empty() bool

func (Pod) VisibleContainerRestarts added in v0.10.8

func (p Pod) VisibleContainerRestarts() int

type PodResetRestartsAction added in v0.10.8

type PodResetRestartsAction struct {
	PodID           k8s.PodID
	ManifestName    model.ManifestName
	VisibleRestarts int
}

The user can indicate "yes, I know the pod restarted N times, stop showing me"

func NewPodResetRestartsAction added in v0.10.8

func NewPodResetRestartsAction(podID k8s.PodID, mn model.ManifestName, visibleRestarts int) PodResetRestartsAction

func (PodResetRestartsAction) Action added in v0.10.8

func (PodResetRestartsAction) Action()

type PodTemplateSpecHashSet added in v0.10.16

type PodTemplateSpecHashSet map[k8s.PodTemplateSpecHash]bool

func NewPodTemplateSpecHashSet added in v0.10.16

func NewPodTemplateSpecHashSet() PodTemplateSpecHashSet

func (PodTemplateSpecHashSet) Add added in v0.10.16

func (PodTemplateSpecHashSet) Contains added in v0.10.16

type RStore added in v0.2.0

type RStore interface {
	Dispatch(action Action)
	RLockState() EngineState
	RUnlockState()
	StateMutex() *sync.RWMutex
}

Read-only store

type Reducer added in v0.1.0

type Reducer func(ctx context.Context, engineState *EngineState, action Action)

type RuntimeState added in v0.10.5

type RuntimeState interface {
	RuntimeState()

	// There are two types of resource dependencies:
	// - servers (Deployments) where what's important is that the server is running
	// - tasks (Jobs, local resources) where what's important is that the job completed
	// Currently, we don't try to distinguish between these two cases.
	//
	// In the future, it might make sense to check "IsBlocking()" or something,
	// and alter the behavior based on whether the underlying resource is a server
	// or a task.
	HasEverBeenReadyOrSucceeded() bool

	RuntimeStatus() model.RuntimeStatus

	// If the runtime status is in Error mode,
	// RuntimeStatusError() should report a reason.
	RuntimeStatusError() error
}

type SetUpper added in v0.8.2

type SetUpper interface {
	SetUp(ctx context.Context)
}

Some subscribers need to do SetUp or TearDown. Both hold the subscriber lock, so should return quickly.

type Store

type Store struct {
	// contains filtered or unexported fields
}

A central state store, modeled after the Reactive programming UX pattern. Terminology is borrowed liberally from Redux. These docs in particular are helpful: https://redux.js.org/introduction/threeprinciples https://redux.js.org/basics

func NewStore

func NewStore(reducer Reducer, logActions LogActionsFlag) *Store

func NewStoreWithFakeReducer added in v0.13.4

func NewStoreWithFakeReducer() (st *Store, getActions func() []Action)

Returns a Store with a fake reducer that saves observed actions and makes them available via the return value `getActions`.

Tests should only use this if they: 1) want to test the Store itself, or 2) want to test subscribers with the particular async behavior of a real Store Otherwise, use NewTestingStore().

func (*Store) AddSubscriber

func (s *Store) AddSubscriber(ctx context.Context, sub Subscriber)

func (*Store) Close

func (s *Store) Close()

func (*Store) Dispatch

func (s *Store) Dispatch(action Action)

func (*Store) LockMutableStateForTesting added in v0.1.0

func (s *Store) LockMutableStateForTesting() *EngineState

func (*Store) Loop added in v0.1.0

func (s *Store) Loop(ctx context.Context) error

func (*Store) NotifySubscribers

func (s *Store) NotifySubscribers(ctx context.Context)

Sends messages to all the subscribers asynchronously.

func (*Store) RLockState

func (s *Store) RLockState() EngineState

TODO(nick): Clone the state to ensure it's not mutated. For now, we use RW locks to simulate the same behavior, but the onus is on the caller to RUnlockState.

func (*Store) RUnlockState

func (s *Store) RUnlockState()

func (*Store) RemoveSubscriber added in v0.4.1

func (s *Store) RemoveSubscriber(ctx context.Context, sub Subscriber) error

func (*Store) SetUpSubscribersForTesting added in v0.8.2

func (s *Store) SetUpSubscribersForTesting(ctx context.Context)

func (*Store) StateMutex added in v0.10.24

func (s *Store) StateMutex() *sync.RWMutex

func (*Store) UnlockMutableState

func (s *Store) UnlockMutableState()

type Subscriber

type Subscriber interface {
	OnChange(ctx context.Context, st RStore)
}

A subscriber is notified whenever the state changes.

Subscribers do not need to be thread-safe. The Store will only call OnChange for a given subscriber when the last call completes.

Subscribers are only allowed to read state. If they want to modify state, they should call store.Dispatch()

type SubscriberLifecycle added in v0.7.11

type SubscriberLifecycle interface {
	SetUpper
	TearDowner
}

Convenience interface for subscriber fulfilling both SetUpper and TearDowner

type TearDowner added in v0.8.2

type TearDowner interface {
	TearDown(ctx context.Context)
}

type TestingStore added in v0.2.0

type TestingStore struct {
	// contains filtered or unexported fields
}

func NewTestingStore added in v0.2.0

func NewTestingStore() *TestingStore

func (*TestingStore) Actions added in v0.2.0

func (s *TestingStore) Actions() []Action

func (*TestingStore) AssertNoErrorActions added in v0.13.4

func (s *TestingStore) AssertNoErrorActions(t testing.TB)

func (*TestingStore) ClearActions added in v0.11.0

func (s *TestingStore) ClearActions()

func (*TestingStore) Dispatch added in v0.2.0

func (s *TestingStore) Dispatch(action Action)

func (*TestingStore) LockMutableStateForTesting added in v0.13.4

func (s *TestingStore) LockMutableStateForTesting() *EngineState

func (*TestingStore) RLockState added in v0.2.0

func (s *TestingStore) RLockState() EngineState

func (*TestingStore) RUnlockState added in v0.2.0

func (s *TestingStore) RUnlockState()

func (*TestingStore) SetState added in v0.2.0

func (s *TestingStore) SetState(state EngineState)

func (*TestingStore) StateMutex added in v0.10.24

func (s *TestingStore) StateMutex() *sync.RWMutex

func (*TestingStore) UnlockMutableState added in v0.13.4

func (s *TestingStore) UnlockMutableState()

func (*TestingStore) WithState added in v0.12.11

func (s *TestingStore) WithState(f func(state *EngineState))

type TiltCloudStatusReceivedAction added in v0.12.10

type TiltCloudStatusReceivedAction struct {
	Found                    bool
	Username                 string
	TeamName                 string
	IsPostRegistrationLookup bool
	SuggestedTiltVersion     string
}

func (TiltCloudStatusReceivedAction) Action added in v0.12.10

type UIDSet added in v0.10.5

type UIDSet map[types.UID]bool

func NewUIDSet added in v0.10.5

func NewUIDSet() UIDSet

func (UIDSet) Add added in v0.10.5

func (s UIDSet) Add(uids ...types.UID)

func (UIDSet) Contains added in v0.10.5

func (s UIDSet) Contains(uid types.UID) bool

type UserStartedTiltCloudRegistrationAction added in v0.10.7

type UserStartedTiltCloudRegistrationAction struct{}

func (UserStartedTiltCloudRegistrationAction) Action added in v0.10.7

type YAMLManifestState added in v0.1.0

type YAMLManifestState struct {
	HasBeenDeployed bool

	CurrentApplyStartTime   time.Time
	LastError               error
	LastApplyFinishTime     time.Time
	LastSuccessfulApplyTime time.Time
	LastApplyStartTime      time.Time
}

func NewYAMLManifestState added in v0.1.0

func NewYAMLManifestState() *YAMLManifestState

func (*YAMLManifestState) ActiveBuild added in v0.4.3

func (s *YAMLManifestState) ActiveBuild() model.BuildRecord

func (*YAMLManifestState) LastBuild added in v0.4.3

func (s *YAMLManifestState) LastBuild() model.BuildRecord

func (*YAMLManifestState) TargetID added in v0.4.3

func (s *YAMLManifestState) TargetID() model.TargetID

Jump to

Keyboard shortcuts

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