cri: add deprecation warning for configs
Signed-off-by: Samuel Karp <samuelkarp@google.com>
This commit is contained in:
		| @@ -401,6 +401,11 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) ([]deprecation.W | ||||
| 		log.G(ctx).Warning("`mirrors` is deprecated, please use `config_path` instead") | ||||
| 	} | ||||
|  | ||||
| 	if len(c.Registry.Configs) != 0 { | ||||
| 		warnings = append(warnings, deprecation.CRIRegistryConfigs) | ||||
| 		log.G(ctx).Warning("`configs` is deprecated, please use `config_path` instead") | ||||
| 	} | ||||
|  | ||||
| 	// Validation for deprecated auths options and mapping it to configs. | ||||
| 	if len(c.Registry.Auths) != 0 { | ||||
| 		if c.Registry.Configs == nil { | ||||
|   | ||||
| @@ -147,6 +147,45 @@ func TestValidateConfig(t *testing.T) { | ||||
| 			}, | ||||
| 			warnings: []deprecation.Warning{deprecation.CRIRegistryMirrors}, | ||||
| 		}, | ||||
| 		"deprecated configs": { | ||||
| 			config: &PluginConfig{ | ||||
| 				ContainerdConfig: ContainerdConfig{ | ||||
| 					DefaultRuntimeName: RuntimeDefault, | ||||
| 					Runtimes: map[string]Runtime{ | ||||
| 						RuntimeDefault: {}, | ||||
| 					}, | ||||
| 				}, | ||||
| 				Registry: Registry{ | ||||
| 					Configs: map[string]RegistryConfig{ | ||||
| 						"gcr.io": { | ||||
| 							Auth: &AuthConfig{ | ||||
| 								Username: "test", | ||||
| 							}, | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			expected: &PluginConfig{ | ||||
| 				ContainerdConfig: ContainerdConfig{ | ||||
| 					DefaultRuntimeName: RuntimeDefault, | ||||
| 					Runtimes: map[string]Runtime{ | ||||
| 						RuntimeDefault: { | ||||
| 							Sandboxer: string(ModePodSandbox), | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 				Registry: Registry{ | ||||
| 					Configs: map[string]RegistryConfig{ | ||||
| 						"gcr.io": { | ||||
| 							Auth: &AuthConfig{ | ||||
| 								Username: "test", | ||||
| 							}, | ||||
| 						}, | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			warnings: []deprecation.Warning{deprecation.CRIRegistryConfigs}, | ||||
| 		}, | ||||
| 		"privileged_without_host_devices_all_devices_allowed without privileged_without_host_devices": { | ||||
| 			config: &PluginConfig{ | ||||
| 				ContainerdConfig: ContainerdConfig{ | ||||
|   | ||||
| @@ -29,6 +29,8 @@ const ( | ||||
| 	CRIRegistryMirrors Warning = Prefix + "cri-registry-mirrors" | ||||
| 	// CRIRegistryAuths is a warning for the use of the `auths` property | ||||
| 	CRIRegistryAuths Warning = Prefix + "cri-registry-auths" | ||||
| 	// CRIRegistryConfigs is a warning for the use of the `configs` property | ||||
| 	CRIRegistryConfigs Warning = Prefix + "cri-registry-configs" | ||||
| ) | ||||
|  | ||||
| var messages = map[Warning]string{ | ||||
| @@ -39,6 +41,8 @@ var messages = map[Warning]string{ | ||||
| 		"Use `config_path` instead.", | ||||
| 	CRIRegistryAuths: "The `auths` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.3 and will be removed in containerd v2.0." + | ||||
| 		"Use `ImagePullSecrets` instead.", | ||||
| 	CRIRegistryConfigs: "The `configs` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.5 and will be removed in containerd v2.0." + | ||||
| 		"Use `config_path` instead.", | ||||
| } | ||||
|  | ||||
| // Valid checks whether a given Warning is valid | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Samuel Karp
					Samuel Karp