-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apis: remove model.LiveUpdate in favor of v1alpha1.LiveUpdateSpec (#4984
- Loading branch information
Showing
33 changed files
with
848 additions
and
970 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package liveupdate | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"github.com/tilt-dev/tilt/pkg/apis/core/v1alpha1" | ||
"github.com/tilt-dev/tilt/pkg/model" | ||
) | ||
|
||
func IsEmptySpec(spec v1alpha1.LiveUpdateSpec) bool { | ||
return len(spec.Syncs) == 0 && len(spec.Execs) == 0 | ||
} | ||
|
||
// FallBackOnFiles returns a PathSet of files which, if any have changed, indicate | ||
// that we should fall back to an image build. | ||
func FallBackOnFiles(spec v1alpha1.LiveUpdateSpec) model.PathSet { | ||
return model.NewPathSet(spec.StopPaths, spec.BasePath) | ||
} | ||
|
||
// Evaluates live-update syncs relative to the base path, | ||
// and returns a sync with resolved paths. | ||
func SyncSteps(spec v1alpha1.LiveUpdateSpec) []model.Sync { | ||
var syncs []model.Sync | ||
for _, sync := range spec.Syncs { | ||
localPath := sync.LocalPath | ||
if !filepath.IsAbs(localPath) { | ||
localPath = filepath.Join(spec.BasePath, localPath) | ||
} | ||
|
||
syncs = append(syncs, model.Sync{LocalPath: localPath, ContainerPath: sync.ContainerPath}) | ||
} | ||
return syncs | ||
} | ||
|
||
// Evaluates live-update exec relative to the base path, | ||
// and returns a run with resolved paths. | ||
func RunSteps(spec v1alpha1.LiveUpdateSpec) []model.Run { | ||
var runs []model.Run | ||
for _, exec := range spec.Execs { | ||
runs = append(runs, model.Run{ | ||
Cmd: model.Cmd{ | ||
Argv: exec.Args, | ||
}, | ||
Triggers: model.NewPathSet(exec.TriggerPaths, spec.BasePath), | ||
}) | ||
} | ||
return runs | ||
} | ||
|
||
func ShouldRestart(spec v1alpha1.LiveUpdateSpec) bool { | ||
return spec.Restart == v1alpha1.LiveUpdateRestartStrategyAlways | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.