This commit is contained in:
Claire Wang 2023-09-13 15:45:14 -04:00
parent 4450a12ffc
commit ef76ece932
3 changed files with 22 additions and 27 deletions

View File

@ -5,10 +5,13 @@
// in a platform-independent manner.
package mdm
import "sync/atomic"
import (
"errors"
"sync/atomic"
)
type MDMHandler struct {
Settings *MDMSettings
Settings MDMSettings
}
var mdmHandler atomic.Value // of MDMHandler type
@ -21,7 +24,7 @@ type MDMSettings interface {
ReadString(key string) (string, error)
}
func RegisterMDMSettings(settings *MDMSettings) *MDMHandler {
func RegisterMDMSettings(settings MDMSettings) *MDMHandler {
if e, ok := mdmHandler.Load().(*MDMHandler); ok {
return e
}
@ -29,3 +32,19 @@ func RegisterMDMSettings(settings *MDMSettings) *MDMHandler {
mdmHandler.Store(e)
return e
}
func ReadBool(key string) (bool, error) {
h := mdmHandler.Load().(*MDMHandler)
if h == nil {
return false, errors.New("nil handler")
}
return h.Settings.ReadBool(key)
}
func ReadString(key string) (string, error) {
h := mdmHandler.Load().(*MDMHandler)
if h == nil {
return "", errors.New("nil handler")
}
return h.Settings.ReadString(key)
}

View File

@ -1,5 +0,0 @@
package mdm
func NewAppleMDMHandler(settings *MDMSettings) *MDMHandler {
return &MDMHandler{Settings: settings}
}

View File

@ -1,19 +0,0 @@
//go:build windows
package mdm
func NewWindowsMDMHandler(settings *MDMSettings) *MDMHandler {
return &MDMHandler{Settings: settings}
}
// readRegistryBool reads a boolean value with the given key from the Windows registry.
func readRegistryBool(key string) (bool, error) {
// TODO(angott): Windows support
return false, nil
}
// readRegistryBool reads a string value with the given key from the Windows registry.
func readRegistryString(key string) (string, error) {
// TODO(angott): Windows support
return "", nil
}