-
Notifications
You must be signed in to change notification settings - Fork 23
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
⭐️ Add device connection #4049
⭐️ Add device connection #4049
Conversation
|
||
import "go.mondoo.com/cnquery/v11/providers/os/connection/device/shared" | ||
|
||
type DeviceManager interface { |
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.
we can change this interface in the future to make this work better with mac/windows if needed
@@ -26,12 +26,12 @@ type VolumeMounter struct { | |||
// where we tell AWS to attach the volume; it doesn't necessarily get attached there, but we have to reference this same location when detaching | |||
VolumeAttachmentLoc string | |||
opts map[string]string | |||
cmdRunner *LocalCommandRunner | |||
CmdRunner *LocalCommandRunner | |||
} | |||
|
|||
func NewVolumeMounter(shell []string) *VolumeMounter { |
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.
we can move this entirely to device/linux
once we migrate the snapshot connections (AWS, Azure, GCP)
} | ||
if runtime.GOOS == "windows" { | ||
// shell = []string{"powershell", "-c"} | ||
return nil, errors.New("device manager not implemented for windows") |
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.
adding support for windows should be as simple as implementing the device manager and then ensuring it gets created here
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.
nice preparation
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.
Thank you @preslavgerchev
} | ||
if runtime.GOOS == "windows" { | ||
// shell = []string{"powershell", "-c"} | ||
return nil, errors.New("device manager not implemented for windows") |
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.
nice preparation
} | ||
log.Debug().Str("manager", manager.Name()).Msg("device manager created") | ||
|
||
mi, err := manager.IdentifyBlock(conf.Options) |
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.
Should we call this function IdentifyBlockDevice
?
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.
Going forward we should expect that this returns a list of block devices.
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.
great idea, adjusted, the code now returns a list. the connection stills works with a single device but we can adjust this when needed.
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.
👍 thank you!!
Signed-off-by: Preslav <[email protected]>
3894947
to
e1ad90e
Compare
This PR adds the initial version of the device connection. It's currently only supported on linux.
To run a best-effort (guess the device) scan:
To specify the actual device you want:
To specify a device by its LUN (specifically useful for azure vms):
The connection also supports injecting platform-ids: