github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/pkg/model/trigger_mode.go (about) 1 package model 2 3 type TriggerMode int 4 5 // Currently TriggerMode models two orthogonal attributes in one enum: 6 // 7 // 1. Whether a file change should update the resource immediately (auto vs 8 // manual mode) 9 // 10 // 2. Whether a resource should start when the env starts (auto_init=true vs 11 // auto_init=false mode, sometimes called AutoInit vs ManualInit mode) 12 // 13 // In the APIServer, we don't model these as attributes of a resource. Rather, 14 // the resource specifies where these attribute comes from, with the ability to 15 // define different sources. 16 // 17 // Update triggers are modeled as StartOn/RestartOn, so resources 18 // can be configured with different types of update triggers. 19 // 20 // Start/stop status of resources are modeled as DisableOn, so 21 // that individual objects can be independently started/stopped. 22 // 23 // We expect TriggerMode to go away in the API in favor of better visualization 24 // of why updates have been triggered and why resources are stopped. 25 const ( 26 // Tilt automatically performs all builds (initial and non-initial) without manual intervention 27 TriggerModeAuto TriggerMode = iota 28 // Tilt automatically performs initial builds without manual intervention, but requires manual intervention for non-initial builds 29 TriggerModeManualWithAutoInit TriggerMode = iota 30 // Tilt requires manual intervention for all builds, and never automatically performs a build 31 TriggerModeManual TriggerMode = iota 32 // Resource does not automatically build on `tilt up`, but builds automatically in response to file changes 33 TriggerModeAutoWithManualInit TriggerMode = iota 34 ) 35 36 var TriggerModes = map[TriggerMode]bool{ 37 TriggerModeAuto: true, 38 TriggerModeManualWithAutoInit: true, 39 TriggerModeManual: true, 40 TriggerModeAutoWithManualInit: true, 41 } 42 43 func ValidTriggerMode(tm TriggerMode) bool { 44 return TriggerModes[tm] 45 } 46 func (t TriggerMode) AutoOnChange() bool { 47 return t == TriggerModeAuto || t == TriggerModeAutoWithManualInit 48 } 49 50 func (t TriggerMode) AutoInitial() bool { 51 return t == TriggerModeAuto || t == TriggerModeManualWithAutoInit 52 }