feat: check product name file on linux for gce#469
Conversation
| { | ||
| if (file_exists($productNameFile)) { | ||
| $productName = trim((string) file_get_contents($productNameFile)); | ||
| return 0 === strpos($productName, 'Google'); |
There was a problem hiding this comment.
Maybe lowercase is better?
| return 0 === strpos($productName, 'Google'); | |
| return 0 === strpos($productName, 'google'); |
There was a problem hiding this comment.
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.
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.
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.
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