Documentation ¶
Index ¶
- Variables
- func ManifestTargetEndpoints(mt *ManifestTarget) (endpoints []string)
- func StateToView(s EngineState) view.View
- type Action
- type BuildResult
- type BuildResultSet
- type BuildState
- func (b BuildState) FilesChanged() []string
- func (b BuildState) FilesChangedSinceLastResultImage() ([]string, error)
- func (b BuildState) HasImage() bool
- func (b BuildState) IsEmpty() bool
- func (b BuildState) LastImageAsString() string
- func (b BuildState) NeedsImageBuild() bool
- func (b BuildState) WithDeployTarget(d DeployInfo) BuildState
- type BuildStateSet
- type BuildStatus
- type ContainerInfo
- type DeployInfo
- type DirtyBit
- type DirtyStartToken
- type EngineState
- func (e *EngineState) BuildStatus(id model.TargetID) BuildStatus
- func (s EngineState) DockerComposeConfigPath() string
- func (e EngineState) IsEmpty() bool
- func (e EngineState) LastTiltfileError() error
- func (e EngineState) Manifest(mn model.ManifestName) (model.Manifest, bool)
- func (e *EngineState) ManifestNamesForTargetID(id model.TargetID) []model.ManifestName
- func (e EngineState) ManifestState(mn model.ManifestName) (*ManifestState, bool)
- func (e EngineState) ManifestStates() []*ManifestState
- func (e EngineState) Manifests() []model.Manifest
- func (e EngineState) RelativeTiltfilePath() (string, error)
- func (e EngineState) Targets() []*ManifestTarget
- func (e *EngineState) UpsertManifestTarget(mt *ManifestTarget)
- type ErrorAction
- type LogAction
- type LogActionsFlag
- type LogEvent
- type ManifestState
- func (ms *ManifestState) ActiveBuild() model.BuildRecord
- func (ms *ManifestState) AddCompletedBuild(bs model.BuildRecord)
- func (ms *ManifestState) BuildStatus(id model.TargetID) BuildStatus
- func (ms *ManifestState) DCResourceState() dockercompose.State
- func (ms *ManifestState) HasPendingChanges() (bool, time.Time)
- func (ms *ManifestState) HasPendingChangesBefore(highWaterMark time.Time) (bool, time.Time)
- func (ms *ManifestState) HasPendingFileChanges() bool
- func (ms *ManifestState) IsDC() bool
- func (ms *ManifestState) IsPendingTime(t time.Time) bool
- func (ms *ManifestState) LastBuild() model.BuildRecord
- func (ms *ManifestState) MostRecentPod() Pod
- func (ms *ManifestState) MutableBuildStatus(id model.TargetID) *BuildStatus
- func (ms *ManifestState) NextBuildReason() model.BuildReason
- func (ms *ManifestState) StartedFirstBuild() bool
- func (ms *ManifestState) TargetID() model.TargetID
- type ManifestTarget
- type Pod
- type PodSet
- type RStore
- type Reducer
- type ResourceState
- type Store
- func (s *Store) AddSubscriber(sub Subscriber)
- func (s *Store) Close()
- func (s *Store) Dispatch(action Action)
- func (s *Store) LockMutableStateForTesting() *EngineState
- func (s *Store) Loop(ctx context.Context) error
- func (s *Store) NotifySubscribers(ctx context.Context)
- func (s *Store) RLockState() EngineState
- func (s *Store) RUnlockState()
- func (s *Store) RemoveSubscriber(ctx context.Context, sub Subscriber) error
- func (s *Store) UnlockMutableState()
- type Subscriber
- type SubscriberLifecycle
- type TestingStore
- type YAMLManifestState
Constants ¶
This section is empty.
Variables ¶
var BuildStateClean = BuildState{}
var EmptyReducer = Reducer(func(ctx context.Context, s *EngineState, action Action) {})
Functions ¶
func ManifestTargetEndpoints ¶ added in v0.5.0
func ManifestTargetEndpoints(mt *ManifestTarget) (endpoints []string)
func StateToView ¶
func StateToView(s EngineState) view.View
Types ¶
type Action ¶
type Action interface {
Action()
}
func WaitForAction ¶ added in v0.8.1
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 BuildResult ¶
type BuildResult struct { // The image target that this built. TargetID model.TargetID // The name+tag of the image that the pod is running. // // The tag is derived from a content-addressable digest. Image reference.NamedTagged // If this build was a container build, containerID we built on top of ContainerID container.ID // Some of our build engines replace the files in-place, rather // than building a new image. This captures how much the code // running on-pod has diverged from the original image. FilesReplacedSet map[string]bool }
The results of a successful build.
func NewContainerBuildResult ¶ added in v0.7.11
func NewContainerBuildResult(id model.TargetID, containerID container.ID) BuildResult
For docker-compose deploys that don't have any built images.
func NewImageBuildResult ¶ added in v0.7.11
func NewImageBuildResult(id model.TargetID, image reference.NamedTagged) BuildResult
For image targets. The container id will be added later.
func (BuildResult) HasImage ¶
func (b BuildResult) HasImage() bool
func (BuildResult) IsEmpty ¶
func (b BuildResult) IsEmpty() bool
func (BuildResult) ShallowCloneForContainerUpdate ¶
func (b BuildResult) ShallowCloneForContainerUpdate(filesReplacedSet map[string]bool) BuildResult
Clone the build result and add new replaced files. Does not do a deep clone of the underlying entities.
type BuildResultSet ¶ added in v0.5.1
type BuildResultSet map[model.TargetID]BuildResult
func (BuildResultSet) OneAndOnlyContainerID ¶ added in v0.7.11
func (set BuildResultSet) OneAndOnlyContainerID() 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. LastResult 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 DeployInfo DeployInfo }
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) FilesChangedSinceLastResultImage ¶
func (b BuildState) FilesChangedSinceLastResultImage() ([]string, error)
Return the files changed since the last result's image in sorted order. The sorting helps ensure that this is deterministic, both for testing and for deterministic builds. Errors if there was no last result image.
func (BuildState) HasImage ¶
func (b BuildState) HasImage() bool
func (BuildState) IsEmpty ¶
func (b BuildState) IsEmpty() bool
A build state is empty if there are no previous results.
func (BuildState) LastImageAsString ¶ added in v0.4.1
func (b BuildState) LastImageAsString() string
func (BuildState) NeedsImageBuild ¶ added in v0.7.11
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) WithDeployTarget ¶ added in v0.4.3
func (b BuildState) WithDeployTarget(d DeployInfo) 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 }
TODO(nick): This will eventually implement TargetStatus
func (BuildStatus) IsEmpty ¶ added in v0.7.11
func (s BuildStatus) IsEmpty() bool
type ContainerInfo ¶ added in v0.7.11
The minimum info we need to retrieve logs for a container.
type DeployInfo ¶ added in v0.2.0
type DeployInfo struct { PodID k8s.PodID ContainerID container.ID ContainerName container.Name Namespace k8s.Namespace }
The information we need to find a ready container.
func NewDeployInfo ¶ added in v0.2.0
func NewDeployInfo(iTarget model.ImageTarget, deployID model.DeployID, podSet PodSet) DeployInfo
Check to see if there's a single, unambiguous Ready container in the given PodSet. If so, create a DeployInfo for that container.
func NewDeployInfoFromDC ¶ added in v0.7.11
func NewDeployInfoFromDC(state dockercompose.State) DeployInfo
func (DeployInfo) Empty ¶ added in v0.2.0
func (d DeployInfo) Empty() bool
type DirtyBit ¶ added in v0.8.0
type DirtyBit struct {
// contains filtered or unexported fields
}
func NewDirtyBit ¶ added in v0.8.0
func NewDirtyBit() *DirtyBit
func (*DirtyBit) FinishBuild ¶ added in v0.8.0
func (b *DirtyBit) FinishBuild(t DirtyStartToken)
func (*DirtyBit) MarkDirty ¶ added in v0.8.0
func (b *DirtyBit) MarkDirty()
Mark the bit as dirty. If the change happens and this is marked dirty later, that's usually ok. It just means IsDirty might have false positives (i.e., we do spurious builds).
func (*DirtyBit) StartBuildIfDirty ¶ added in v0.8.0
func (b *DirtyBit) StartBuildIfDirty() (DirtyStartToken, bool)
If the bit is currently marked dirty, returns a StartToken to pass to FinishBuild. Otherwise, return false.
type DirtyStartToken ¶ added in v0.8.0
type EngineState ¶
type EngineState struct { 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 model.ManifestName WatchFiles bool // How many builds were queued on startup (i.e., how many manifests there were) InitialBuildCount int // How many builds have been completed (pass or fail) since starting tilt CompletedBuildCount int // For synchronizing BuildController so that it's only // doing one action at a time. In the future, we might // want to allow it to parallelize builds better, but that // would require better tools for triaging output to different streams. BuildControllerActionCount int PermanentError error // The user has indicated they want to exit UserExited bool // The full log stream for tilt. This might deserve gc or file storage at some point. Log model.Log `testdiff:"ignore"` // GlobalYAML is a special manifest that has no images, but has dependencies // and a bunch of YAML that is deployed when those dependencies change. // TODO(dmiller) in the future we may have many of these manifests, but for now it's a special case. GlobalYAML model.Manifest GlobalYAMLState *YAMLManifestState TiltfilePath string ConfigFiles []string TiltIgnoreContents string PendingConfigFileChanges map[string]time.Time // InitManifests is the list of manifest names that we were told to init from the CLI. InitManifests []model.ManifestName TriggerMode model.TriggerMode TriggerQueue []model.ManifestName LogTimestamps bool IsProfiling bool LastTiltfileBuild model.BuildRecord CurrentTiltfileBuild model.BuildRecord TiltfileCombinedLog model.Log SailURL string }
func NewState ¶
func NewState() *EngineState
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) 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) ManifestNamesForTargetID ¶ added in v0.7.11
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.11
type ErrorAction struct {
Error error
}
func NewErrorAction ¶ added in v0.7.11
func NewErrorAction(err error) ErrorAction
func (ErrorAction) Action ¶ added in v0.7.11
func (ErrorAction) Action()
type LogActionsFlag ¶ added in v0.2.0
type LogActionsFlag bool
type LogEvent ¶ added in v0.8.1
func NewLogEvent ¶ added in v0.8.1
type ManifestState ¶
type ManifestState struct { Name model.ManifestName // k8s-specific state PodSet PodSet LBs map[k8s.ServiceName]*url.URL DeployID model.DeployID // ID we have assigned to the current deploy (helps find expected k8s objects) BuildStatuses map[model.TargetID]*BuildStatus // State of the running resource -- specific to type (e.g. k8s, docker-compose, etc.) ResourceState ResourceState 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 // If the pod isn't running this container then it's possible we're running stale code ExpectedContainerID container.ID // 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 // The log stream for this resource CombinedLog model.Log `testdiff:"ignore"` // If this manifest was changed, which config files led to the most recent change in manifest definition ConfigFilesThatCausedChange []string }
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) DCResourceState ¶ added in v0.4.1
func (ms *ManifestState) DCResourceState() dockercompose.State
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) HasPendingChangesBefore ¶ added in v0.4.1
Like HasPendingChanges, but relative to a particular time.
func (*ManifestState) HasPendingFileChanges ¶ added in v0.7.11
func (ms *ManifestState) HasPendingFileChanges() bool
func (*ManifestState) IsDC ¶ added in v0.4.1
func (ms *ManifestState) IsDC() bool
func (*ManifestState) IsPendingTime ¶ added in v0.2.0
func (ms *ManifestState) IsPendingTime(t time.Time) bool
Whether a change at the given time should trigger a build. Used to determine if changes to synced files or config files should kick off a new build.
func (*ManifestState) LastBuild ¶
func (ms *ManifestState) LastBuild() model.BuildRecord
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) NextBuildReason ¶ added in v0.2.0
func (ms *ManifestState) NextBuildReason() model.BuildReason
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) 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 Pod ¶
type Pod struct { PodID k8s.PodID Namespace k8s.Namespace StartedAt time.Time Status string Phase v1.PodPhase // 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 // The log for the currently active pod, if any CurrentLog model.Log `testdiff:"ignore"` // Corresponds to the deployed container. ContainerName container.Name ContainerID container.ID ContainerPorts []int32 ContainerReady bool ContainerImageRef reference.Named // We want to show the user # of restarts since pod has been running current code, // i.e. OldRestarts - Total Restarts ContainerRestarts int OldRestarts int // # times the pod restarted when it was running old code // HACK(maia): eventually we'll want our model of the world to handle pods with // multiple containers (for logs, restart counts, port forwards, etc.). For now, // we need to ship log visibility into multiple containers. Here's the minimum // of info we need for that. ContainerInfos []ContainerInfo }
type PodSet ¶ added in v0.2.0
type PodSet struct { Pods map[k8s.PodID]*Pod DeployID model.DeployID // Deploy that these pods correspond to }
func (PodSet) MostRecentPod ¶ added in v0.2.0
Get the "most recent pod" from the PodSet. 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.
type RStore ¶ added in v0.2.0
type RStore interface { Dispatch(action Action) RLockState() EngineState RUnlockState() }
Read-only store
type Reducer ¶ added in v0.1.0
type Reducer func(ctx context.Context, engineState *EngineState, action Action)
type ResourceState ¶ added in v0.4.1
type ResourceState interface {
ResourceState()
}
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 NewStoreForTesting ¶ added in v0.1.0
Returns a Store for testing that saves observed actions and makes them available via the return value `getActions`
func (*Store) AddSubscriber ¶
func (s *Store) AddSubscriber(sub Subscriber)
func (*Store) LockMutableStateForTesting ¶ added in v0.1.0
func (s *Store) LockMutableStateForTesting() *EngineState
func (*Store) NotifySubscribers ¶
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) UnlockMutableState ¶
func (s *Store) UnlockMutableState()
type Subscriber ¶
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
Some subscribers need to do teardown. Teardown holds the subscriber lock, so we expect it to return quickly. TODO(nick): A Setup method would also be useful for subscribers that do one-time setup.
type TestingStore ¶ added in v0.2.0
type TestingStore struct { Actions []Action // contains filtered or unexported fields }
func NewTestingStore ¶ added in v0.2.0
func NewTestingStore() *TestingStore
func (*TestingStore) Dispatch ¶ added in v0.2.0
func (s *TestingStore) Dispatch(action Action)
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)
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