@@ -133,6 +133,7 @@ type tiltProvider struct {
133
133
type tiltProviderConfig struct {
134
134
Context * string `json:"context,omitempty"`
135
135
Version * string `json:"version,omitempty"`
136
+ LiveReloadDeps []string `json:"live_reload_deps,omitempty"`
136
137
ApplyProviderYaml * bool `json:"apply_provider_yaml,omitempty"`
137
138
KustomizeFolder * string `json:"kustomize_folder,omitempty"`
138
139
KustomizeOptions []string `json:"kustomize_options,omitempty"`
@@ -347,7 +348,13 @@ func tiltResources(ctx context.Context, ts *tiltSettings) error {
347
348
if ptr .Deref (config .ApplyProviderYaml , true ) {
348
349
kustomizeFolder := path .Join (* config .Context , ptr .Deref (config .KustomizeFolder , "config/default" ))
349
350
kustomizeOptions := config .KustomizeOptions
350
- tasks [providerName ] = workloadTask (providerName , "provider" , "manager" , "manager" , ts , kustomizeFolder , kustomizeOptions , getProviderObj (config .Version ))
351
+ liveReloadDeps := config .LiveReloadDeps
352
+ var debugConfig * tiltSettingsDebugConfig
353
+ if d , ok := ts .Debug [providerName ]; ok {
354
+ debugConfig = & d
355
+ }
356
+ extraArgs := ts .ExtraArgs [providerName ]
357
+ tasks [providerName ] = workloadTask (providerName , "provider" , "manager" , "manager" , liveReloadDeps , debugConfig , extraArgs , kustomizeFolder , kustomizeOptions , getProviderObj (config .Version ))
351
358
}
352
359
}
353
360
@@ -686,7 +693,7 @@ func kustomizeTask(path, out string) taskFunction {
686
693
// workloadTask generates a task for creating the component yaml for a workload and saving the output on a file.
687
694
// NOTE: This task has several sub steps including running kustomize, envsubst, fixing components for debugging,
688
695
// and adding the workload resource mimicking what clusterctl init does.
689
- func workloadTask (name , workloadType , binaryName , containerName string , ts * tiltSettings , path string , options []string , getAdditionalObject func (string , []unstructured.Unstructured ) (* unstructured.Unstructured , error )) taskFunction {
696
+ func workloadTask (name , workloadType , binaryName , containerName string , liveReloadDeps [] string , debugConfig * tiltSettingsDebugConfig , extraArgs tiltSettingsExtraArgs , path string , options []string , getAdditionalObject func (string , []unstructured.Unstructured ) (* unstructured.Unstructured , error )) taskFunction {
690
697
return func (ctx context.Context , prefix string , errCh chan error ) {
691
698
args := []string {"build" }
692
699
args = append (args , options ... )
@@ -718,7 +725,7 @@ func workloadTask(name, workloadType, binaryName, containerName string, ts *tilt
718
725
return
719
726
}
720
727
721
- if err := prepareWorkload (name , prefix , binaryName , containerName , objs , ts ); err != nil {
728
+ if err := prepareWorkload (prefix , binaryName , containerName , objs , liveReloadDeps , debugConfig , extraArgs ); err != nil {
722
729
errCh <- err
723
730
return
724
731
}
@@ -787,14 +794,18 @@ func writeIfChanged(prefix string, path string, yaml []byte) error {
787
794
// If there are extra_args given for the workload, we append those to the ones that already exist in the deployment.
788
795
// This has the affect that the appended ones will take precedence, as those are read last.
789
796
// Finally, we modify the deployment to enable prometheus metrics scraping.
790
- func prepareWorkload (name , prefix , binaryName , containerName string , objs []unstructured.Unstructured , ts * tiltSettings ) error {
797
+ func prepareWorkload (prefix , binaryName , containerName string , objs []unstructured.Unstructured , liveReloadDeps [] string , debugConfig * tiltSettingsDebugConfig , extraArgs tiltSettingsExtraArgs ) error {
791
798
return updateDeployment (prefix , objs , func (deployment * appsv1.Deployment ) {
792
799
for j , container := range deployment .Spec .Template .Spec .Containers {
793
800
if container .Name != containerName {
794
801
continue
795
802
}
796
- cmd := []string {"sh" , "/start.sh" , "/" + binaryName }
797
- args := append (container .Args , []string (ts .ExtraArgs [name ])... )
803
+
804
+ cmd := []string {"/" + binaryName }
805
+ if len (liveReloadDeps ) > 0 || debugConfig != nil {
806
+ cmd = []string {"sh" , "/start.sh" , "/" + binaryName }
807
+ }
808
+ args := append (container .Args , []string (extraArgs )... )
798
809
799
810
// remove securityContext for tilt live_update, see https://github.com/tilt-dev/tilt/issues/3060
800
811
container .SecurityContext = nil
@@ -805,19 +816,19 @@ func prepareWorkload(name, prefix, binaryName, containerName string, objs []unst
805
816
// alter deployment for working nicely with delve debugger;
806
817
// most specifically, configuring delve, starting the manager with profiling enabled, dropping liveness and
807
818
// readiness probes and disabling leader election.
808
- if d , ok := ts . Debug [ name ]; ok {
819
+ if debugConfig != nil {
809
820
cmd = []string {"sh" , "/start.sh" , "/dlv" , "--accept-multiclient" , "--api-version=2" , "--headless=true" , "exec" }
810
821
811
- if d .Port != nil && * d .Port > 0 {
822
+ if debugConfig .Port != nil && * debugConfig .Port > 0 {
812
823
cmd = append (cmd , "--listen=:30000" )
813
824
}
814
- if d .Continue != nil && * d .Continue {
825
+ if debugConfig .Continue != nil && * debugConfig .Continue {
815
826
cmd = append (cmd , "--continue" )
816
827
}
817
828
818
829
cmd = append (cmd , []string {"--" , "/" + binaryName }... )
819
830
820
- if d .ProfilerPort != nil && * d .ProfilerPort > 0 {
831
+ if debugConfig .ProfilerPort != nil && * debugConfig .ProfilerPort > 0 {
821
832
args = append (args , []string {"--profiler-address=:6060" }... )
822
833
}
823
834
0 commit comments