@@ -608,3 +608,23 @@ func TestFailKustomizeBuildPatches(t *testing.T) {
608608 _ , _ , _ , err = kustomize .Build (& kustomizeSource , nil , nil , nil )
609609 require .EqualError (t , err , "kustomization file not found in the path" )
610610}
611+
612+ func TestKustomizeBuildComponentsNoFoundComponents (t * testing.T ) {
613+ appPath , err := testDataDir (t , kustomization6 )
614+ require .NoError (t , err )
615+ kustomize := NewKustomizeApp (appPath , appPath , git.NopCreds {}, "" , "" , "" , "" )
616+
617+ // Test with non-existent components and IgnoreMissingComponents = true
618+ // This should result in foundComponents being empty, so no "edit add component" command should be executed
619+ kustomizeSource := v1alpha1.ApplicationSourceKustomize {
620+ Components : []string {"./non-existent-component1" , "./non-existent-component2" },
621+ IgnoreMissingComponents : true ,
622+ }
623+ _ , _ , commands , err := kustomize .Build (& kustomizeSource , nil , nil , nil )
624+ require .NoError (t , err )
625+
626+ // Verify that no "edit add component" command was executed
627+ for _ , cmd := range commands {
628+ assert .NotContains (t , cmd , "edit add component" , "kustomize edit add component should not be invoked when foundComponents is empty" )
629+ }
630+ }
0 commit comments