go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/_motor/providers/provider.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package providers 5 6 type PlatformIdDetector string 7 8 const ( 9 HostnameDetector PlatformIdDetector = "hostname" 10 MachineIdDetector PlatformIdDetector = "machine-id" 11 CloudDetector PlatformIdDetector = "cloud-detect" 12 AWSEc2Detector PlatformIdDetector = "aws-ec2" 13 AWSEcsDetector PlatformIdDetector = "aws-ecs" 14 SshHostKey PlatformIdDetector = "ssh-host-key" 15 // TransportPlatformIdentifierDetector is a detector that gets the platform id 16 // from the transports Identifier() method. This requires the 17 // TransportIdentifier interface be implemented for the transport 18 TransportPlatformIdentifierDetector PlatformIdDetector = "transport-platform-id" 19 ) 20 21 func AvailablePlatformIdDetector() []string { 22 return []string{HostnameDetector.String(), MachineIdDetector.String(), AWSEc2Detector.String(), CloudDetector.String(), SshHostKey.String(), TransportPlatformIdentifierDetector.String()} 23 } 24 25 var platformIdAliases = map[string]PlatformIdDetector{ 26 "awsec2": AWSEc2Detector, 27 "machineid": MachineIdDetector, 28 } 29 30 func (id PlatformIdDetector) String() string { 31 return string(id) 32 } 33 34 func ToPlatformIdDetectors(idDetectors []string) []PlatformIdDetector { 35 idDetectorsCopy := make([]PlatformIdDetector, len(idDetectors)) 36 for i, v := range idDetectors { 37 if detector, ok := platformIdAliases[v]; ok { 38 idDetectorsCopy[i] = detector 39 } else { 40 idDetectorsCopy[i] = PlatformIdDetector(v) 41 } 42 } 43 return idDetectorsCopy 44 } 45 46 type Instance interface { 47 PlatformIdDetectors() []PlatformIdDetector 48 49 // returns if this is a static asset that does not allow run command 50 Capabilities() Capabilities 51 52 Runtime() string 53 54 // Close closes the transport 55 Close() 56 } 57 58 type PlatformIdentifier interface { 59 Identifier() (string, error) 60 }