Add users (#258)

For #248 

Added a User DB similar to the Device DB. 
The user specification be added with the API/mdmctl commands and then referenced with a blueprint. 
If added to the blueprint, the user will be installed as an administrator during the AccountConfiguration step.
This commit is contained in:
Victor Vrantchan
2017-10-24 20:34:41 -04:00
committed by GitHub
parent ad28f03a95
commit 43d026c970
24 changed files with 830 additions and 22 deletions

47
cmd/mdmctl/get_users.go Normal file
View File

@@ -0,0 +1,47 @@
package main
import (
"context"
"flag"
"fmt"
"os"
"text/tabwriter"
"github.com/pkg/errors"
"github.com/micromdm/micromdm/core/list"
)
type usersTableOutput struct{ w *tabwriter.Writer }
func (out *usersTableOutput) BasicHeader() {
fmt.Fprintf(out.w, "UUID\tUDID\tUserID\tUserShortName\tUserLongName\n")
}
func (out *usersTableOutput) BasicFooter() {
out.w.Flush()
}
func (cmd *getCommand) getUsers(args []string) error {
flagset := flag.NewFlagSet("users", flag.ExitOnError)
flagset.Usage = usageFor(flagset, "mdmctl get users [flags]")
if err := flagset.Parse(args); err != nil {
return err
}
w := tabwriter.NewWriter(os.Stderr, 0, 4, 2, ' ', 0)
out := &usersTableOutput{w}
out.BasicHeader()
defer out.BasicFooter()
users, err := cmd.list.ListUsers(context.TODO(), list.ListUsersOption{})
if err != nil {
return errors.Wrap(err, "list users")
}
for _, u := range users {
fmt.Fprintf(out.w, "%s\t%s\t%s\t%v\t%s\n", u.UUID, u.UDID, u.UserID, u.UserShortname, u.UserLongname)
}
return nil
}