INNER CODE UNIT · Go

handleVersion

pingcap/tidb-operator · cmd/crd-modifier/main.go:205

func handleVersion(version *apiextensionsv1.CustomResourceDefinitionVersion, keys ...string) {
	handleSelectedJSONSchemaProps(version.Schema.OpenAPIV3Schema, keys...)
}

func handleSelectedJSONSchemaProps(props *apiextensionsv1.JSONSchemaProps, keys ...string) {
	if len(keys) == 0 {
		// When the target path is reached, call handleJSONSchemaProps to remove the required fields.
		// `nil` is passed for retainKeys, which means no keys should be retained (i.e., all are removed).
		handleJSONSchemaProps(props, nil)
		return
	}

	key := keys[0]
	child, ok := props.Properties[key]
	if !ok {
		// If the path doesn't exist in the schema, it means this CRD doesn't have the expected structure.
		// This is not an error - just skip processing this path silently.
		fmt.Printf("Path %v not found in schema, skipping...\n", keys)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…