MCPcopy Create free account
hub / github.com/OverloadBlitz/cloudcent-cli / InferOSFromPattern

Function InferOSFromPattern

internal/pulumi/resources/aws/ec2.go:12–27  ·  view source on GitHub ↗

InferOSFromPattern infers "linux" or "windows" from an AMI name pattern or SSM path. TODO: how to find other OS and software

(pattern string)

Source from the content-addressed store, hash-verified

10// InferOSFromPattern infers "linux" or "windows" from an AMI name pattern or SSM path.
11// TODO: how to find other OS and software
12func 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").
30func mockedOS(record resources.ResourceRecord) string {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected