mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-11 20:45:32 +08:00
reorganize profile service (#347)
Moved all the endpoints into the profile package. Defined a Store interface which includes all the used BoltDB methods. Moved the BoltDB implementation into a subpackage.
This commit is contained in:
59
cmd/mdmctl/setup.go
Normal file
59
cmd/mdmctl/setup.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/go-kit/kit/log"
|
||||
httptransport "github.com/go-kit/kit/transport/http"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/api/server/apply"
|
||||
"github.com/micromdm/micromdm/platform/api/server/list"
|
||||
"github.com/micromdm/micromdm/platform/api/server/remove"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
)
|
||||
|
||||
type remoteServices struct {
|
||||
profilesvc profile.Service
|
||||
applysvc apply.Service
|
||||
list list.Service
|
||||
remove remove.Service
|
||||
}
|
||||
|
||||
func setupClient(logger log.Logger) (*remoteServices, error) {
|
||||
cfg, err := LoadServerConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
applysvc, err := apply.NewClient(
|
||||
cfg.ServerURL, logger, cfg.APIToken,
|
||||
httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
profilesvc, err := profile.NewHTTPClient(
|
||||
cfg.ServerURL, cfg.APIToken, logger,
|
||||
httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
listsvc, err := list.NewClient(
|
||||
cfg.ServerURL, logger, cfg.APIToken,
|
||||
httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rmsvc, err := remove.NewClient(
|
||||
cfg.ServerURL, logger, cfg.APIToken,
|
||||
httptransport.SetClient(skipVerifyHTTPClient(cfg.SkipVerify)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &remoteServices{
|
||||
profilesvc: profilesvc,
|
||||
applysvc: applysvc,
|
||||
list: listsvc,
|
||||
remove: rmsvc,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user