feat(auth): align CLI application with new auth mode wording
All checks were successful
/ build (push) Successful in 3m13s
All checks were successful
/ build (push) Successful in 3m13s
This commit is contained in:
parent
59c217b666
commit
c1a575f57c
1 changed files with 27 additions and 27 deletions
|
@ -19,15 +19,15 @@ const (
|
||||||
desc = "a commandline helper for upda"
|
desc = "a commandline helper for upda"
|
||||||
version = server.Version
|
version = server.Version
|
||||||
|
|
||||||
envServerUrl = "UPDA_SERVER_URL"
|
envServerUrl = "UPDA_SERVER_URL"
|
||||||
envAdminUser = "UPDA_ADMIN_USER"
|
envUser = "UPDA_USER"
|
||||||
envAdminPassword = "UPDA_ADMIN_PASSWORD"
|
envPassword = "UPDA_PASSWORD"
|
||||||
envWebhookId = "UPDA_WEBHOOK_ID"
|
envWebhookId = "UPDA_WEBHOOK_ID"
|
||||||
envWebhookToken = "UPDA_WEBHOOK_TOKEN"
|
envWebhookToken = "UPDA_WEBHOOK_TOKEN"
|
||||||
|
|
||||||
flagServerUrl = "server-url"
|
flagServerUrl = "server-url"
|
||||||
flagAdminUser = "admin-user"
|
flagUser = "user"
|
||||||
flagAdminPass = "admin-pass"
|
flagPass = "pass"
|
||||||
flagWebhookId = "webhook-id"
|
flagWebhookId = "webhook-id"
|
||||||
flagWebhookToken = "webhook-token"
|
flagWebhookToken = "webhook-token"
|
||||||
flagUpdatePageSize = "page-size"
|
flagUpdatePageSize = "page-size"
|
||||||
|
@ -41,8 +41,8 @@ const (
|
||||||
func Start() {
|
func Start() {
|
||||||
var raw bool
|
var raw bool
|
||||||
var serverUrl string
|
var serverUrl string
|
||||||
var adminUser string
|
var user string
|
||||||
var adminPassword string
|
var password string
|
||||||
var webhookId string
|
var webhookId string
|
||||||
var webhookToken string
|
var webhookToken string
|
||||||
var updatePageSize int64
|
var updatePageSize int64
|
||||||
|
@ -63,21 +63,21 @@ func Start() {
|
||||||
EnvVars: []string{envServerUrl},
|
EnvVars: []string{envServerUrl},
|
||||||
Destination: &serverUrl,
|
Destination: &serverUrl,
|
||||||
}
|
}
|
||||||
adminUserFlag := &cli.StringFlag{
|
userFlag := &cli.StringFlag{
|
||||||
Name: flagAdminUser,
|
Name: flagUser,
|
||||||
Usage: "admin user",
|
Usage: "user",
|
||||||
Required: true,
|
Required: true,
|
||||||
Aliases: []string{"u"},
|
Aliases: []string{"u"},
|
||||||
EnvVars: []string{envAdminUser},
|
EnvVars: []string{envUser},
|
||||||
Destination: &adminUser,
|
Destination: &user,
|
||||||
}
|
}
|
||||||
adminPasswordFlag := &cli.StringFlag{
|
passwordFlag := &cli.StringFlag{
|
||||||
Name: flagAdminPass,
|
Name: flagPass,
|
||||||
Usage: "admin password",
|
Usage: "password",
|
||||||
Required: true,
|
Required: true,
|
||||||
Aliases: []string{"p"},
|
Aliases: []string{"p"},
|
||||||
EnvVars: []string{envAdminPassword},
|
EnvVars: []string{envPassword},
|
||||||
Destination: &adminPassword,
|
Destination: &password,
|
||||||
}
|
}
|
||||||
webhookIdFlag := &cli.StringFlag{
|
webhookIdFlag := &cli.StringFlag{
|
||||||
Name: flagWebhookId,
|
Name: flagWebhookId,
|
||||||
|
@ -126,8 +126,8 @@ func Start() {
|
||||||
Aliases: []string{"c"},
|
Aliases: []string{"c"},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
serverUrlFlag,
|
serverUrlFlag,
|
||||||
adminUserFlag,
|
userFlag,
|
||||||
adminPasswordFlag,
|
passwordFlag,
|
||||||
rawFlag,
|
rawFlag,
|
||||||
},
|
},
|
||||||
ArgsUsage: "<label> [<type (generic|diun, default: generic)>] [<ignore-host (true|false, default: false)>]",
|
ArgsUsage: "<label> [<type (generic|diun, default: generic)>] [<ignore-host (true|false, default: false)>]",
|
||||||
|
@ -158,8 +158,8 @@ func Start() {
|
||||||
Aliases: []string{"s"},
|
Aliases: []string{"s"},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
serverUrlFlag,
|
serverUrlFlag,
|
||||||
adminUserFlag,
|
userFlag,
|
||||||
adminPasswordFlag,
|
passwordFlag,
|
||||||
updatePageSizeFlag,
|
updatePageSizeFlag,
|
||||||
rawFlag,
|
rawFlag,
|
||||||
},
|
},
|
||||||
|
@ -176,7 +176,7 @@ func Start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func webhookCreate(cCtx *cli.Context) error {
|
func webhookCreate(cCtx *cli.Context) error {
|
||||||
if err := failIfFlagsNotPresent(cCtx, []string{flagServerUrl, flagAdminUser, flagAdminPass}); err != nil {
|
if err := failIfFlagsNotPresent(cCtx, []string{flagServerUrl, flagUser, flagPass}); err != nil {
|
||||||
return cli.Exit(err, 1)
|
return cli.Exit(err, 1)
|
||||||
}
|
}
|
||||||
if !cCtx.Args().Present() {
|
if !cCtx.Args().Present() {
|
||||||
|
@ -214,7 +214,7 @@ func webhookCreate(cCtx *cli.Context) error {
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
client.SetDisableWarn(true)
|
client.SetDisableWarn(true)
|
||||||
res, err := client.R().
|
res, err := client.R().
|
||||||
SetBasicAuth(cCtx.String(flagAdminUser), cCtx.String(flagAdminPass)).
|
SetBasicAuth(cCtx.String(flagUser), cCtx.String(flagPass)).
|
||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
SetBody(&payload).
|
SetBody(&payload).
|
||||||
SetResult(&successRes).
|
SetResult(&successRes).
|
||||||
|
@ -280,7 +280,7 @@ func webhookSend(cCtx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateShow(cCtx *cli.Context) error {
|
func updateShow(cCtx *cli.Context) error {
|
||||||
if err := failIfFlagsNotPresent(cCtx, []string{flagServerUrl, flagAdminUser, flagAdminPass}); err != nil {
|
if err := failIfFlagsNotPresent(cCtx, []string{flagServerUrl, flagUser, flagPass}); err != nil {
|
||||||
return cli.Exit(err, 1)
|
return cli.Exit(err, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ func updateShow(cCtx *cli.Context) error {
|
||||||
client := resty.New()
|
client := resty.New()
|
||||||
client.SetDisableWarn(true)
|
client.SetDisableWarn(true)
|
||||||
res, err := client.R().
|
res, err := client.R().
|
||||||
SetBasicAuth(cCtx.String(flagAdminUser), cCtx.String(flagAdminPass)).
|
SetBasicAuth(cCtx.String(flagUser), cCtx.String(flagPass)).
|
||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
SetResult(&successRes).
|
SetResult(&successRes).
|
||||||
SetError(&errorRes).
|
SetError(&errorRes).
|
||||||
|
|
Loading…
Reference in a new issue