@@ -61,6 +61,16 @@ func init() {
6161 }
6262 mdb := m .(* metadata.DB )
6363
64+ // only set the default value of config path, if both mirrors and
65+ // config path are empty and we are on Linux.
66+ // This also makes sure that if the loaded config already contains both config path and mirrors
67+ // the validation will fail.
68+ if runtime .GOOS == "linux" {
69+ if config .Registry .ConfigPath == "" && len (config .Registry .Mirrors ) == 0 {
70+ config .Registry .ConfigPath = "/etc/containerd/certs.d:/etc/docker/certs.d"
71+ }
72+ }
73+
6474 if warnings , err := criconfig .ValidateImageConfig (ic .Context , & config ); err != nil {
6575 return nil , fmt .Errorf ("invalid cri image config: %w" , err )
6676 } else if len (warnings ) > 0 {
@@ -210,18 +220,6 @@ func migrateConfig(dst, src map[string]interface{}) {
210220 dst [key ] = val
211221 }
212222 }
213- if runtime .GOOS == "linux" {
214- if value , ok := dst ["registry" ]; ok {
215- regMap := value .(map [string ]any )
216- if configPath , ok := regMap ["config_path" ]; ok {
217- if configPath == "" {
218- // Fill in default from config_unix.go (DefaultImageConfig)
219- regMap ["config_path" ] = "/etc/containerd/certs.d:/etc/docker/certs.d"
220- }
221- }
222- dst ["registry" ] = regMap
223- }
224- }
225223
226224 containerdConf , ok := src ["containerd" ]
227225 if ! ok {
0 commit comments