Files
micromdm/cmd/mdmctl/remove.go
Victor Vrantchan 91c236c8c3 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.
2017-11-23 22:07:57 -05:00

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
}