Skip to content

Commit 0b30073

Browse files
marclopppapapetrou76
authored andcommitted
Add timeout values to ecctl.Config (#100)
Signed-off-by: Marc Lopez <marc5.12@outlook.com>
1 parent 35bcb95 commit 0b30073

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

cmd/root.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,6 @@ func initApp(cmd *cobra.Command, client *http.Client, v *viper.Viper) error {
173173
return errors.New("cmd: root http client cannot be nil")
174174
}
175175

176-
if timeout := v.GetDuration("timeout"); timeout.Nanoseconds() > 0 {
177-
client.Timeout = timeout
178-
}
179-
180176
var c = ecctl.Config{
181177
Client: client,
182178
OutputDevice: output.NewDevice(defaultOutput),

pkg/ecctl/app.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func NewApplication(c Config) (*App, error) {
4848
AuthWriter: authWriter,
4949
Region: c.Region,
5050
SkipTLSVerify: c.Insecure,
51+
Timeout: c.Timeout,
5152
VerboseSettings: api.VerboseSettings{
5253
Verbose: c.Verbose,
5354
Device: c.OutputDevice,

pkg/ecctl/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"io"
2323
"net/http"
24+
"time"
2425

2526
"github.com/elastic/cloud-sdk-go/pkg/output"
2627
"github.com/elastic/cloud-sdk-go/pkg/util/slice"
@@ -58,6 +59,8 @@ type Config struct {
5859
ErrorDevice io.Writer `json:"-"`
5960
Client *http.Client `json:"-"`
6061

62+
Timeout time.Duration `json:"timeout,omitempty"`
63+
6164
Verbose bool `json:"verbose,omitempty"`
6265
Force bool `json:"force,omitempty"`
6366
Insecure bool `json:"insecure,omitempty"`

0 commit comments

Comments
 (0)