PR-3051: Fix download deploy package out of k8s cluster (#3136)

* Fix download deploy package out of k8s cluster

Signed-off-by: LiuXiang <lx1036@126.com>

* Fix pkg getdeploy cli command to fetch pkgs stored in storagesvc and remote pkgs

Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>

* Instead of Contains, parse url and check path for better validation

Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>

---------

Signed-off-by: LiuXiang <lx1036@126.com>
Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>
Co-authored-by: LiuXiang <lx1036@126.com>
This commit is contained in:
soharab-ic
2025-01-13 12:55:50 +05:30
committed by GitHub
co-authored by LiuXiang
parent cd23fc6f63
commit a8157e94a9
2 changed files with 66 additions and 2 deletions
@@ -32,3 +32,35 @@ func TestPrintPackageSummary(t *testing.T) {
t.Errorf("PrintPackageBuildLog() = %v, want %v", gotWriter, expected)
}
}
func TestValidArchiveURL(t *testing.T) {
tests := []struct {
name string
url string
expected bool
}{
{
name: "Valid Archive URL",
url: "http://storagesvc.fission/v1/archive?id=/fission/fission-functions/Fc4c15f47-bb49-47c5-b382-526a6539841d",
expected: true,
},
{
name: "Invalid Archive URL",
url: "https://raw.githubusercontent.com/imaginery/training/refs/heads/fission/hello-go?token=ABCD",
expected: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := validArchiveURL(tt.url)
if err != nil {
t.Errorf("got error %v", err)
}
if got != tt.expected {
t.Errorf("expected %t got %t", got, tt.expected)
}
})
}
}