store

package
v0.33.13 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const MainTiltfileManifestName = model.MainTiltfileManifestName
View Source
const MaxBackoff = time.Second * 15

Variables

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

	// EngineModeCI 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 AllPodContainerPorts added in v0.19.7

func AllPodContainerPorts(p v1alpha1.Pod) []int32

func AllPodContainerRestarts added in v0.19.7

func AllPodContainerRestarts(p v1alpha1.Pod) int32

func AllPodContainers added in v0.19.7

func AllPodContainers(p v1alpha1.Pod) []v1alpha1.Container

func AllPodContainersReady added in v0.19.7

func AllPodContainersReady(p v1alpha1.Pod) bool

func ClusterImageRefFromBuildResult added in v0.14.0

func ClusterImageRefFromBuildResult(r BuildResult) string

func CreateEngineStateEncoder added in v0.10.18

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

func LocalImageRefFromBuildResult added in v0.14.0

func LocalImageRefFromBuildResult(r BuildResult) string

func ManifestTargetEndpoints added in v0.5.0

func ManifestTargetEndpoints(mt *ManifestTarget) (endpoints []model.Link)

func MostRecentPod added in v0.23.1

func MostRecentPod(list []v1alpha1.Pod) v1alpha1.Pod

func MustObjectLogHandler added in v0.18.12

func MustObjectLogHandler(ctx context.Context, st Dispatcher, obj metav1.Object) context.Context

Read labels and annotations of the given API object to determine where to log, panicking if there's no info available.

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 WithManifestLogHandler added in v0.24.0

func WithManifestLogHandler(ctx context.Context, st Dispatcher, mn model.ManifestName, spanID logstore.SpanID) context.Context

func WithObjectLogHandler added in v0.18.12

func WithObjectLogHandler(ctx context.Context, st Dispatcher, obj metav1.Object) (context.Context, error)

Read labels and annotations of the given API object to determine where to log.

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 AppendToTriggerQueueAction added in v0.31.2

type AppendToTriggerQueueAction struct {
	Name   model.ManifestName
	Reason model.BuildReason
}

func (AppendToTriggerQueueAction) Action added in v0.31.2

func (AppendToTriggerQueueAction) Action()

type BuildResult

type BuildResult interface {
	TargetID() model.TargetID
	BuildType() model.BuildType
}

The results of a build.

If a build is successful, the builder should always return a BuildResult to indicate the output artifacts of the build (e.g., any new images).

If a build is not successful, things get messier. Certain types of failure may still return a result (e.g., a failed live update might return the container IDs where the error happened).

Long-term, we want this interface to be more like Bazel's SpawnResult https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/actions/SpawnResult.java#L36 where a builder always returns a Result, but with a code for each of the different failure types.

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) ApplyFilter added in v0.22.12

func (set BuildResultSet) ApplyFilter() *k8sconv.KubernetesApplyFilter

func (BuildResultSet) BuildTypes added in v0.10.14

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

type BuildState

type BuildState struct {
	// The last result.
	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

	// Dependencies changed since the last result was built
	DepsChangedSet map[model.TargetID]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)
	FullBuildTriggered bool

	// The default cluster.
	Cluster *v1alpha1.Cluster
}

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, pendingDeps []model.TargetID) BuildState

func (BuildState) ClusterOrEmpty added in v0.27.0

func (b BuildState) ClusterOrEmpty() *v1alpha1.Cluster

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) HasLastResult added in v0.15.2

func (b BuildState) HasLastResult() 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.14.0

func (b BuildState) LastLocalImageAsString() 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) WithFullBuildTriggered added in v0.14.3

func (b BuildState) WithFullBuildTriggered(isImageBuildTrigger bool) 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

func (BuildStateSet) FullBuildTriggered added in v0.14.3

