From cf6f439eb0b353152d0b78b3ff6005aab728d964 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Fri, 29 Dec 2023 11:29:43 -0800 Subject: [PATCH] Fix transfer plugin unpack configuration Remove default unpack configuration to prevent duplication of configuration from toml decoder appending to the default. When no unpack configuration is provided, use the default. Signed-off-by: Derek McGowan --- plugins/transfer/plugin.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/transfer/plugin.go b/plugins/transfer/plugin.go index 38972b29a..90185e78b 100644 --- a/plugins/transfer/plugin.go +++ b/plugins/transfer/plugin.go @@ -77,6 +77,17 @@ func init() { var lc local.TransferConfig lc.MaxConcurrentDownloads = config.MaxConcurrentDownloads lc.MaxConcurrentUploadedLayers = config.MaxConcurrentUploadedLayers + + // If UnpackConfiguration is not defined, set the default. + // If UnpackConfiguration is defined and empty, ignore. + if config.UnpackConfiguration == nil { + config.UnpackConfiguration = []unpackConfiguration{ + { + Platform: platforms.Format(platforms.DefaultSpec()), + Snapshotter: defaults.DefaultSnapshotter, + }, + } + } for _, uc := range config.UnpackConfiguration { p, err := platforms.Parse(uc.Platform) if err != nil { @@ -148,7 +159,7 @@ type transferConfig struct { MaxConcurrentUploadedLayers int `toml:"max_concurrent_uploaded_layers"` // UnpackConfiguration is used to read config from toml - UnpackConfiguration []unpackConfiguration `toml:"unpack_config"` + UnpackConfiguration []unpackConfiguration `toml:"unpack_config,omitempty"` // RegistryConfigPath is a path to the root directory containing registry-specific configurations RegistryConfigPath string `toml:"config_path"` @@ -169,11 +180,5 @@ func defaultConfig() *transferConfig { return &transferConfig{ MaxConcurrentDownloads: 3, MaxConcurrentUploadedLayers: 3, - UnpackConfiguration: []unpackConfiguration{ - { - Platform: platforms.Format(platforms.DefaultSpec()), - Snapshotter: defaults.DefaultSnapshotter, - }, - }, } }