mirror of
https://github.com/Luzifer/vault-unseal.git
synced 2024-12-22 22:01:20 +00:00
Use a HTTP client with explicit timeout
This commit is contained in:
parent
effdb41876
commit
c1ca27a2b6
1 changed files with 5 additions and 2 deletions
7
main.go
7
main.go
|
@ -35,9 +35,12 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
timedClient := http.DefaultClient
|
||||||
|
timedClient.Timeout = 10 * time.Second
|
||||||
|
|
||||||
for {
|
for {
|
||||||
s := sealStatus{}
|
s := sealStatus{}
|
||||||
r, err := http.Get(config.VaultInstance + "/v1/sys/seal-status")
|
r, err := timedClient.Get(config.VaultInstance + "/v1/sys/seal-status")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("An error ocurred while reading seal-status: %s\n", err)
|
log.Printf("An error ocurred while reading seal-status: %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -57,7 +60,7 @@ func main() {
|
||||||
"key": token,
|
"key": token,
|
||||||
})
|
})
|
||||||
r, _ := http.NewRequest("PUT", config.VaultInstance+"/v1/sys/unseal", body)
|
r, _ := http.NewRequest("PUT", config.VaultInstance+"/v1/sys/unseal", body)
|
||||||
resp, err := http.DefaultClient.Do(r)
|
resp, err := timedClient.Do(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("An error ocurred while doing unseal: %s\n", err)
|
log.Printf("An error ocurred while doing unseal: %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
Loading…
Reference in a new issue