func (set BuildStateSet) FullBuildTriggered() bool

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

	LastResult BuildResult

	// Stores the times that dependencies were marked dirty, so we can prioritize
	// the oldest one first.
	//
	// Long-term, we want to process all dependencies as a build graph rather than
	// a list of manifests. Specifically, we'll build one Target at a time.  Once
	// the build completes, we'll look at all the targets that depend on it, and
	// mark PendingDependencyChanges to indicate that they need a rebuild.
	//
	// Short-term, we only use this for cases where two manifests share a common
	// image. This only handles cross-manifest dependencies.
	//
	// This approach allows us to start working on the bookkeeping and
	// dependency-tracking in the short-term, without having to switch over to a
	// full dependency graph in one swoop.
	PendingDependencyChanges map[model.TargetID]time.Time
}

TODO(nick): This will eventually implement TargetStatus

func (*BuildStatus) ClearPendingChangesBefore added in v0.16.0

func (s *BuildStatus) ClearPendingChangesBefore(startTime time.Time)

func (BuildStatus) IsEmpty added in v0.7.11

func (s BuildStatus) IsEmpty() bool

type ChangeSet added in v0.19.1

type ChangeSet struct {
	Changes map[types.NamespacedName]bool
}

Represents all the IDs of a particular type of resource that have changed.

func NewChangeSet added in v0.19.1

func NewChangeSet(names ...types.NamespacedName) ChangeSet

func (*ChangeSet) Add added in v0.19.1

func (s *ChangeSet) Add(nn types.NamespacedName)

Add a changed resource name.

func (*ChangeSet) AddAll added in v0.19.1

func (s *ChangeSet) AddAll(other ChangeSet)

Merge another change set into this one.

func (*ChangeSet) Empty added in v0.20.5

func (s *ChangeSet) Empty() bool

type ChangeSummary added in v0.18.12

type ChangeSummary struct {
	// True if we saw one or more legacy actions that don't know how
	// to summarize their changes.
	Legacy bool

	// True if this change added logs.
	Log bool

	// Cmds with their specs changed.
	CmdSpecs ChangeSet

	UISessions  ChangeSet
	UIResources ChangeSet
	UIButtons   ChangeSet

	Clusters ChangeSet

	// If non-zero, that means we tried to apply this change and got
	// an error.
	LastBackoff time.Duration
}

Summarize the changes to the EngineState since the last change.

func LegacyChangeSummary added in v0.18.12

func LegacyChangeSummary() ChangeSummary

func (*ChangeSummary) Add added in v0.19.0

func (s *ChangeSummary) Add(other ChangeSummary)

func (ChangeSummary) IsLogOnly added in v0.18.12

func (s ChangeSummary) IsLogOnly() bool

type Cmd added in v0.18.12

type Cmd = v1alpha1.Cmd

type Dispatcher added in v0.23.5

type Dispatcher interface {
	Dispatch(action Action)
}

type DockerComposeBuildResult added in v0.10.14

type DockerComposeBuildResult struct {

	// 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.
	Status v1alpha1.DockerComposeServiceStatus
	// contains filtered or unexported fields
}

func NewDockerComposeDeployResult added in v0.10.0

func NewDockerComposeDeployResult(id model.TargetID, status v1alpha1.DockerComposeServiceStatus) DockerComposeBuildResult

For docker compose deploy targets.

func (DockerComposeBuildResult) BuildType added in v0.10.14

func (DockerComposeBuildResult) TargetID added in v0.10.14

type EngineMode added in v0.14.0

type EngineMode struct {
	Name string
}

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

func (EngineMode) IsCIMode added in v0.14.0

func (m EngineMode) IsCIMode() bool

func (EngineMode) WatchesFiles added in v0.14.0

func (m EngineMode) WatchesFiles() bool

