-
Notifications
You must be signed in to change notification settings - Fork 0
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
[CMSP-217] Accept siteID key as either int or string #1
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This pull request modifies the sites-yml-validator to accept site IDs as either integers or strings in YAML configurations, addressing difficulties in PHP differentiating between integer and string keys.
- Modified
pkg/model/sites.go
to use string keys forDomainMapByEnvironment
type - Updated
pkg/validator/sites.go
with newisValidSiteID
function to validate site IDs - Added new test cases in
pkg/validator/sites_test.go
for string-based site IDs - Introduced new fixture files
valid_both_string_and_int_key.yml
andvalid_string_as_key.yml
to test mixed and string-only site ID representations
5 file(s) reviewed, 3 comment(s)
Edit PR Review Bot Settings
1: dev-srtest.pantheonsite.io | ||
"2": about.dev-srtest.pantheonsite.io | ||
"3": employee-resources.dev-srtest.pantheonsite.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Inconsistent key formatting for site IDs. Consider using quotes for all keys for consistency.
"30": dev-srtest.pantheonsite.io | ||
"2": about.dev-srtest.pantheonsite.io | ||
"3": employee-resources.dev-srtest.pantheonsite.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Ensure consistent quoting style for all string keys
if s[0:1] == "0" { | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: This check might reject valid site IDs like '0123'. Consider using a regex to check for leading zeros instead
As part of implementing pantheon-systems/terminus-yml-validator-plugin#1, I discovered it is difficult, if not impossible, for PHP to differentiate between siteID keys being an int, or a string that could be cast to an int.
Rather than jumping through a lot of hoops on the PHP side, I opted to make the go validator a bit more flexible.
TODO: