Skip to content

Commit 72ba720

Browse files
committed
review changes
Signed-off-by: Łukasz Jakimczuk <[email protected]>
1 parent 221fb9e commit 72ba720

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

internal/decryptor/decryptor.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -573,19 +573,14 @@ func (d *Decryptor) decryptKustomizationSources(visited map[string]struct{}) vis
573573
continue
574574
}
575575

576-
u, err := url.Parse(patch.Path)
577-
if err != nil {
578-
return err
579-
}
580-
581-
if u.IsAbs() {
576+
if isRemoteURL(patch.Path) {
582577
continue
583578
}
584579

585580
// Determine the format for the patch, defaulting to YAML if not specified.
586581
format := formatForPath(patch.Path)
587582
// Visit the patch reference and attempt to decrypt it.
588-
if err = visitRef(patch.Path, format); err != nil {
583+
if err := visitRef(patch.Path, format); err != nil {
589584
return err
590585
}
591586
}
@@ -847,6 +842,17 @@ func recurseKustomizationFiles(root, path string, visit visitKustomization, visi
847842
return nil
848843
}
849844

845+
func isRemoteURL(path string) bool {
846+
u, err := url.Parse(path)
847+
if err != nil {
848+
return false
849+
}
850+
851+
// A remote URL will have a scheme (like "http", "https", "ssh")
852+
// AND a host (like "example.com").
853+
return u.Scheme != "" && u.Host != ""
854+
}
855+
850856
// isSOPSEncryptedResource detects if the given resource is a SOPS' encrypted
851857
// resource by looking for ".sops" and ".sops.mac" fields.
852858
func isSOPSEncryptedResource(res *resource.Resource) bool {

internal/decryptor/decryptor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ func TestDecryptor_decryptKustomizationSources(t *testing.T) {
936936
},
937937
{
938938
// this patch gets ignored due to being remote
939-
Path: "https:/raw.githubusercontent.com/kubernetes-sigs/kustomize/master/examples/wordpress/patch.yaml",
939+
Path: "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/examples/wordpress/patch.yaml",
940940
},
941941
},
942942
secretGenerator: []kustypes.SecretArgs{

0 commit comments

Comments
 (0)