@@ -28,6 +28,7 @@ import (
28
28
"io/fs"
29
29
"os"
30
30
"os/exec"
31
+ "path"
31
32
"path/filepath"
32
33
"strings"
33
34
"sync"
@@ -36,6 +37,7 @@ import (
36
37
"github.com/pkg/errors"
37
38
"github.com/spf13/pflag"
38
39
appsv1 "k8s.io/api/apps/v1"
40
+ corev1 "k8s.io/api/core/v1"
39
41
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
40
42
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
41
43
kerrors "k8s.io/apimachinery/pkg/util/errors"
@@ -129,8 +131,11 @@ type tiltProvider struct {
129
131
}
130
132
131
133
type tiltProviderConfig struct {
132
- Context * string `json:"context,omitempty"`
133
- Version * string `json:"version,omitempty"`
134
+ Context * string `json:"context,omitempty"`
135
+ Version * string `json:"version,omitempty"`
136
+ ApplyProviderYaml * bool `json:"apply_provider_yaml,omitempty"`
137
+ KustomizeFolder * string `json:"kustomize_folder,omitempty"`
138
+ KustomizeOptions []string `json:"kustomize_options,omitempty"`
134
139
}
135
140
136
141
func init () {
@@ -339,7 +344,11 @@ func tiltResources(ctx context.Context, ts *tiltSettings) error {
339
344
if ! ok {
340
345
return errors .Errorf ("failed to obtain config for the provider %s, please add the providers path to the provider_repos list in tilt-settings.yaml/json file" , providerName )
341
346
}
342
- tasks [providerName ] = workloadTask (providerName , "provider" , "manager" , "manager" , ts , fmt .Sprintf ("%s/config/default" , * config .Context ), getProviderObj (config .Version ))
347
+ if ptr .Deref (config .ApplyProviderYaml , true ) {
348
+ kustomizeFolder := path .Join (* config .Context , ptr .Deref (config .KustomizeFolder , "config/default" ))
349
+ kustomizeOptions := config .KustomizeOptions
350
+ tasks [providerName ] = workloadTask (providerName , "provider" , "manager" , "manager" , ts , kustomizeFolder , kustomizeOptions , getProviderObj (config .Version ))
351
+ }
343
352
}
344
353
345
354
return runTaskGroup (ctx , "resources" , tasks )
@@ -361,8 +370,11 @@ func loadTiltProvider(providerRepository string) (map[string]tiltProviderConfig,
361
370
contextPath := filepath .Join (providerRepository , ptr .Deref (p .Config .Context , "." ))
362
371
363
372
ret [p .Name ] = tiltProviderConfig {
364
- Context : & contextPath ,
365
- Version : p .Config .Version ,
373
+ Context : & contextPath ,
374
+ Version : p .Config .Version ,
375
+ ApplyProviderYaml : p .Config .ApplyProviderYaml ,
376
+ KustomizeFolder : p .Config .KustomizeFolder ,
377
+ KustomizeOptions : p .Config .KustomizeOptions ,
366
378
}
367
379
}
368
380
return ret , nil
@@ -674,9 +686,12 @@ func kustomizeTask(path, out string) taskFunction {
674
686
// workloadTask generates a task for creating the component yaml for a workload and saving the output on a file.
675
687
// NOTE: This task has several sub steps including running kustomize, envsubst, fixing components for debugging,
676
688
// and adding the workload resource mimicking what clusterctl init does.
677
- func workloadTask (name , workloadType , binaryName , containerName string , ts * tiltSettings , path string , getAdditionalObject func (string , []unstructured.Unstructured ) (* unstructured.Unstructured , error )) taskFunction {
689
+ func workloadTask (name , workloadType , binaryName , containerName string , ts * tiltSettings , path string , options [] string , getAdditionalObject func (string , []unstructured.Unstructured ) (* unstructured.Unstructured , error )) taskFunction {
678
690
return func (ctx context.Context , prefix string , errCh chan error ) {
679
- kustomizeCmd := exec .CommandContext (ctx , kustomizePath , "build" , path )
691
+ args := []string {"build" }
692
+ args = append (args , options ... )
693
+ args = append (args , path )
694
+ kustomizeCmd := exec .CommandContext (ctx , kustomizePath , args ... )
680
695
var stdout1 , stderr1 bytes.Buffer
681
696
kustomizeCmd .Dir = rootPath
682
697
kustomizeCmd .Stdout = & stdout1
@@ -823,11 +838,14 @@ func prepareWorkload(name, prefix, binaryName, containerName string, objs []unst
823
838
824
839
container .LivenessProbe = nil
825
840
container .ReadinessProbe = nil
841
+
842
+ container .Resources = corev1.ResourceRequirements {}
826
843
}
827
844
828
845
container .Command = cmd
829
846
container .Args = args
830
847
deployment .Spec .Template .Spec .Containers [j ] = container
848
+ deployment .Spec .Replicas = ptr.To [int32 ](1 )
831
849
}
832
850
})
833
851
}
0 commit comments