@@ -818,6 +818,7 @@ func TestDecryptor_decryptKustomizationSources(t *testing.T) {
818818 wordirSuffix string
819819 path string
820820 files []file
821+ patch []kustypes.Patch
821822 secretGenerator []kustypes.SecretArgs
822823 expectVisited []string
823824 wantErr error
@@ -922,6 +923,34 @@ func TestDecryptor_decryptKustomizationSources(t *testing.T) {
922923 wantErr : & fs.PathError {Op : "lstat" , Path : "data.env" , Err : fmt .Errorf ("" )},
923924 expectVisited : []string {},
924925 },
926+ {
927+ name : "ignore remote patches" ,
928+ path : "subdir" ,
929+ files : []file {
930+ {name : "subdir/file.txt" , data : []byte ("file" ), encrypt : true , expectData : true },
931+ {name : "subdir/patch.yaml" , data : []byte ("op: add\n " ), encrypt : true , expectData : true },
932+ },
933+ patch : []kustypes.Patch {
934+ {
935+ Path : "patch.yaml" ,
936+ },
937+ {
938+ // this patch gets ignored due to being remote
939+ Path : "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/examples/wordpress/patch.yaml" ,
940+ },
941+ },
942+ secretGenerator : []kustypes.SecretArgs {
943+ {
944+ GeneratorArgs : kustypes.GeneratorArgs {
945+ Name : "envSecret" ,
946+ KvPairSources : kustypes.KvPairSources {
947+ FileSources : []string {"file.txt" },
948+ },
949+ },
950+ },
951+ },
952+ expectVisited : []string {"subdir/patch.yaml" , "subdir/file.txt" },
953+ },
925954 }
926955 for _ , tt := range tests {
927956 t .Run (tt .name , func (t * testing.T ) {
@@ -967,7 +996,10 @@ func TestDecryptor_decryptKustomizationSources(t *testing.T) {
967996
968997 visited := make (map [string ]struct {}, 0 )
969998 visit := d .decryptKustomizationSources (visited )
970- kus := & kustypes.Kustomization {SecretGenerator : tt .secretGenerator }
999+ kus := & kustypes.Kustomization {
1000+ Patches : tt .patch ,
1001+ SecretGenerator : tt .secretGenerator ,
1002+ }
9711003
9721004 err = visit (root , tt .path , kus )
9731005 if tt .wantErr == nil {
0 commit comments