github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/store/liveupdates/sync.go (about) 1 package liveupdates 2 3 import ( 4 "github.com/tilt-dev/tilt/internal/build" 5 "github.com/tilt-dev/tilt/internal/controllers/apis/liveupdate" 6 "github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" 7 ) 8 9 // LiveUpdatePlan is the result of evaluating a list of changed files against the rules in the spec. 10 // 11 // TODO(milas): we should probably canonicalize all the local paths here using .spec.basePath 12 type LiveUpdatePlan struct { 13 // SyncPaths are changed (local) paths and their corresponding container paths to be synced. 14 SyncPaths []build.PathMapping 15 // NoMatchPaths are changed (local) paths that do not match any Live Update rules. 16 NoMatchPaths []string 17 // StopPaths are changed (local) paths that should halt Live Update and result in a full rebuild. 18 // 19 // These are often referred to as "fallback" paths, particularly in the Tiltfile API. 20 StopPaths []string 21 } 22 23 // NewLiveUpdatePlan evaluates a set of changed files against a LiveUpdateSpec. 24 func NewLiveUpdatePlan(luSpec v1alpha1.LiveUpdateSpec, filesChanged []string) (LiveUpdatePlan, error) { 25 var plan LiveUpdatePlan 26 27 var err error 28 plan.SyncPaths, plan.NoMatchPaths, err = build.FilesToPathMappings( 29 filesChanged, 30 liveupdate.SyncSteps(luSpec), 31 ) 32 if err != nil { 33 return LiveUpdatePlan{}, err 34 } 35 36 plan.StopPaths, err = liveupdate.FallBackOnFiles(luSpec).Intersection(filesChanged) 37 if err != nil { 38 return LiveUpdatePlan{}, err 39 } 40 41 return plan, nil 42 }