Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[validation-gen] failed to compile generated validation file in pkg/apis/core/v1 #42

Closed
yongruilin opened this issue Nov 5, 2024 · 0 comments
Assignees

Comments

@yongruilin
Copy link
Collaborator

yongruilin commented Nov 5, 2024

What happened?

Failed to compile generated validation file in pkg/apis/core/v1 for zz_generated.validation.go

Causes:

  1. optional and required can only take in comparable type. e.g.
    if e := validate.Optional(opCtx, fldPath, obj, oldObj); len(e) != 0 {
    , where "corev1.NodeAffinity" is non-comparable
  2. optional and required validation may take in non-pointer variable, e.g. []string:
    func(obj, oldObj []corev1.Capability, fldPath *field.Path) (errs field.ErrorList) {
    if e := validate.Optional(opCtx, fldPath, obj, oldObj); len(e) != 0 {
    return // do not proceed
    }
    return
  3. No validation is generated for metav1 e.g.
    errs = append(errs, metav1.Validate_ListMeta(opCtx, obj, oldObj, fldPath)...)
  4. The validation input should be a pointer for the safe.Field e.g.
    return Validate_NodeStatus(opCtx, &root.Status, safe.Field(safe.Cast[*corev1.Node](oldObj), func(oldObj *corev1.Node) corev1.NodeStatus { return oldObj.Status }), nil)

What did you expect to happen?

Successfully compiled.

How can we reproduce it (as minimally and precisely as possible)?

go build ./pkg/apis/core/v1  

Anything else we need to know?

No response

Kubernetes version

$ kubectl version
# paste output here

Cloud provider

OS version

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants