@@ -202,23 +202,23 @@ func setDefaults(ts *tiltSettings) {
202202func allowK8sConfig (ts * tiltSettings ) error {
203203 config , err := clientcmd .NewDefaultClientConfigLoadingRules ().Load ()
204204 if err != nil {
205- return errors .Wrap (err , "failed to load Kubeconfig " )
205+ return errors .Wrap (err , "failed to load KubeConfig file " )
206206 }
207207
208208 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 " )
210210 }
211211 context , ok := config .Contexts [config .CurrentContext ]
212212 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 )
214214 }
215215 if strings .HasPrefix (context .Cluster , "kind-" ) {
216216 return nil
217217 }
218218
219219 allowed := sets .NewString (ts .AllowedContexts ... )
220220 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 )
222222 }
223223 return nil
224224}
@@ -668,7 +668,7 @@ func kustomizeTask(path, out string) taskFunction {
668668// workloadTask generates a task for creating the component yaml for a workload and saving the output on a file.
669669// NOTE: This task has several sub steps including running kustomize, envsubst, fixing components for debugging,
670670// 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 {
672672 return func (ctx context.Context , prefix string , errCh chan error ) {
673673 kustomizeCmd := exec .CommandContext (ctx , kustomizePath , "build" , path )
674674 var stdout1 , stderr1 bytes.Buffer
@@ -701,13 +701,22 @@ func workloadTask(name, workloadType, binaryName, containerName string, ts *tilt
701701 errCh <- err
702702 return
703703 }
704- if getAdditionalObjects != nil {
705- additionalObjects , err := getAdditionalObjects (prefix , objs )
704+ if getAdditionalObject != nil {
705+ additionalObject , err := getAdditionalObject (prefix , objs )
706706 if err != nil {
707707 errCh <- err
708708 return
709709 }
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 )
711720 }
712721
713722 yaml , err := utilyaml .FromUnstructured (objs )
@@ -757,7 +766,6 @@ func writeIfChanged(prefix string, path string, yaml []byte) error {
757766// If there are extra_args given for the workload, we append those to the ones that already exist in the deployment.
758767// This has the affect that the appended ones will take precedence, as those are read last.
759768// Finally, we modify the deployment to enable prometheus metrics scraping.
760-
761769func prepareWorkload (name , prefix , binaryName , containerName string , objs []unstructured.Unstructured , ts * tiltSettings ) error {
762770 return updateDeployment (prefix , objs , func (d * appsv1.Deployment ) {
763771 for j , container := range d .Spec .Template .Spec .Containers {
0 commit comments