mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
fix: compressedLayerExtracterStore+isCompressedLayer - allow tar.gzip suffixes (cherry-pick #26355 for 3.2) (#26375)
Signed-off-by: erin liman <erin.liman@tiktokusds.com> Co-authored-by: erin <6914822+nepeat@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
75eddbd910
commit
9c128e2d4c
@@ -430,7 +430,7 @@ func isContentLayer(mediaType string) bool {
|
||||
|
||||
func isCompressedLayer(mediaType string) bool {
|
||||
// TODO: Is zstd something which is used in the wild? For now let's stick to these suffixes
|
||||
return strings.HasSuffix(mediaType, "tar+gzip") || strings.HasSuffix(mediaType, "tar")
|
||||
return strings.HasSuffix(mediaType, "tar+gzip") || strings.HasSuffix(mediaType, "tar.gzip") || strings.HasSuffix(mediaType, "tar")
|
||||
}
|
||||
|
||||
func createTarFile(from, to string) error {
|
||||
@@ -531,7 +531,7 @@ func (s *compressedLayerExtracterStore) Push(ctx context.Context, desc imagev1.D
|
||||
}
|
||||
defer os.RemoveAll(srcDir)
|
||||
|
||||
if strings.HasSuffix(desc.MediaType, "tar+gzip") {
|
||||
if strings.HasSuffix(desc.MediaType, "tar+gzip") || strings.HasSuffix(desc.MediaType, "tar.gzip") {
|
||||
err = files.Untgz(srcDir, content, s.maxSize, false)
|
||||
} else {
|
||||
err = files.Untar(srcDir, content, s.maxSize, false)
|
||||
|
||||
@@ -254,6 +254,31 @@ func Test_nativeOCIClient_Extract(t *testing.T) {
|
||||
disableManifestMaxExtractedSize: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "extraction with docker rootfs tar.gzip layer",
|
||||
fields: fields{
|
||||
allowedMediaTypes: []string{"application/vnd.docker.image.rootfs.diff.tar.gzip"},
|
||||
},
|
||||
args: args{
|
||||
digestFunc: func(store *memory.Store) string {
|
||||
layerBlob := createGzippedTarWithContent(t, "foo.yaml", "some content")
|
||||
return generateManifest(t, store, layerConf{content.NewDescriptorFromBytes("application/vnd.docker.image.rootfs.diff.tar.gzip", layerBlob), layerBlob})
|
||||
},
|
||||
postValidationFunc: func(_, path string, _ Client, _ fields, _ args) {
|
||||
manifestDir, err := os.ReadDir(path)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, manifestDir, 1)
|
||||
require.Equal(t, "foo.yaml", manifestDir[0].Name())
|
||||
f, err := os.Open(filepath.Join(path, manifestDir[0].Name()))
|
||||
require.NoError(t, err)
|
||||
contents, err := io.ReadAll(f)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "some content", string(contents))
|
||||
},
|
||||
manifestMaxExtractedSize: 1000,
|
||||
disableManifestMaxExtractedSize: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "extraction with standard gzip layer using cache",
|
||||
fields: fields{
|
||||
|
||||
Reference in New Issue
Block a user