@@ -202,23 +202,23 @@ func setDefaults(ts *tiltSettings) {
202
202
func allowK8sConfig (ts * tiltSettings ) error {
203
203
config , err := clientcmd .NewDefaultClientConfigLoadingRules ().Load ()
204
204
if err != nil {
205
- return errors .Wrap (err , "failed to load Kubeconfig " )
205
+ return errors .Wrap (err , "failed to load KubeConfig file " )
206
206
}
207
207
208
208
if config .CurrentContext == "" {
209
- return errors .New ("failed to get current context" )
209
+ return errors .New ("failed to get current context from the KubeConfig file " )
210
210
}
211
211
context , ok := config .Contexts [config .CurrentContext ]
212
212
if ! ok {
213
- return errors .Errorf ("failed to get context %s" , config .CurrentContext )
213
+ return errors .Errorf ("failed to get context %s from the KubeConfig file " , config .CurrentContext )
214
214
}
215
215
if strings .HasPrefix (context .Cluster , "kind-" ) {
216
216
return nil
217
217
}
218
218
219
219
allowed := sets .NewString (ts .AllowedContexts ... )
220
220
if ! allowed .Has (config .CurrentContext ) {
221
- return errors .Errorf ("context %s is not allowed" , config .CurrentContext )
221
+ return errors .Errorf ("context %s from the KubeConfig file is not allowed" , config .CurrentContext )
222
222
}
223
223
return nil
224
224
}
@@ -668,7 +668,7 @@ func kustomizeTask(path, out string) taskFunction {
668
668
// workloadTask generates a task for creating the component yaml for a workload and saving the output on a file.
669
669
// NOTE: This task has several sub steps including running kustomize, envsubst, fixing components for debugging,
670
670
// and adding the workload resource mimicking what clusterctl init does.
671
- func workloadTask (name , workloadType , binaryName , containerName string , ts * tiltSettings , path string , getAdditionalObjects func (string , []unstructured.Unstructured ) (* unstructured.Unstructured , error )) taskFunction {
671
+ func workloadTask (name , workloadType , binaryName , containerName string , ts * tiltSettings , path string , getAdditionalObject func (string , []unstructured.Unstructured ) (* unstructured.Unstructured , error )) taskFunction {
672
672
return func (ctx context.Context , prefix string , errCh chan error ) {
673
673
kustomizeCmd := exec .CommandContext (ctx , kustomizePath , "build" , path )
674
674
var stdout1 , stderr1 bytes.Buffer
@@ -701,13 +701,22 @@ func workloadTask(name, workloadType, binaryName, containerName string, ts *tilt
701
701
errCh <- err
702
702
return
703
703
}
704
- if getAdditionalObjects != nil {
705
- additionalObjects , err := getAdditionalObjects (prefix , objs )
704
+ if getAdditionalObject != nil {
705
+ additionalObject , err := getAdditionalObject (prefix , objs )
706
706
if err != nil {
707
707
errCh <- err
708
708
return
709
709
}
710
- objs = append (objs , * additionalObjects )
710
+ objs = append (objs , * additionalObject )
711
+ }
712
+
713
+ for _ , o := range objs {
714
+ labels := o .GetLabels ()
715
+ if labels == nil {
716
+ labels = map [string ]string {}
717
+ }
718
+ labels [clusterctlv1 .ClusterctlLabelName ] = ""
719
+ o .SetLabels (labels )
711
720
}
712
721
713
722
yaml , err := utilyaml .FromUnstructured (objs )
@@ -757,7 +766,6 @@ func writeIfChanged(prefix string, path string, yaml []byte) error {
757
766
// If there are extra_args given for the workload, we append those to the ones that already exist in the deployment.
758
767
// This has the affect that the appended ones will take precedence, as those are read last.
759
768
// Finally, we modify the deployment to enable prometheus metrics scraping.
760
-
761
769
func prepareWorkload (name , prefix , binaryName , containerName string , objs []unstructured.Unstructured , ts * tiltSettings ) error {
762
770
return updateDeployment (prefix , objs , func (d * appsv1.Deployment ) {
763
771
for j , container := range d .Spec .Template .Spec .Containers {
0 commit comments