mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-05 08:55:51 +08:00
organize essential APIs into platform, workflow and pkg folders (#337)
Add more logic to the way code is organized. /pkg -- library code not directly connected to micromdm /mdm -- packages meant for the services devices interract with. The MDM protocol. /dep -- DEP API and related packages. /platform -- Core APIs the server provides. Commands API, Devices API, queue, pubsub etc. /workflow -- Packages/API that build on top of platform. Today that's the webhook package. Depending on what ends up here, the workflow folder might become its own repository.
This commit is contained in:
@@ -12,11 +12,12 @@ import (
|
||||
|
||||
"github.com/go-kit/kit/log"
|
||||
httptransport "github.com/go-kit/kit/transport/http"
|
||||
"github.com/micromdm/micromdm/blueprint"
|
||||
"github.com/micromdm/micromdm/core/apply"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
"github.com/pkg/errors"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/apiserver/apply"
|
||||
"github.com/micromdm/micromdm/platform/blueprint"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
)
|
||||
|
||||
type applyCommand struct {
|
||||
|
||||
@@ -16,8 +16,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/groob/plist"
|
||||
"github.com/micromdm/micromdm/appmanifest"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/mdm/appmanifest"
|
||||
)
|
||||
|
||||
func (cmd *applyCommand) applyApp(args []string) error {
|
||||
|
||||
@@ -11,8 +11,9 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/micromdm/dep"
|
||||
"github.com/micromdm/micromdm/crypto"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/pkg/crypto"
|
||||
)
|
||||
|
||||
func certificatesFromURL(serverURL string, insecure bool) ([]*x509.Certificate, error) {
|
||||
|
||||
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/groob/plist"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/crypto/password"
|
||||
"github.com/micromdm/micromdm/user"
|
||||
"github.com/micromdm/micromdm/pkg/crypto/password"
|
||||
"github.com/micromdm/micromdm/platform/user"
|
||||
)
|
||||
|
||||
func (cmd *applyCommand) applyUser(args []string) error {
|
||||
|
||||
@@ -14,9 +14,10 @@ import (
|
||||
|
||||
"github.com/go-kit/kit/log"
|
||||
httptransport "github.com/go-kit/kit/transport/http"
|
||||
"github.com/micromdm/micromdm/core/list"
|
||||
"github.com/micromdm/micromdm/crypto"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/pkg/crypto"
|
||||
"github.com/micromdm/micromdm/platform/apiserver/list"
|
||||
)
|
||||
|
||||
type getCommand struct {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"os"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/micromdm/micromdm/core/list"
|
||||
"github.com/micromdm/micromdm/platform/apiserver/list"
|
||||
)
|
||||
|
||||
type appsTableOutput struct{ w *tabwriter.Writer }
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/core/list"
|
||||
"github.com/micromdm/micromdm/platform/apiserver/list"
|
||||
)
|
||||
|
||||
type usersTableOutput struct{ w *tabwriter.Writer }
|
||||
|
||||
@@ -17,9 +17,9 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/crypto/pkcs12"
|
||||
|
||||
"github.com/micromdm/micromdm/config"
|
||||
"github.com/micromdm/micromdm/crypto"
|
||||
"github.com/micromdm/micromdm/crypto/mdmcertutil"
|
||||
"github.com/micromdm/micromdm/pkg/crypto"
|
||||
"github.com/micromdm/micromdm/pkg/crypto/mdmcertutil"
|
||||
"github.com/micromdm/micromdm/platform/config"
|
||||
)
|
||||
|
||||
type mdmcertCommand struct{}
|
||||
|
||||
@@ -8,7 +8,8 @@ import (
|
||||
"github.com/go-kit/kit/log"
|
||||
|
||||
httptransport "github.com/go-kit/kit/transport/http"
|
||||
"github.com/micromdm/micromdm/core/remove"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/apiserver/remove"
|
||||
)
|
||||
|
||||
type removeCommand struct {
|
||||
|
||||
@@ -19,48 +19,46 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fullsailor/pkcs7"
|
||||
"github.com/groob/finalizer/logutil"
|
||||
"github.com/micromdm/go4/env"
|
||||
"github.com/micromdm/go4/version"
|
||||
"golang.org/x/crypto/acme/autocert"
|
||||
"golang.org/x/crypto/pkcs12"
|
||||
|
||||
"github.com/RobotsAndPencils/buford/push"
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/fullsailor/pkcs7"
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/go-kit/kit/log"
|
||||
"github.com/go-kit/kit/log/level"
|
||||
httptransport "github.com/go-kit/kit/transport/http"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/groob/finalizer/logutil"
|
||||
"github.com/micromdm/dep"
|
||||
"github.com/micromdm/go4/env"
|
||||
"github.com/micromdm/go4/httputil"
|
||||
"github.com/micromdm/go4/version"
|
||||
boltdepot "github.com/micromdm/scep/depot/bolt"
|
||||
scep "github.com/micromdm/scep/server"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/crypto/acme/autocert"
|
||||
"golang.org/x/crypto/pkcs12"
|
||||
|
||||
"github.com/micromdm/micromdm/appstore"
|
||||
"github.com/micromdm/micromdm/blueprint"
|
||||
"github.com/micromdm/micromdm/command"
|
||||
configsvc "github.com/micromdm/micromdm/config"
|
||||
"github.com/micromdm/micromdm/core/apply"
|
||||
"github.com/micromdm/micromdm/core/list"
|
||||
"github.com/micromdm/micromdm/core/remove"
|
||||
"github.com/micromdm/micromdm/crypto"
|
||||
"github.com/micromdm/micromdm/dep/depsync"
|
||||
"github.com/micromdm/micromdm/dep/deptoken"
|
||||
"github.com/micromdm/micromdm/device"
|
||||
"github.com/micromdm/micromdm/mdm/checkin"
|
||||
"github.com/micromdm/micromdm/mdm/connect"
|
||||
"github.com/micromdm/micromdm/mdm/enroll"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/pubsub/inmem"
|
||||
nanopush "github.com/micromdm/micromdm/push"
|
||||
"github.com/micromdm/micromdm/queue"
|
||||
"github.com/micromdm/micromdm/user"
|
||||
"github.com/micromdm/micromdm/webhook"
|
||||
"github.com/micromdm/micromdm/pkg/crypto"
|
||||
"github.com/micromdm/micromdm/platform/apiserver/apply"
|
||||
"github.com/micromdm/micromdm/platform/apiserver/list"
|
||||
"github.com/micromdm/micromdm/platform/apiserver/remove"
|
||||
"github.com/micromdm/micromdm/platform/apns"
|
||||
"github.com/micromdm/micromdm/platform/appstore"
|
||||
"github.com/micromdm/micromdm/platform/blueprint"
|
||||
"github.com/micromdm/micromdm/platform/command"
|
||||
"github.com/micromdm/micromdm/platform/config"
|
||||
"github.com/micromdm/micromdm/platform/device"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/pubsub/inmem"
|
||||
"github.com/micromdm/micromdm/platform/queue"
|
||||
"github.com/micromdm/micromdm/platform/user"
|
||||
"github.com/micromdm/micromdm/workflow/webhook"
|
||||
)
|
||||
|
||||
const homePage = `<!doctype html>
|
||||
@@ -126,7 +124,7 @@ func serve(args []string) error {
|
||||
if err := os.MkdirAll(*flConfigPath, 0755); err != nil {
|
||||
return errors.Wrapf(err, "creating config directory %s", *flConfigPath)
|
||||
}
|
||||
sm := &config{
|
||||
sm := &server{
|
||||
configPath: *flConfigPath,
|
||||
ServerPublicURL: strings.TrimRight(*flServerURL, "/"),
|
||||
APNSCertificatePath: *flAPNSCertPath,
|
||||
@@ -193,17 +191,17 @@ func serve(args []string) error {
|
||||
ctx := context.Background()
|
||||
httpLogger := log.With(logger, "transport", "http")
|
||||
|
||||
var configHandlers configsvc.HTTPHandlers
|
||||
var configHandlers config.HTTPHandlers
|
||||
{
|
||||
pushCertEndpoint := configsvc.MakeSavePushCertificateEndpoint(sm.configService)
|
||||
configEndpoints := configsvc.Endpoints{
|
||||
pushCertEndpoint := config.MakeSavePushCertificateEndpoint(sm.configService)
|
||||
configEndpoints := config.Endpoints{
|
||||
SavePushCertificateEndpoint: pushCertEndpoint,
|
||||
}
|
||||
configOpts := []httptransport.ServerOption{
|
||||
httptransport.ServerErrorLogger(httpLogger),
|
||||
httptransport.ServerErrorEncoder(checkin.EncodeError),
|
||||
}
|
||||
configHandlers = configsvc.MakeHTTPHandlers(ctx, configEndpoints, configOpts...)
|
||||
configHandlers = config.MakeHTTPHandlers(ctx, configEndpoints, configOpts...)
|
||||
}
|
||||
|
||||
var checkinHandlers checkin.HTTPHandlers
|
||||
@@ -218,16 +216,16 @@ func serve(args []string) error {
|
||||
checkinHandlers = checkin.MakeHTTPHandlers(ctx, e, opts...)
|
||||
}
|
||||
|
||||
var pushHandlers nanopush.HTTPHandlers
|
||||
var pushHandlers apns.HTTPHandlers
|
||||
{
|
||||
e := nanopush.Endpoints{
|
||||
PushEndpoint: nanopush.MakePushEndpoint(sm.pushService),
|
||||
e := apns.Endpoints{
|
||||
PushEndpoint: apns.MakePushEndpoint(sm.pushService),
|
||||
}
|
||||
opts := []httptransport.ServerOption{
|
||||
httptransport.ServerErrorLogger(httpLogger),
|
||||
httptransport.ServerErrorEncoder(checkin.EncodeError),
|
||||
}
|
||||
pushHandlers = nanopush.MakeHTTPHandlers(ctx, e, opts...)
|
||||
pushHandlers = apns.MakeHTTPHandlers(ctx, e, opts...)
|
||||
}
|
||||
|
||||
var commandHandlers command.HTTPHandlers
|
||||
@@ -473,7 +471,7 @@ func printExamples() {
|
||||
fmt.Println(exampleText)
|
||||
}
|
||||
|
||||
type config struct {
|
||||
type server struct {
|
||||
configPath string
|
||||
depsim string
|
||||
pubclient pubsub.PublishSubscriber
|
||||
@@ -487,7 +485,7 @@ type config struct {
|
||||
tlsCertPath string
|
||||
scepDepot *boltdepot.Depot
|
||||
profileDB *profile.DB
|
||||
configDB *configsvc.DB
|
||||
configDB *config.DB
|
||||
CommandWebhookURL string
|
||||
|
||||
// TODO: refactor enroll service and remove the need to reference
|
||||
@@ -496,13 +494,13 @@ type config struct {
|
||||
scepCACertPath string
|
||||
|
||||
PushService *push.Service // bufford push
|
||||
pushService nanopush.Service
|
||||
pushService apns.Service
|
||||
checkinService checkin.Service
|
||||
connectService connect.ConnectService
|
||||
enrollService enroll.Service
|
||||
scepService scep.Service
|
||||
commandService command.Service
|
||||
configService configsvc.Service
|
||||
configService config.Service
|
||||
|
||||
responseWebhook *webhook.CommandWebhook
|
||||
webhooksHTTPClient *http.Client
|
||||
@@ -510,21 +508,21 @@ type config struct {
|
||||
err error
|
||||
}
|
||||
|
||||
func (c *config) setupPubSub() {
|
||||
func (c *server) setupPubSub() {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
c.pubclient = inmem.NewPubSub()
|
||||
}
|
||||
|
||||
func (c *config) setupCommandService() {
|
||||
func (c *server) setupCommandService() {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
c.commandService, c.err = command.New(c.db, c.pubclient)
|
||||
}
|
||||
|
||||
func (c *config) setupWebhooks() {
|
||||
func (c *server) setupWebhooks() {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
@@ -542,7 +540,7 @@ func (c *config) setupWebhooks() {
|
||||
c.responseWebhook = h
|
||||
}
|
||||
|
||||
func (c *config) startWebhooks() {
|
||||
func (c *server) startWebhooks() {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
@@ -552,7 +550,7 @@ func (c *config) startWebhooks() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *config) setupCommandQueue(logger log.Logger) {
|
||||
func (c *server) setupCommandQueue(logger log.Logger) {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
@@ -578,14 +576,14 @@ func (c *config) setupCommandQueue(logger log.Logger) {
|
||||
c.connectService = connectService
|
||||
}
|
||||
|
||||
func (c *config) setupCheckinService() {
|
||||
func (c *server) setupCheckinService() {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
c.checkinService, c.err = checkin.New(c.db, c.pubclient)
|
||||
}
|
||||
|
||||
func (c *config) setupBolt() {
|
||||
func (c *server) setupBolt() {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
@@ -598,7 +596,7 @@ func (c *config) setupBolt() {
|
||||
c.db = db
|
||||
}
|
||||
|
||||
func (c *config) loadPushCerts() {
|
||||
func (c *server) loadPushCerts() {
|
||||
if c.APNSCertificatePath == "" && c.APNSPrivateKeyPass == "" && c.APNSPrivateKeyPath == "" {
|
||||
// this is optional, config could also be provided with mdmctl
|
||||
return
|
||||
@@ -660,26 +658,26 @@ type pushServiceCert struct {
|
||||
PrivateKey interface{}
|
||||
}
|
||||
|
||||
func (c *config) setupConfigStore() {
|
||||
func (c *server) setupConfigStore() {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
db, err := configsvc.NewDB(c.db, c.pubclient)
|
||||
db, err := config.NewDB(c.db, c.pubclient)
|
||||
if err != nil {
|
||||
c.err = err
|
||||
return
|
||||
}
|
||||
c.configDB = db
|
||||
c.configService = configsvc.NewService(db)
|
||||
c.configService = config.NewService(db)
|
||||
|
||||
}
|
||||
|
||||
func (c *config) setupPushService(logger log.Logger) {
|
||||
func (c *server) setupPushService(logger log.Logger) {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
var opts []nanopush.Option
|
||||
var opts []apns.Option
|
||||
{
|
||||
cert, _ := c.configDB.PushCertificate()
|
||||
if c.pushCert.Certificate != nil && cert == nil {
|
||||
@@ -698,28 +696,28 @@ func (c *config) setupPushService(logger log.Logger) {
|
||||
return
|
||||
}
|
||||
svc := push.NewService(client, push.Production)
|
||||
opts = append(opts, nanopush.WithPushService(svc))
|
||||
opts = append(opts, apns.WithPushService(svc))
|
||||
}
|
||||
after:
|
||||
|
||||
db, err := nanopush.NewDB(c.db, c.pubclient)
|
||||
db, err := apns.NewDB(c.db, c.pubclient)
|
||||
if err != nil {
|
||||
c.err = err
|
||||
return
|
||||
}
|
||||
|
||||
service, err := nanopush.New(db, c.configDB, c.pubclient, opts...)
|
||||
service, err := apns.New(db, c.configDB, c.pubclient, opts...)
|
||||
if err != nil {
|
||||
c.err = errors.Wrap(err, "starting micromdm push service")
|
||||
return
|
||||
}
|
||||
c.pushService = nanopush.NewLoggingService(
|
||||
c.pushService = apns.NewLoggingService(
|
||||
service,
|
||||
log.With(level.Info(logger), "component", "push"),
|
||||
)
|
||||
}
|
||||
|
||||
func (c *config) setupEnrollmentService() {
|
||||
func (c *server) setupEnrollmentService() {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
@@ -759,7 +757,7 @@ func (p staticTopicProvider) PushTopic() (string, error) {
|
||||
return p.topic, nil
|
||||
}
|
||||
|
||||
func (c *config) depClient() (dep.Client, error) {
|
||||
func (c *server) depClient() (dep.Client, error) {
|
||||
if c.err != nil {
|
||||
return nil, c.err
|
||||
}
|
||||
@@ -808,7 +806,7 @@ func (c *config) depClient() (dep.Client, error) {
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func (c *config) setupDEPSync() {
|
||||
func (c *server) setupDEPSync() {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
@@ -828,7 +826,7 @@ func (c *config) setupDEPSync() {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *config) setupSCEP(logger log.Logger) {
|
||||
func (c *server) setupSCEP(logger log.Logger) {
|
||||
if c.err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ func TestLoadPushCerts(t *testing.T) {
|
||||
p12path := "testdata/pushcert.p12"
|
||||
keysecret := "secret"
|
||||
|
||||
cfg := &config{
|
||||
cfg := &server{
|
||||
APNSPrivateKeyPath: keypath,
|
||||
APNSCertificatePath: certpath,
|
||||
APNSPrivateKeyPass: keysecret,
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/dep/deptoken"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -10,8 +10,9 @@ import (
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/micromdm/dep"
|
||||
"github.com/micromdm/micromdm/crypto"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
|
||||
"github.com/micromdm/micromdm/pkg/crypto"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
// CheckinBucket is the *bolt.DB bucket where checkins are archived.
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"github.com/micromdm/mdm"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/queue"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/queue"
|
||||
)
|
||||
|
||||
const ConnectTopic = "mdm.Connect"
|
||||
|
||||
@@ -5,13 +5,13 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/micromdm/micromdm/crypto"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
boltdepot "github.com/micromdm/scep/depot/bolt"
|
||||
|
||||
"github.com/fullsailor/pkcs7"
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/micromdm/mdm"
|
||||
boltdepot "github.com/micromdm/scep/depot/bolt"
|
||||
|
||||
"github.com/micromdm/micromdm/pkg/crypto"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
)
|
||||
|
||||
type Endpoints struct {
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/micromdm/micromdm/config"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/config"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -9,7 +9,8 @@ import (
|
||||
"github.com/fullsailor/pkcs7"
|
||||
httptransport "github.com/go-kit/kit/transport/http"
|
||||
"github.com/groob/plist"
|
||||
"github.com/micromdm/micromdm/crypto"
|
||||
|
||||
"github.com/micromdm/micromdm/pkg/crypto"
|
||||
)
|
||||
|
||||
type HTTPHandlers struct {
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/micromdm/mdm"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type Checkin struct {
|
||||
AuthenticateInvoked bool
|
||||
AuthenticateFunc CheckinFunc
|
||||
|
||||
TokenUpdateInvoked bool
|
||||
TokenUpdateFunc CheckinFunc
|
||||
|
||||
CheckOutInvoked bool
|
||||
CheckoutFunc CheckinFunc
|
||||
}
|
||||
|
||||
type CheckinFunc func(ctx context.Context, cmd mdm.CheckinCommand) error
|
||||
|
||||
func (svc *Checkin) Authenticate(ctx context.Context, cmd mdm.CheckinCommand) error {
|
||||
svc.AuthenticateInvoked = true
|
||||
return svc.AuthenticateFunc(ctx, cmd)
|
||||
}
|
||||
|
||||
func (svc *Checkin) TokenUpdate(ctx context.Context, cmd mdm.CheckinCommand) error {
|
||||
svc.TokenUpdateInvoked = true
|
||||
return svc.TokenUpdateFunc(ctx, cmd)
|
||||
}
|
||||
|
||||
func (svc *Checkin) CheckOut(ctx context.Context, cmd mdm.CheckinCommand) error {
|
||||
svc.CheckOutInvoked = true
|
||||
return svc.CheckoutFunc(ctx, cmd)
|
||||
}
|
||||
|
||||
func FailCheckin(context.Context, mdm.CheckinCommand) error {
|
||||
return errors.New("checkin failed")
|
||||
}
|
||||
|
||||
func SucceedCheckin(context.Context, mdm.CheckinCommand) error {
|
||||
return nil
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package mock
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/micromdm/mdm"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type Command struct {
|
||||
NewCommandInvoked bool
|
||||
NewCommandFunc NewCommandFunc
|
||||
}
|
||||
|
||||
type NewCommandFunc func(context.Context, *mdm.CommandRequest) (*mdm.Payload, error)
|
||||
|
||||
func (svc *Command) NewCommand(ctx context.Context, request *mdm.CommandRequest) (*mdm.Payload, error) {
|
||||
svc.NewCommandInvoked = true
|
||||
return svc.NewCommandFunc(ctx, request)
|
||||
}
|
||||
|
||||
var MockPayload = &mdm.Payload{
|
||||
CommandUUID: "1234",
|
||||
}
|
||||
|
||||
func FailNewCommand(context.Context, *mdm.CommandRequest) (*mdm.Payload, error) {
|
||||
return nil, errors.New("command creation failed")
|
||||
}
|
||||
|
||||
func ReturnMockPayload(context.Context, *mdm.CommandRequest) (*mdm.Payload, error) {
|
||||
return MockPayload, nil
|
||||
}
|
||||
|
||||
func ReturnPayload(p *mdm.Payload) NewCommandFunc {
|
||||
return func(context.Context, *mdm.CommandRequest) (*mdm.Payload, error) {
|
||||
return p, nil
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,10 @@ import (
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/micromdm/dep"
|
||||
"github.com/micromdm/micromdm/blueprint"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
"github.com/micromdm/micromdm/user"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/blueprint"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
"github.com/micromdm/micromdm/platform/user"
|
||||
)
|
||||
|
||||
type Endpoints struct {
|
||||
@@ -13,15 +13,15 @@ import (
|
||||
"net/textproto"
|
||||
|
||||
"github.com/fullsailor/pkcs7"
|
||||
"github.com/micromdm/dep"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/dep"
|
||||
"github.com/micromdm/micromdm/appstore"
|
||||
"github.com/micromdm/micromdm/blueprint"
|
||||
"github.com/micromdm/micromdm/dep/deptoken"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/user"
|
||||
"github.com/micromdm/micromdm/platform/appstore"
|
||||
"github.com/micromdm/micromdm/platform/blueprint"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/user"
|
||||
)
|
||||
|
||||
type Service interface {
|
||||
@@ -6,10 +6,10 @@ import (
|
||||
|
||||
"github.com/go-kit/kit/endpoint"
|
||||
"github.com/micromdm/dep"
|
||||
"github.com/micromdm/micromdm/blueprint"
|
||||
"github.com/micromdm/micromdm/dep/deptoken"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
"github.com/micromdm/micromdm/user"
|
||||
"github.com/micromdm/micromdm/platform/blueprint"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
"github.com/micromdm/micromdm/platform/user"
|
||||
)
|
||||
|
||||
type Endpoints struct {
|
||||
@@ -10,13 +10,13 @@ import (
|
||||
"github.com/micromdm/dep"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/appstore"
|
||||
"github.com/micromdm/micromdm/blueprint"
|
||||
"github.com/micromdm/micromdm/dep/deptoken"
|
||||
"github.com/micromdm/micromdm/device"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/user"
|
||||
"github.com/micromdm/micromdm/platform/appstore"
|
||||
"github.com/micromdm/micromdm/platform/blueprint"
|
||||
"github.com/micromdm/micromdm/platform/device"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/user"
|
||||
)
|
||||
|
||||
type ListDevicesOption struct {
|
||||
@@ -2,8 +2,9 @@ package remove
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/micromdm/micromdm/blueprint"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/blueprint"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
)
|
||||
|
||||
type Service interface {
|
||||
@@ -1,4 +1,4 @@
|
||||
package push
|
||||
package apns
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/mdm/checkin"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
const PushBucket = "mdm.PushInfo"
|
||||
@@ -1,4 +1,4 @@
|
||||
package push
|
||||
package apns
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,4 +1,4 @@
|
||||
package push
|
||||
package apns
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -1,6 +1,6 @@
|
||||
package push
|
||||
package apns
|
||||
|
||||
import "golang.org/x/net/context"
|
||||
import "context"
|
||||
|
||||
type Service interface {
|
||||
Push(ctx context.Context, udid string) (string, error)
|
||||
@@ -1,10 +1,10 @@
|
||||
package push
|
||||
package apns
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/micromdm/micromdm/push/internal/pushproto"
|
||||
"github.com/micromdm/micromdm/platform/apns/internal/pushproto"
|
||||
)
|
||||
|
||||
type PushInfo struct {
|
||||
@@ -1,6 +1,7 @@
|
||||
package push
|
||||
package apns
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -11,11 +12,10 @@ import (
|
||||
"github.com/RobotsAndPencils/buford/payload"
|
||||
"github.com/RobotsAndPencils/buford/push"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/micromdm/micromdm/config"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/queue"
|
||||
"github.com/micromdm/micromdm/platform/config"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/queue"
|
||||
)
|
||||
|
||||
type Push struct {
|
||||
@@ -1,4 +1,4 @@
|
||||
package push
|
||||
package apns
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -10,8 +10,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/groob/plist"
|
||||
"github.com/micromdm/micromdm/appmanifest"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/mdm/appmanifest"
|
||||
)
|
||||
|
||||
type AppStore interface {
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/micromdm/micromdm/blueprint/internal/blueprintproto"
|
||||
"github.com/micromdm/micromdm/platform/blueprint/internal/blueprintproto"
|
||||
)
|
||||
|
||||
// ApplyAt is a case-insensitive string that specifies at which point the
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
"github.com/micromdm/micromdm/user"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
"github.com/micromdm/micromdm/platform/user"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -4,14 +4,14 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/micromdm/mdm"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/mdm"
|
||||
"github.com/micromdm/micromdm/command"
|
||||
"github.com/micromdm/micromdm/device"
|
||||
"github.com/micromdm/micromdm/mdm/checkin"
|
||||
"github.com/micromdm/micromdm/profile"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/command"
|
||||
"github.com/micromdm/micromdm/platform/device"
|
||||
"github.com/micromdm/micromdm/platform/profile"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
func (db *DB) ApplyToDevice(ctx context.Context, svc command.Service, bp *Blueprint, udid string) error {
|
||||
@@ -5,9 +5,10 @@ import (
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/micromdm/mdm"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -5,9 +5,10 @@ import (
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/micromdm/mdm"
|
||||
"github.com/micromdm/micromdm/command/internal/commandproto"
|
||||
"github.com/pkg/errors"
|
||||
uuid "github.com/satori/go.uuid"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/command/internal/commandproto"
|
||||
)
|
||||
|
||||
type Event struct {
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/groob/plist"
|
||||
"github.com/micromdm/mdm"
|
||||
|
||||
"github.com/micromdm/micromdm/command"
|
||||
"github.com/micromdm/micromdm/platform/command"
|
||||
)
|
||||
|
||||
var marshalTests = []string{
|
||||
@@ -2,8 +2,9 @@ package config
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/micromdm/micromdm/config/internal/configproto"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/config/internal/configproto"
|
||||
)
|
||||
|
||||
// ServerConfig holds the configuration of the MDM Server.
|
||||
@@ -9,9 +9,10 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/boltdb/bolt"
|
||||
"github.com/micromdm/micromdm/crypto"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/pkg/crypto"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/micromdm/micromdm/dep/depsync"
|
||||
"github.com/micromdm/micromdm/mdm/checkin"
|
||||
"github.com/micromdm/micromdm/mdm/connect"
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -4,8 +4,9 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/micromdm/micromdm/device/internal/deviceproto"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/device/internal/deviceproto"
|
||||
)
|
||||
|
||||
type Device struct {
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
"github.com/fullsailor/pkcs7"
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/groob/plist"
|
||||
"github.com/micromdm/micromdm/profile/internal/profileproto"
|
||||
|
||||
"github.com/micromdm/micromdm/platform/profile/internal/profileproto"
|
||||
)
|
||||
|
||||
type Mobileconfig []byte
|
||||
@@ -3,7 +3,7 @@ package inmem
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
func (p *Inmem) Subscribe(_ context.Context, name, topic string) (<-chan pubsub.Event, error) {
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/micromdm/micromdm/pubsub"
|
||||
"github.com/micromdm/micromdm/platform/pubsub"
|
||||
)
|
||||
|
||||
func NewPubSub() *Inmem {
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/micromdm/micromdm/queue/internal/commandqueuedproto"
|
||||
"github.com/micromdm/micromdm/platform/queue/internal/commandqueuedproto"
|
||||
)
|
||||
|
||||
type QueueCommandQueued struct {
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/gogo/protobuf/proto"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/micromdm/micromdm/queue/internal/devicecommandproto"
|
||||
"github.com/micromdm/micromdm/platform/queue/internal/devicecommandproto"
|
||||
)
|
||||
|
||||
type Command struct {
|
||||
@@ -30,7 +30,7 @@ type DeviceCommand struct {
|
||||
// These are going to scale great. We'll have to see.
|
||||
Completed []Command
|
||||
Failed []Command
|
||||
NotNow []Command
|
||||
NotNow []Command
|
||||
}
|
||||
|
||||
func MarshalDeviceCommand(c *DeviceCommand) ([]byte, error) {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user