mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-14 17:41:43 +08:00
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.
71 lines
1.2 KiB
Go
71 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/go-kit/kit/log"
|
|
|
|
httptransport "github.com/go-kit/kit/transport/http"
|
|
|
|
"github.com/micromdm/micromdm/platform/apiserver/remove"
|
|
)
|
|
|
|
type removeCommand struct {
|
|
config *ServerConfig
|
|
remove remove.Service
|
|
}
|
|
|
|
func (cmd *removeCommand) setup() error {
|
|
cfg, err := LoadServerConfig()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
cmd.config = cfg
|
|
logger := log.NewLogfmtLogger(os.Stderr)
|
|
rmsvc, err := remove.NewClient(cfg.ServerURL, logger, cfg.APIToken, httptransport.SetClient(skipVerifyHTTPClient(cmd.config.SkipVerify)))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
cmd.remove = rmsvc
|
|
return nil
|
|
}
|
|
|
|
func (cmd *removeCommand) Run(args []string) error {
|
|
if len(args) < 1 {
|
|
cmd.Usage()
|
|
os.Exit(1)
|
|
}
|
|
|
|
if err := cmd.setup(); err != nil {
|
|
return err
|
|
}
|
|
|
|
var run func([]string) error
|
|
switch strings.ToLower(args[0]) {
|
|
case "blueprints":
|
|
run = cmd.removeBlueprints
|
|
case "profiles":
|
|
run = cmd.removeProfiles
|
|
default:
|
|
cmd.Usage()
|
|
os.Exit(1)
|
|
}
|
|
|
|
return run(args[1:])
|
|
}
|
|
|
|
func (cmd *removeCommand) Usage() error {
|
|
const getUsage = `
|
|
Display one or many resources.
|
|
|
|
Valid resource types:
|
|
|
|
* blueprints
|
|
* profiles`
|
|
|
|
fmt.Println(getUsage)
|
|
return nil
|
|
}
|