1
0
mirror of https://github.com/drone/drone-cli.git synced 2024-11-23 01:11:57 +01:00

print machine account token

This commit is contained in:
Brad Rydzewski 2019-02-20 16:59:11 -08:00
parent 00907ac6ef
commit 513b079977
4 changed files with 21 additions and 5 deletions

4
Gopkg.lock generated

@ -68,7 +68,6 @@
version = "v0.3.3" version = "v0.3.3"
[[projects]] [[projects]]
branch = "master"
name = "github.com/drone/drone-go" name = "github.com/drone/drone-go"
packages = [ packages = [
"drone", "drone",
@ -79,7 +78,8 @@
"plugin/registry", "plugin/registry",
"plugin/secret" "plugin/secret"
] ]
revision = "1354e27647f2efee29b63dcd9cc561fafb4c51c1" revision = "b1b8a8f8f28e6beecb78e7c6fa95a26ccc040b26"
version = "v1.0.1"
[[projects]] [[projects]]
branch = "master" branch = "master"

@ -23,6 +23,10 @@ var userAddCmd = cli.Command{
Name: "machine", Name: "machine",
Usage: "machine account", Usage: "machine account",
}, },
cli.BoolFlag{
Name: "token",
Usage: "api token",
},
}, },
} }
@ -38,11 +42,15 @@ func userAdd(c *cli.Context) error {
Login: login, Login: login,
Admin: c.Bool("admin"), Admin: c.Bool("admin"),
Machine: c.Bool("machine"), Machine: c.Bool("machine"),
Token: c.String("token"),
} }
user, err := client.UserCreate(in) user, err := client.UserCreate(in)
if err != nil { if err != nil {
return err return err
} }
fmt.Printf("Successfully added user %s\n", user.Login) fmt.Printf("Successfully added user %s\n", user.Login)
if user.Token != "" {
fmt.Printf("Generated account token %s\n", user.Token)
}
return nil return nil
} }

6
vendor/github.com/drone/drone-go/NOTICE generated vendored Normal file

@ -0,0 +1,6 @@
Drone
Copyright 2019 Drone.IO, Inc
This product includes software developed at Drone.IO, Inc.
(http://drone.io/).

@ -29,13 +29,15 @@ type (
Created int64 `json:"created"` Created int64 `json:"created"`
Updated int64 `json:"updated"` Updated int64 `json:"updated"`
LastLogin int64 `json:"last_login"` LastLogin int64 `json:"last_login"`
Token string `json:"token"`
} }
// UserPatch defines a user patch request. // UserPatch defines a user patch request.
UserPatch struct { UserPatch struct {
Active *bool `json:"active,omitempty"` Active *bool `json:"active,omitempty"`
Admin *bool `json:"admin,omitempty"` Admin *bool `json:"admin,omitempty"`
Machine *bool `json:"machine,omitempty"` Machine *bool `json:"machine,omitempty"`
Token *string `json:"token,omitempty"`
} }
// Repo represents a repository. // Repo represents a repository.