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

Should array schema include "format" key? #141

Closed
alegacy opened this issue Feb 11, 2019 · 0 comments · Fixed by #143
Closed

Should array schema include "format" key? #141

alegacy opened this issue Feb 11, 2019 · 0 comments · Fixed by #143

Comments

@alegacy
Copy link
Contributor

alegacy commented Feb 11, 2019

Does it make sense to include the "format" key within a schema when the type is "array"? For example, I created an array of strings and wanted those strings to be formatted as IPv4 addresses. After fixing #123 to ensure that "format" keys are included for strings I found that the "format" key was included in both the array definition and the "items" definitions. I cannot think of a reason why the outer format would be required.

With this in my types.go struct:

	// +kubebuilder:validation:Format=ipv4
	// list of IP addresses
	Addresses []string `json:"addresses,omitempty"`

I get this in my CRD yaml (notice the "format: ipv4" at both the array and items levels). I am proposing to remove the one at the array level unless there is a reason for this that I have not yet uncovered:

        spec:
          properties:
            addresses:
              description: list of IP addresses
              format: ipv4
              items:
                format: ipv4
                type: string
              type: array
alegacy added a commit to alegacy/controller-tools that referenced this issue Feb 11, 2019
This commit removes the "format" key from array objects since any format
annotations on arrays are assumed to be applicable to the array items
rather than to the array itself.

Closes kubernetes-sigs#141

Signed-off-by: Allain Legacy <[email protected]>
alegacy added a commit to alegacy/controller-tools that referenced this issue Feb 11, 2019
This commit removes the "format" key from array objects since any format
annotations on arrays are assumed to be applicable to the array items
rather than to the array itself.

Closes kubernetes-sigs#141

Signed-off-by: Allain Legacy <[email protected]>
alegacy added a commit to alegacy/controller-tools that referenced this issue Feb 11, 2019
This commit removes the "format" key from array objects since any format
annotations on arrays are assumed to be applicable to the array items
rather than to the array itself.

Closes kubernetes-sigs#141

Signed-off-by: Allain Legacy <[email protected]>
alegacy added a commit to alegacy/controller-tools that referenced this issue Feb 13, 2019
This commit removes the "format" key from array objects since any format
annotations on arrays are assumed to be applicable to the array items
rather than to the array itself.  Byte arrays are handled as a special
case since they are represented as byte strings in the CRD YAML rather
than actual arrays.

Closes kubernetes-sigs#141

Signed-off-by: Allain Legacy <[email protected]>
alegacy added a commit to alegacy/controller-tools that referenced this issue Feb 14, 2019
This commit removes the "format" key from array objects since any format
annotations on arrays are assumed to be applicable to the array items
rather than to the array itself.  Byte arrays are handled as a special
case since they are represented as byte strings in the CRD YAML rather
than actual arrays.

Closes kubernetes-sigs#141

Signed-off-by: Allain Legacy <[email protected]>
alegacy added a commit to alegacy/controller-tools that referenced this issue Feb 15, 2019
This commit removes the "format" key from array objects since any format
annotations on arrays are assumed to be applicable to the array items
rather than to the array itself.  Byte arrays are handled as a special
case since they are represented as byte strings in the CRD YAML rather
than actual arrays.

Closes kubernetes-sigs#141

Signed-off-by: Allain Legacy <[email protected]>
justinsb added a commit to justinsb/controller-tools that referenced this issue May 20, 2024
justinsb added a commit to justinsb/controller-tools that referenced this issue May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant