@@ -4,12 +4,12 @@ import (
44 . "github.com/mandelsoft/goutils/testutils"
55 . "github.com/onsi/ginkgo/v2"
66 . "github.com/onsi/gomega"
7-
8- . "ocm.software/ocm/api/helper/builder"
7+ "helm.sh/helm/v3/pkg/registry"
98
109 "github.com/mandelsoft/filepath/pkg/filepath"
1110 "github.com/mandelsoft/vfs/pkg/vfs"
1211
12+ . "ocm.software/ocm/api/helper/builder"
1313 envhelper "ocm.software/ocm/api/helper/env"
1414 "ocm.software/ocm/api/oci/artdesc"
1515 "ocm.software/ocm/api/oci/extensions/repositories/artifactset"
@@ -21,6 +21,7 @@ import (
2121 "ocm.software/ocm/api/ocm/selectors"
2222 "ocm.software/ocm/api/utils/accessio"
2323 "ocm.software/ocm/api/utils/accessobj"
24+ "ocm.software/ocm/api/utils/blobaccess/dirtree"
2425 "ocm.software/ocm/api/utils/tarutils"
2526)
2627
@@ -30,10 +31,11 @@ const (
3031 Version = "v1.0.0"
3132 OCIResource = "helm"
3233
33- ArtifactType = "NotHelmChart"
34- SpecialOCIResource = "specialhelm"
35- UnusualOCIResource = "unusualhelm"
36- LegacyOCIResource = "legacyhelm"
34+ ArtifactType = "NotHelmChart"
35+ SpecialOCIResource = "specialhelm"
36+ UnusualOCIResource = "unusualhelm"
37+ LegacyOCIResource = "legacyhelm"
38+ HelmViaChartMediaType = "helmviaaccess"
3739)
3840
3941var _ = Describe ("upload" , func () {
@@ -57,6 +59,9 @@ var _ = Describe("upload", func() {
5759 env .Resource (LegacyOCIResource , Version , resourcetypes .HELM_CHART , v1 .LocalRelation , func () {
5860 env .BlobFromFile (artifactset .MediaType (artdesc .MediaTypeImageManifest ), filepath .Join ("/testdata/legacy-pre-hip-helm-chart.tgz" ))
5961 })
62+ env .Resource (HelmViaChartMediaType , Version , resourcetypes .HELM_CHART , v1 .LocalRelation , func () {
63+ env .BlobFromDirTree ("/testdata/test-chart" , dirtree .WithMimeType (registry .ChartLayerMediaType ), dirtree .WithPreserveDir (true ), dirtree .WithCompressWithGzip (true ))
64+ })
6065 })
6166 })
6267 })
@@ -85,21 +90,47 @@ var _ = Describe("upload", func() {
8590
8691 It ("successfully download unusual artifacts with non-defacto helm chart order" , func () {
8792 MustBeSuccessful (download .RegisterHandlerByName (env , helm .PATH , nil , download .ForArtifactType (ArtifactType )))
88-
8993 repo := Must (ctf .Open (env .OCMContext (), accessobj .ACC_READONLY , CTFPath , 0o777 , env ))
9094 cv := Must (repo .LookupComponentVersion (Component , Version ))
9195 path := Must (download .DownloadResource (env .OCMContext (), Must (cv .SelectResources (selectors .Identity (v1.Identity {"name" : UnusualOCIResource })))[0 ], "/resource" , download .WithFileSystem (env .FileSystem ())))
9296 MustBeSuccessful (tarutils .ExtractArchiveToFs (env .FileSystem (), path , env .FileSystem ()))
9397 Expect (Must (vfs .FileExists (env .FileSystem (), "/postgresql/Chart.yaml" ))).To (BeTrue ())
9498 })
9599
96- It ("successfully download artifacts with helm chart content with legacy content type " , func () {
100+ It ("successfully download unusual artifacts with non-defacto helm chart order and path given to tgz " , func () {
97101 MustBeSuccessful (download .RegisterHandlerByName (env , helm .PATH , nil , download .ForArtifactType (ArtifactType )))
102+ repo := Must (ctf .Open (env .OCMContext (), accessobj .ACC_READONLY , CTFPath , 0o777 , env ))
103+ cv := Must (repo .LookupComponentVersion (Component , Version ))
104+ path := Must (download .DownloadResource (env .OCMContext (), Must (cv .SelectResources (selectors .Identity (v1.Identity {"name" : UnusualOCIResource })))[0 ], "/path.tgz" , download .WithFileSystem (env .FileSystem ())))
105+ MustBeSuccessful (tarutils .ExtractArchiveToFs (env .FileSystem (), path , env .FileSystem ()))
106+ Expect (Must (vfs .FileExists (env .FileSystem (), "/postgresql/Chart.yaml" ))).To (BeTrue ())
107+ })
98108
109+ It ("successfully download unusual artifacts with non-defacto helm chart order and path given to tar.gz" , func () {
110+ MustBeSuccessful (download .RegisterHandlerByName (env , helm .PATH , nil , download .ForArtifactType (ArtifactType )))
111+ repo := Must (ctf .Open (env .OCMContext (), accessobj .ACC_READONLY , CTFPath , 0o777 , env ))
112+ cv := Must (repo .LookupComponentVersion (Component , Version ))
113+ path := Must (download .DownloadResource (env .OCMContext (), Must (cv .SelectResources (selectors .Identity (v1.Identity {"name" : UnusualOCIResource })))[0 ], "/path.tar.gz" , download .WithFileSystem (env .FileSystem ())))
114+ MustBeSuccessful (tarutils .ExtractArchiveToFs (env .FileSystem (), path , env .FileSystem ()))
115+ Expect (Must (vfs .FileExists (env .FileSystem (), "/postgresql/Chart.yaml" ))).To (BeTrue ())
116+ })
117+
118+ It ("successfully download unusual artifacts with helm media type" , func () {
119+ MustBeSuccessful (download .RegisterHandlerByName (env , helm .PATH , nil , download .ForArtifactType (ArtifactType )))
120+ repo := Must (ctf .Open (env .OCMContext (), accessobj .ACC_READONLY , CTFPath , 0o777 , env ))
121+ cv := Must (repo .LookupComponentVersion (Component , Version ))
122+ path := Must (download .DownloadResource (env .OCMContext (), Must (cv .SelectResources (selectors .Identity (v1.Identity {"name" : HelmViaChartMediaType })))[0 ], "/resource" , download .WithFileSystem (env .FileSystem ())))
123+ MustBeSuccessful (tarutils .ExtractArchiveToFs (env .FileSystem (), path , env .FileSystem ()))
124+ Expect (Must (vfs .FileExists (env .FileSystem (), "test-chart/Chart.yaml" ))).To (BeTrue ())
125+ })
126+
127+ It ("successfully download artifacts with helm chart content with legacy content type" , func () {
128+ MustBeSuccessful (download .RegisterHandlerByName (env , helm .PATH , nil , download .ForArtifactType (ArtifactType )))
99129 repo := Must (ctf .Open (env .OCMContext (), accessobj .ACC_READONLY , CTFPath , 0o777 , env ))
100130 cv := Must (repo .LookupComponentVersion (Component , Version ))
101131 path := Must (download .DownloadResource (env .OCMContext (), Must (cv .SelectResources (selectors .Identity (v1.Identity {"name" : LegacyOCIResource })))[0 ], "/resource" , download .WithFileSystem (env .FileSystem ())))
102132 MustBeSuccessful (tarutils .ExtractArchiveToFs (env .FileSystem (), path , env .FileSystem ()))
103133 Expect (Must (vfs .FileExists (env .FileSystem (), "/ingress-nginx/Chart.yaml" ))).To (BeTrue ())
104134 })
135+
105136})
0 commit comments