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 <derek@mcg.dev>
This commit is contained in:
Derek McGowan 2023-12-29 11:29:43 -08:00
parent 02e0fef84b
commit cf6f439eb0
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -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,
},
},
}
}