fix: load timeout before other opts

This commit is contained in:
decentral1se 2021-10-21 15:06:03 +02:00
parent 6d4ee3de0d
commit 7a5ad65178
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -14,6 +14,8 @@ import (
func New(contextName string) (*client.Client, error) { func New(contextName string) (*client.Client, error) {
var clientOpts []client.Opt var clientOpts []client.Opt
clientOpts = append(clientOpts, client.WithTimeout(3*time.Second))
if contextName != "default" { if contextName != "default" {
context, err := GetContext(contextName) context, err := GetContext(contextName)
if err != nil { if err != nil {
@ -47,8 +49,6 @@ func New(contextName string) (*client.Client, error) {
clientOpts = append(clientOpts, client.WithAPIVersionNegotiation()) clientOpts = append(clientOpts, client.WithAPIVersionNegotiation())
} }
clientOpts = append(clientOpts, client.WithTimeout(3*time.Second))
cl, err := client.NewClientWithOpts(clientOpts...) cl, err := client.NewClientWithOpts(clientOpts...)
if err != nil { if err != nil {
return nil, err return nil, err