forked from micromdm/micromdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
remove.go
69 lines (56 loc) · 1.17 KB
/
remove.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"fmt"
"os"
"strings"
"github.com/go-kit/kit/log"
httptransport "github.com/go-kit/kit/transport/http"
"github.com/micromdm/micromdm/core/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
}