go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/reboot/reboot.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  package reboot
     5  
     6  import (
     7  	"errors"
     8  
     9  	"go.mondoo.com/cnquery/providers-sdk/v1/inventory"
    10  	"go.mondoo.com/cnquery/providers/os/connection/shared"
    11  )
    12  
    13  type Reboot interface {
    14  	Name() string
    15  	RebootPending() (bool, error)
    16  }
    17  
    18  func New(conn shared.Connection) (Reboot, error) {
    19  	pf := conn.Asset().Platform
    20  
    21  	switch {
    22  	case pf.IsFamily("debian"):
    23  		return &DebianReboot{conn: conn}, nil
    24  	case pf.IsFamily("redhat") || pf.Name == "amazonlinux":
    25  		return &RpmNewestKernel{conn: conn}, nil
    26  	case pf.IsFamily(inventory.FAMILY_WINDOWS):
    27  		return &WinReboot{conn: conn}, nil
    28  	default:
    29  		return nil, errors.New("your platform is not supported by reboot resource")
    30  	}
    31  }