This repository was archived by the owner on Aug 14, 2020. It is now read-only.
spec: Define ACString type and use it for labels values#590
Open
sgotti wants to merge 1 commit intoappc:masterfrom
Open
spec: Define ACString type and use it for labels values#590sgotti wants to merge 1 commit intoappc:masterfrom
sgotti wants to merge 1 commit intoappc:masterfrom
Conversation
Having a label value being a freeform string is coumbersome to use and query since it can contains non printable characters. Also having it unlimited can bring to other problems. This patch adds a ACString type that: * is restricted to all unicode printable characters. Such characters include letters, marks, numbers, punctuation, symbols, and the ASCII space character, from unicode categories L, M, N, P, S and the ASCII space character. * it MUST be UTF-8 encoded * it MUST be be 255 characters or less (not bytes). This patch starts using this new type for labels values. Some notes: * There isn't a regexp to match the valid chars. In Go we can use unicode.IsPrint or strconv.IsPrint * This defines that the string MUST be UTF-8 (needed to correctly count the number of characters) but this assumption is done everywhere (for example json string marshall/unmarshall) when a string is involved. So this should probably be defined at the top of the spec?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is related to discussion in #586.
I tried to put some limits on the freeform string trying to keep all the possible use cases (and only ACIs with very strange labels will be broken by this change) without limiting them to only ASCII characters . For example kubernetes has very big limits on label values and force it to be <= 63 chars (http://kubernetes.io/docs/user-guide/labels/).
About the max number of chars I just choosed 255 as a number but it can be changed.
spec: Define ACString type and use it for labels values
Having a label value being a freeform string is coumbersome to use and
query since it can contains non printable characters.
Also having it unlimited can bring to other problems.
This patch adds a ACString type that:
include letters, marks, numbers, punctuation, symbols, and the ASCII
space character, from unicode categories L, M, N, P, S and the ASCII
space character.
This patch starts using this new type for labels values.
Some notes:
unicode.IsPrint or strconv.IsPrint
the number of characters) but this assumption is done everywhere (for
example json string marshall/unmarshall) when a string is involved. So
this should probably be defined at the top of the spec?