func (EngineMode) WatchesRuntime added in v0.14.0

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

	// Keep a set of the current builds, so we can quickly count how many
	// builds there are without looking at all builds in the list.
	CurrentBuildSet map[model.ManifestName]bool

	TerminalMode TerminalMode

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

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

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

	UpdateSettings model.UpdateSettings

	FatalError error

	// 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"`

	TriggerQueue []model.ManifestName

	TiltfileDefinitionOrder []model.ManifestName
	TiltfileStates          map[model.ManifestName]*ManifestState

	// Files and directories read during tiltfile execution,
	// which we listen to for reload.
	TiltfileConfigPaths map[model.ManifestName][]string

	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

	DockerPruneSettings model.DockerPruneSettings

	TelemetrySettings model.TelemetrySettings

	UserConfigState model.UserConfigState

	// The initialization sequence is unfortunate. Currently we have:
	// 1) Dispatch an InitAction
	// 1) InitAction sets DesiredTiltfilePath
	// 2) ConfigsController reads DesiredTiltfilePath, writes a new Tiltfile object to the APIServer
	// 4) ConfigsController dispatches a TiltfileCreateAction, to copy the apiserver data into the EngineState
	DesiredTiltfilePath string

	// KubernetesResources by name.
	// Updated to match KubernetesApply + KubernetesDiscovery
	KubernetesResources map[string]*k8sconv.KubernetesResource `json:"-"`

	// API-server-based data models. Stored in EngineState
	// to assist in migration.
	Cmds                  map[string]*Cmd                           `json:"-"`
	Tiltfiles             map[string]*v1alpha1.Tiltfile             `json:"-"`
	FileWatches           map[string]*v1alpha1.FileWatch            `json:"-"`
	KubernetesApplys      map[string]*v1alpha1.KubernetesApply      `json:"-"`
	KubernetesDiscoverys  map[string]*v1alpha1.KubernetesDiscovery  `json:"-"`
	UIResources           map[string]*v1alpha1.UIResource           `json:"-"`
	ConfigMaps            map[string]*v1alpha1.ConfigMap            `json:"-"`
	LiveUpdates           map[string]*v1alpha1.LiveUpdate           `json:"-"`
	Clusters              map[string]*v1alpha1.Cluster              `json:"-"`
	UIButtons             map[string]*v1alpha1.UIButton             `json:"-"`
	DockerComposeServices map[string]*v1alpha1.DockerComposeService `json:"-"`
	ImageMaps             map[string]*v1alpha1.ImageMap             `json:"-"`
	DockerImages          map[string]*v1alpha1.DockerImage          `json:"-"`
	CmdImages             map[string]*v1alpha1.CmdImage             `json:"-"`
}

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) AppendToTriggerQueue added in v0.17.10

func (e *EngineState) AppendToTriggerQueue(mn model.ManifestName, reason model.BuildReason)

func (*EngineState) AvailableBuildSlots added in v0.14.0

func (e *EngineState) AvailableBuildSlots() int

func (*EngineState) BuildStatus added in v0.5.1

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

Find the first build status. Only suitable for testing.

func (EngineState) GetTiltfileStates added in v0.22.1

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

Returns TiltfileStates in a stable order.

func (*EngineState) HasBuild added in v0.33.0

func (e *EngineState) HasBuild() bool

func (*EngineState) InitialBuildsCompleted added in v0.10.18

func (e *EngineState) InitialBuildsCompleted() bool

func (*EngineState) IsBuilding added in v0.26.0

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

func (EngineState) IsEmpty added in v0.4.1

func (e EngineState) IsEmpty() bool

func (EngineState) LastMainTiltfileError added in v0.22.1

func (e EngineState) LastMainTiltfileError() error

func (*EngineState) MainConfigPaths added in v0.22.4

func (e *EngineState) MainConfigPaths() []string

func (*EngineState) MainTiltfilePath added in v0.22.4

func (e *EngineState) MainTiltfilePath() string

func (*EngineState) MainTiltfileState added in v0.22.1

func (e *EngineState) MainTiltfileState() *ManifestState

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.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) RemoveFromTriggerQueue added in v0.17.10

func (e *EngineState) RemoveFromTriggerQueue(mn model.ManifestName)

func (*EngineState) RemoveManifestTarget added in v0.17.13

func (e *EngineState) RemoveManifestTarget(mn model.ManifestName)

func (EngineState) Targets added in v0.5.0

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

Returns ManifestTargets in a stable order

func (EngineState) TargetsBesides added in v0.16.0

func (e EngineState) TargetsBesides(mn model.ManifestName) []*ManifestTarget

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 Hold added in v0.17.5

type Hold struct {
	Reason HoldReason

	// Pointers to the internal data model we're holding for.
	HoldOn []model.TargetID

	// Pointers to the API objects we're holding for.
	OnRefs []v1alpha1.UIResourceStateWaitingOnRef
}

We place a "hold" on a manifest if we can't build it because it's waiting on something.

func (Hold) String added in v0.22.15

func (h Hold) String() string

type HoldReason added in v0.22.15

type HoldReason string
const (
	HoldReasonNone                             HoldReason = ""
	HoldReasonTiltfileReload                   HoldReason = "tiltfile-reload"
	HoldReasonWaitingForUnparallelizableTarget HoldReason = "waiting-for-local"
	HoldReasonIsUnparallelizableTarget         HoldReason = "is-unparallelizable-local"
	HoldReasonWaitingForUncategorized          HoldReason = "waiting-for-uncategorized"
	HoldReasonBuildingComponent                HoldReason = "building-component"
	HoldReasonWaitingForDep                    HoldReason = "waiting-for-dep"
	HoldReasonWaitingForDeploy                 HoldReason = "waiting-for-deploy"

	// We're waiting for a reconciler to respond to the change,
	// but don't know yet what it's waiting on.
	HoldReasonReconciling HoldReason = "reconciling"

	// We're waiting on the cluster connection to be established.
	HoldReasonCluster HoldReason = "waiting-for-cluster"
)

type ImageBuildResult added in v0.10.14

type ImageBuildResult struct {
	ImageMapStatus v1alpha1.ImageMapStatus
	// contains filtered or unexported fields
}

func NewImageBuildResult added in v0.7.11

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

For image targets.

func NewImageBuildResultSingleRef added in v0.14.0

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) TargetID added in v0.10.14

func (r ImageBuildResult) TargetID() model.TargetID

type ImageBuildResultSet added in v0.20.9

type ImageBuildResultSet map[model.TargetID]ImageBuildResult

A BuildResultSet that can only hold image build results.

func (ImageBuildResultSet) ToBuildResultSet added in v0.20.9

func (s ImageBuildResultSet) ToBuildResultSet() BuildResultSet

type K8sBuildResult added in v0.10.14

type K8sBuildResult struct {
	*k8sconv.KubernetesApplyFilter
	// contains filtered or unexported fields
}

func NewK8sDeployResult added in v0.10.5

func NewK8sDeployResult(id model.TargetID, filter *k8sconv.KubernetesApplyFilter) K8sBuildResult

NewK8sDeployResult creates a deploy result for Kubernetes deploy targets.

func (K8sBuildResult) BuildType added in v0.10.14

func (r K8sBuildResult) BuildType() model.BuildType

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 {
	LBs map[k8s.ServiceName]*url.URL

	ApplyFilter *k8sconv.KubernetesApplyFilter

	// This must match the FilteredPods field of k8sconv.KubernetesResource
	FilteredPods []v1alpha1.Pod

	// Conditions from the apply operation; must match the Conditions field
	// from k8sconv.KubernetesResource::ApplyStatus.
	Conditions []metav1.Condition

	LastReadyOrSucceededTime    time.Time
	HasEverDeployedSuccessfully bool

	UpdateStartTime map[k8s.PodID]time.Time

	PodReadinessMode model.PodReadinessMode
}

func NewK8sRuntimeState added in v0.10.5

func NewK8sRuntimeState(m model.Manifest) K8sRuntimeState

func NewK8sRuntimeStateWithPods added in v0.16.0

func NewK8sRuntimeStateWithPods(m model.Manifest, pods ...v1alpha1.Pod) K8sRuntimeState

func (K8sRuntimeState) ContainsID added in v0.10.5

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

func (K8sRuntimeState) EntityDisplayNames added in v0.23.0

func (s K8sRuntimeState) EntityDisplayNames() []string

func (K8sRuntimeState) GetPods added in v0.23.1

func (s K8sRuntimeState) GetPods() []v1alpha1.Pod

func (K8sRuntimeState) HasEverBeenReadyOrSucceeded added in v0.14.0

func (s K8sRuntimeState) HasEverBeenReadyOrSucceeded() bool

func (K8sRuntimeState) MostRecentPod added in v0.10.5

func (s K8sRuntimeState) MostRecentPod() v1alpha1.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) RuntimeState added in v0.10.5

func (K8sRuntimeState) RuntimeState()

func (K8sRuntimeState) RuntimeStatus added in v0.14.0

func (s K8sRuntimeState) RuntimeStatus() v1alpha1.RuntimeStatus

func (K8sRuntimeState) RuntimeStatusError added in v0.14.0

func (s K8sRuntimeState) RuntimeStatusError() error

func (K8sRuntimeState) VisiblePodContainerRestarts added in v0.20.4

func (s K8sRuntimeState) VisiblePodContainerRestarts(podID k8s.PodID) int32

type KubernetesDiscovery added in v0.20.2

type KubernetesDiscovery = v1alpha1.KubernetesDiscovery

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) TargetID added in v0.10.14

func (r LocalBuildResult) TargetID() model.TargetID

type LocalRuntimeState added in v0.10.9

type LocalRuntimeState struct {
	CmdName                  string
	Status                   v1alpha1.RuntimeStatus
	PID                      int
	StartTime                time.Time
	FinishTime               time.Time
	SpanID                   model.LogSpanID
	LastReadyOrSucceededTime time.Time
	Ready                    bool
}

func (LocalRuntimeState) HasEverBeenReadyOrSucceeded added in v0.14.0

func (l LocalRuntimeState) HasEverBeenReadyOrSucceeded() bool

func (LocalRuntimeState) RuntimeState added in v0.10.9

func (LocalRuntimeState) RuntimeState()

func (LocalRuntimeState) RuntimeStatus added in v0.14.0

func (l LocalRuntimeState) RuntimeStatus() v1alpha1.RuntimeStatus

func (LocalRuntimeState) RuntimeStatusError added in v0.14.0

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.14.0

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

func NewLogAction added in v0.14.0

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.14.0

func (le LogAction) Fields() logger.Fields

func (LogAction) Level added in v0.14.0

func (le LogAction) Level() logger.Level

func (LogAction) ManifestName added in v0.14.0

func (le LogAction) ManifestName() model.ManifestName

func (LogAction) Message added in v0.14.0

func (le LogAction) Message() []byte

func (LogAction) SpanID added in v0.14.0

func (le LogAction) SpanID() logstore.SpanID

func (LogAction) String added in v0.14.0

func (le LogAction) String() string

func (LogAction) Summarize added in v0.18.12

func (LogAction) Summarize(s *ChangeSummary)

func (LogAction) Time added in v0.14.0

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

	// Any current builds for this manifest.
	//
	// There can be multiple simultaneous image builds + deploys + live updates
	// associated with a manifest.
	//
	// In an ideal world, we'd read these builds from the API models
	// rather than do separate bookkeeping for them.
	CurrentBuilds map[string]model.BuildRecord

	LastSuccessfulDeployTime time.Time

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

	// 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

	DisableState v1alpha1.DisableState
}

func NewManifestState

func NewManifestState(m model.Manifest) *ManifestState

func (*ManifestState) AddCompletedBuild added in v0.4.1

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

func (*ManifestState) AddPendingFileChange added in v0.19.3

func (ms *ManifestState) AddPendingFileChange(targetID model.TargetID, file string, timestamp time.Time)

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) EarliestCurrentBuild added in v0.26.0

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

Return the current build that started first.

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.14.0

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

Like HasPendingChanges, but relative to a particular time.

func (*ManifestState) HasPendingDependencyChanges added in v0.15.2

func (ms *ManifestState) HasPendingDependencyChanges() bool

func (*ManifestState) HasPendingFileChanges added in v0.7.11

func (ms *ManifestState) HasPendingFileChanges() bool

func (*ManifestState) IsBuilding added in v0.14.0

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.14.0

func (ms *ManifestState) LocalRuntimeState() LocalRuntimeState

func (*ManifestState) MostRecentPod added in v0.2.0

func (ms *ManifestState) MostRecentPod() v1alpha1.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) (*v1alpha1.Pod, bool)

func (*ManifestState) RuntimeStatus added in v0.23.4

func (ms *ManifestState) RuntimeStatus(triggerMode model.TriggerMode) v1alpha1.RuntimeStatus

Check the runtime status of the individual status fields.

The individual status fields don't know anything about how resources are triggered (i.e., whether they're waiting on a dependent resource to build or a manual trigger). So we need to consider that information here.

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

func (*ManifestState) UpdateStatus added in v0.18.4

func (ms *ManifestState) UpdateStatus(triggerMode model.TriggerMode) v1alpha1.UpdateStatus

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) NextBuildReason added in v0.10.19

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

func (*ManifestTarget) RuntimeStatus added in v0.23.4

func (mt *ManifestTarget) RuntimeStatus() v1alpha1.RuntimeStatus

Compute the runtime status for the whole Manifest.

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

func (*ManifestTarget) UpdateStatus added in v0.18.4

func (mt *ManifestTarget) UpdateStatus() v1alpha1.UpdateStatus

type PanicAction added in v0.10.22

type PanicAction struct {
	Err error
}

func (PanicAction) Action added in v0.10.22

func (PanicAction) Action()

type PodLogStream added in v0.19.2

type PodLogStream = v1alpha1.PodLogStream

type PortForward added in v0.19.7

type PortForward = v1alpha1.PortForward

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() v1alpha1.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 {
	// Initialize the subscriber.
	//
	// Any errors will trigger an ErrorAction.
	SetUp(ctx context.Context, st RStore) error
}

Some subscribers need to do SetUp or TearDown.

Both hold the subscriber lock, so should return quickly.

SetUp and TearDown are called in serial. SetUp is called in FIFO order while TearDown is LIFO so that inter-subscriber dependencies are respected.

type Sleeper added in v0.20.9

type Sleeper interface {
	// A cancelable Sleep(). Exits immediately if the context is canceled.
	Sleep(ctx context.Context, d time.Duration)
}

func DefaultSleeper added in v0.20.9

func DefaultSleeper() Sleeper

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.14.0

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) error

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, summary ChangeSummary)

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) error

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, summary ChangeSummary) error
}

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().

If OnChange returns an error, the store will requeue the change summary and retry after a backoff period.

Over time, we want to port all subscribers to use controller-runtime's Reconciler interface. In the intermediate period, we expect this interface will evolve to support all the features of Reconciler.

https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/reconcile

type SubscriberLifecycle added in v0.7.11

type SubscriberLifecycle interface {
	SetUpper
	TearDowner
}

Convenience interface for subscriber fulfilling both SetUpper and TearDowner

type Summarizer added in v0.18.12

type Summarizer interface {
	Action

	Summarize(summary *ChangeSummary)
}

type TearDowner added in v0.8.2

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

type TerminalMode added in v0.15.0

type TerminalMode int

When Tilt is talking to a terminal, it can take on a few different modes.

const (
	// For the case where the terminal mode simply
	// hasn't been initialized yet.
	TerminalModeDefault TerminalMode = iota

	// A termbox UI takes over your terminal screen.
	TerminalModeHUD

	// Logs are incrementally written to stdout.
	// This is the only available mode if the user
	// is redirecting tilt output to a file.
	TerminalModeStream

	// Tilt waits on a prompt to decide what mode
	// to be in.
	TerminalModePrompt
)

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.14.0

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

func (*TestingStore) ClearActions added in v0.14.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.14.0

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.14.0

func (s *TestingStore) UnlockMutableState()

func (*TestingStore) WaitForAction added in v0.15.0

func (s *TestingStore) WaitForAction(t testing.TB, typ reflect.Type) Action

func (*TestingStore) WithManifestState added in v0.24.0

func (s *TestingStore) WithManifestState(name model.ManifestName, f func(ms *ManifestState))

func (*TestingStore) WithState added in v0.14.0

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

type TiltCloudStatusReceivedAction added in v0.14.0

type TiltCloudStatusReceivedAction struct {
	SuggestedTiltVersion string
}

func (TiltCloudStatusReceivedAction) Action added in v0.14.0

Directories

Path Synopsis
Converts Kubernetes data models into our own internal data models.
Converts Kubernetes data models into our own internal data models.

Jump to

Keyboard shortcuts

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