Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aaron-prindle/3b537688ad7f588688ce5705cfffa6a6 to your computer and use it in GitHub Desktop.
Save aaron-prindle/3b537688ad7f588688ce5705cfffa6a6 to your computer and use it in GitHub Desktop.
/*
Copyright 2025 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// +k8s:validation-gen=TypeMeta
// +k8s:validation-gen-scheme-registry=k8s.io/code-generator/cmd/validation-gen/testscheme.Scheme
// This is a test package.
package subfield
import "k8s.io/code-generator/cmd/validation-gen/testscheme"
var localSchemeBuilder = testscheme.New()
type Struct struct {
TypeMeta int `json:"typeMeta"`
// +k8s:listType=map
// +k8s:listMapKey=key
// +k8s:item(key: "target")=+k8s:subfield(stringField)=+k8s:validateFalse="item Items[key=target].stringField"
Items []Item `json:"items"`
// +k8s:listType=map
// +k8s:listMapKey=key
// +k8s:item(key: "ratchet")=+k8s:subfield(status)=+k8s:neq="forbidden"
RatchetItems []RatchetItem `json:"ratchetItems"`
}
type Item struct {
Key string `json:"key"`
StringField string `json:"stringField"`
}
type RatchetItem struct {
Key string `json:"key"`
Status string `json:"status"`
Version int `json:"version"`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment