@@ -28,6 +28,7 @@ import (
2828 "io/fs"
2929 "os"
3030 "os/exec"
31+ "path"
3132 "path/filepath"
3233 "strings"
3334 "sync"
@@ -36,6 +37,7 @@ import (
3637 "github.com/pkg/errors"
3738 "github.com/spf13/pflag"
3839 appsv1 "k8s.io/api/apps/v1"
40+ corev1 "k8s.io/api/core/v1"
3941 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4042 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
4143 kerrors "k8s.io/apimachinery/pkg/util/errors"
@@ -129,8 +131,11 @@ type tiltProvider struct {
129131}
130132
131133type 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"`
134139}
135140
136141func init () {
@@ -339,7 +344,11 @@ func tiltResources(ctx context.Context, ts *tiltSettings) error {
339344 if ! ok {
340345 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 )
341346 }
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+ }
343352 }
344353
345354 return runTaskGroup (ctx , "resources" , tasks )
@@ -361,8 +370,11 @@ func loadTiltProvider(providerRepository string) (map[string]tiltProviderConfig,
361370 contextPath := filepath .Join (providerRepository , ptr .Deref (p .Config .Context , "." ))
362371
363372 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 ,
366378 }
367379 }
368380 return ret , nil
@@ -674,9 +686,12 @@ func kustomizeTask(path, out string) taskFunction {
674686// workloadTask generates a task for creating the component yaml for a workload and saving the output on a file.
675687// NOTE: This task has several sub steps including running kustomize, envsubst, fixing components for debugging,
676688// 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 {
678690 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 ... )
680695 var stdout1 , stderr1 bytes.Buffer
681696 kustomizeCmd .Dir = rootPath
682697 kustomizeCmd .Stdout = & stdout1
@@ -823,11 +838,14 @@ func prepareWorkload(name, prefix, binaryName, containerName string, objs []unst
823838
824839 container .LivenessProbe = nil
825840 container .ReadinessProbe = nil
841+
842+ container .Resources = corev1.ResourceRequirements {}
826843 }
827844
828845 container .Command = cmd
829846 container .Args = args
830847 deployment .Spec .Template .Spec .Containers [j ] = container
848+ deployment .Spec .Replicas = ptr.To [int32 ](1 )
831849 }
832850 })
833851}
0 commit comments