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

added admission plugin command line tools

This commit is contained in:
Brad Rydzewski 2019-09-19 10:22:36 -07:00
parent a986f7c87c
commit b417dfe5f4
2 changed files with 66 additions and 0 deletions

@ -0,0 +1,64 @@
package admit
import (
"context"
"github.com/drone/drone-go/drone"
"github.com/drone/drone-go/plugin/admission"
"github.com/urfave/cli"
)
// Command exports the admission command set.
var Command = cli.Command{
Name: "admit",
Usage: "test user admission",
ArgsUsage: "user",
Action: admit,
Flags: []cli.Flag{
cli.StringFlag{
Name: "user",
Usage: "username",
},
cli.StringFlag{
Name: "endpoint",
Usage: "plugin endpoint",
EnvVar: "DRONE_ADMISSION_ENDPOINT",
},
cli.StringFlag{
Name: "secret",
Usage: "plugin secret",
EnvVar: "DRONE_ADMISSION_SECRET",
},
cli.StringFlag{
Name: "ssl-skip-verify",
Usage: "plugin ssl verification disabled",
EnvVar: "DRONE_ADMISSION_SKIP_VERIFY",
},
},
}
func admit(c *cli.Context) error {
login := c.String("user")
if login == "" {
login = c.Args().First()
}
req := &admission.Request{
User: drone.User{
Login: login,
},
}
client := admission.Client(
c.String("endpoint"),
c.String("secret"),
c.Bool("ssl-skip-verify"),
)
_, err := client.Admit(context.Background(), req)
if err != nil {
return err
}
return nil
}

@ -1,6 +1,7 @@
package plugins
import (
"github.com/drone/drone-cli/drone/plugins/admit"
"github.com/drone/drone-cli/drone/plugins/config"
"github.com/drone/drone-cli/drone/plugins/convert"
"github.com/drone/drone-cli/drone/plugins/registry"
@ -14,6 +15,7 @@ var Command = cli.Command{
Name: "plugins",
Usage: "plugin helper functions",
Subcommands: []cli.Command{
admit.Command,
config.Command,
convert.Command,
secret.Command,