-
Notifications
You must be signed in to change notification settings - Fork 193
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
feat: check product name file on linux for gce #469
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.
LGTM, thanks!
{ | ||
if (file_exists($productNameFile)) { | ||
$productName = trim((string) file_get_contents($productNameFile)); | ||
return 0 === strpos($productName, 'Google'); |
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.
Maybe lowercase is better?
return 0 === strpos($productName, 'Google'); | |
return 0 === strpos($productName, 'google'); |
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.
The is determined by the Operating system, and the string is uppercase (literally, Google
). So making it lowercase would fail the check.
Why do you think lowercase is better?
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.
My only question is: Should we normalize the contents (e.g. force lowercase) in order to avoid any sort of subtle issues with string matching/discrepancies in this file's contents?
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.
The Product Name is either Google
or Google Compute Engine
. The lowercase name google
is not valid (or at least, there are no known Operating Systems which use that). So there's no reason to add a check for the lowercase value.
To my knowledge, other language implementations have not included such a normalization
{ | ||
if (file_exists($productNameFile)) { | ||
$productName = trim((string) file_get_contents($productNameFile)); | ||
return 0 === strpos($productName, 'Google'); |
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.
My only question is: Should we normalize the contents (e.g. force lowercase) in order to avoid any sort of subtle issues with string matching/discrepancies in this file's contents?
cc @sai-sunder-s and @TimurSadykov