-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (33 loc) · 829 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
"github.com/ovh/go-ovh/ovh"
"github.com/spf13/viper"
)
func main() {
// Setup configuration with viper
viper.SetDefault("API_ENDPOINT", "ovh-eu")
viper.BindEnv("API_ENDPOINT")
viper.BindEnv("APPLICATION_KEY")
viper.BindEnv("APPLICATION_SECRET")
viper.BindEnv("CONSUMER_KEY")
viper.BindEnv("DNS_ZONE")
apiEndpoint := viper.GetString("API_ENDPOINT")
appKey := viper.GetString("APPLICATION_KEY")
appSecret := viper.GetString("APPLICATION_SECRET")
consumerKey := viper.GetString("CONSUMER_KEY")
client, err := ovh.NewClient(
apiEndpoint,
appKey,
appSecret,
consumerKey,
)
if err != nil {
panic(err)
}
dnsZone := viper.GetString("DNS_ZONE")
query := fmt.Sprintf("/domain/zone/%v/refresh", dnsZone)
if err = client.Post(query, nil, nil); err != nil {
panic(err)
}
}