Skip to content

Commit cf6f439

Browse files
committed
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 <[email protected]>
1 parent 02e0fef commit cf6f439

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

plugins/transfer/plugin.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ func init() {
7777
var lc local.TransferConfig
7878
lc.MaxConcurrentDownloads = config.MaxConcurrentDownloads
7979
lc.MaxConcurrentUploadedLayers = config.MaxConcurrentUploadedLayers
80+
81+
// If UnpackConfiguration is not defined, set the default.
82+
// If UnpackConfiguration is defined and empty, ignore.
83+
if config.UnpackConfiguration == nil {
84+
config.UnpackConfiguration = []unpackConfiguration{
85+
{
86+
Platform: platforms.Format(platforms.DefaultSpec()),
87+
Snapshotter: defaults.DefaultSnapshotter,
88+
},
89+
}
90+
}
8091
for _, uc := range config.UnpackConfiguration {
8192
p, err := platforms.Parse(uc.Platform)
8293
if err != nil {
@@ -148,7 +159,7 @@ type transferConfig struct {
148159
MaxConcurrentUploadedLayers int `toml:"max_concurrent_uploaded_layers"`
149160

150161
// UnpackConfiguration is used to read config from toml
151-
UnpackConfiguration []unpackConfiguration `toml:"unpack_config"`
162+
UnpackConfiguration []unpackConfiguration `toml:"unpack_config,omitempty"`
152163

153164
// RegistryConfigPath is a path to the root directory containing registry-specific configurations
154165
RegistryConfigPath string `toml:"config_path"`
@@ -169,11 +180,5 @@ func defaultConfig() *transferConfig {
169180
return &transferConfig{
170181
MaxConcurrentDownloads: 3,
171182
MaxConcurrentUploadedLayers: 3,
172-
UnpackConfiguration: []unpackConfiguration{
173-
{
174-
Platform: platforms.Format(platforms.DefaultSpec()),
175-
Snapshotter: defaults.DefaultSnapshotter,
176-
},
177-
},
178183
}
179184
}

0 commit comments

Comments
 (0)