InferOSFromPattern infers "linux" or "windows" from an AMI name pattern or SSM path. TODO: how to find other OS and software
(pattern string)
| 10 | // InferOSFromPattern infers "linux" or "windows" from an AMI name pattern or SSM path. |
| 11 | // TODO: how to find other OS and software |
| 12 | func InferOSFromPattern(pattern string) (string, bool) { |
| 13 | lower := strings.ToLower(pattern) |
| 14 | windowsKeywords := []string{"windows", "win2019", "win2022", "win2016", "win2012"} |
| 15 | for _, kw := range windowsKeywords { |
| 16 | if strings.Contains(lower, kw) { |
| 17 | return "windows", true |
| 18 | } |
| 19 | } |
| 20 | linuxKeywords := []string{"linux", "ubuntu", "debian", "rhel", "redhat", "red-hat", "centos", "suse", "amzn", "amazon-linux", "al2023", "al2"} |
| 21 | for _, kw := range linuxKeywords { |
| 22 | if strings.Contains(lower, kw) { |
| 23 | return "linux", true |
| 24 | } |
| 25 | } |
| 26 | return "", false |
| 27 | } |
| 28 | |
| 29 | // mockedOS returns the collector-inferred OS from MockedProperties ("linux" or "windows"). |
| 30 | func mockedOS(record resources.ResourceRecord) string { |
nothing calls this directly
no outgoing calls
no test coverage detected