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

gcp: refactor label key and value sanitization #7

Closed
wants to merge 1 commit into from

Conversation

joemiller
Copy link
Member

The previous logic did not properly sanitize the label values, as it only ensured length was within the 64 char limit. However, there are additional restrictions on labels and they are similar to the key restrictions.

The language from the GCP docs is:

Each resource can have up to 64 labels.
Each label must be a key-value pair.
Keys have a minimum length of 1 character and a maximum length of 63 characters, and cannot be empty. Values can be empty, and have a maximum length of 63 characters.
Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. Keys must start with a lowercase letter or international character.

The new logic attempts to follow all of these rules. The test cases have been expanded to reflect this as well.

The previous logic did not properly sanitize the label values, as it
only ensured length was within the 64 char limit. However, there are
additional restrictions on labels and they are similar to the key restrictions.

The language from the GCP docs is:

> Each resource can have up to 64 labels.
> Each label must be a key-value pair.
> Keys have a minimum length of 1 character and a maximum length of 63 characters, and cannot be empty. Values can be empty, and have a maximum length of 63 characters.
> Keys and values can contain only lowercase letters, numeric characters, underscores, and dashes. All characters must use UTF-8 encoding, and international characters are allowed. Keys must start with a lowercase letter or international character.

The new logic attempts to follow all of these rules. The test cases have
been expanded to reflect this as well.
@joemiller joemiller closed this Jan 12, 2025
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 this pull request may close these issues.

1 participant