From 0f62fe6aca28daaa218419133962d9766b09f342 Mon Sep 17 00:00:00 2001 From: Shivaprasad Bhat Date: Mon, 20 Feb 2023 12:13:15 +0530 Subject: [PATCH] fix: rename flag to secure (#29) --- cli/cdk/dex_client.go | 22 ++++++++++++++-------- cli/config/configs.go | 4 ++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/cli/cdk/dex_client.go b/cli/cdk/dex_client.go index 3cb66e6..691e6f3 100644 --- a/cli/cdk/dex_client.go +++ b/cli/cdk/dex_client.go @@ -22,7 +22,7 @@ type swaggerParams interface { } type swaggerTransport struct { - runtime.ClientTransport + *httptransport.Runtime Context context.Context Timeout time.Duration @@ -36,7 +36,13 @@ func (tr *swaggerTransport) Submit(operation *runtime.ClientOperation) (interfac } params.SetContext(tr.Context) } - return tr.ClientTransport.Submit(operation) + + v, err := tr.Runtime.Submit(operation) + if err != nil { + return nil, err + } + + return v, nil } func NewClient(cmd *cobra.Command) *client.DexAPI { @@ -51,8 +57,8 @@ func NewClient(cmd *cobra.Command) *client.DexAPI { } scheme := []string{"http"} - if cfg.UseHTTPS { - scheme = append(scheme, "https") + if cfg.Secure { + scheme = []string{"https"} } r := httptransport.New(cfg.Host, "/api", scheme) @@ -65,15 +71,15 @@ func NewClient(cmd *cobra.Command) *client.DexAPI { return client.New(customTr, strfmt.Default) } -func newSwaggerTransport(cmd *cobra.Command, r runtime.ClientTransport) *swaggerTransport { +func newSwaggerTransport(cmd *cobra.Command, r *httptransport.Runtime) *swaggerTransport { d, err := cmd.Flags().GetDuration("timeout") if err != nil || d == 0 { d = 10 * time.Second } return &swaggerTransport{ - ClientTransport: r, - Context: cmd.Context(), - Timeout: d, + Runtime: r, + Context: cmd.Context(), + Timeout: d, } } diff --git a/cli/config/configs.go b/cli/config/configs.go index deb2c68..4ee848e 100644 --- a/cli/config/configs.go +++ b/cli/config/configs.go @@ -16,8 +16,8 @@ var ErrClientConfigNotFound = errors.New(heredoc.Doc(` `)) type ClientConfig struct { - Host string `yaml:"host" cmdx:"host"` - UseHTTPS bool `yaml:"use_https" cmdx:"use_https"` + Host string `yaml:"host" cmdx:"host"` + Secure bool `yaml:"secure" cmdx:"secure"` } func Load() (*ClientConfig, error) {