go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/providers/os/resources/uptime/uptime.go (about) 1 // Copyright (c) Mondoo, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 package uptime 5 6 import ( 7 "errors" 8 "time" 9 10 "go.mondoo.com/cnquery/providers-sdk/v1/inventory" 11 "go.mondoo.com/cnquery/providers/os/connection/shared" 12 ) 13 14 type Uptime interface { 15 Name() string 16 Duration() (time.Duration, error) 17 } 18 19 func New(conn shared.Connection) (Uptime, error) { 20 pf := conn.Asset().Platform 21 22 switch { 23 case pf.IsFamily(inventory.FAMILY_UNIX): 24 return &Unix{conn: conn}, nil 25 case pf.IsFamily(inventory.FAMILY_WINDOWS): 26 return &Windows{conn: conn}, nil 27 default: 28 return nil, errors.New("your platform is not supported by reboot resource") 29 } 30 }