forked from Cloudxtreme/core-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathping.go
More file actions
35 lines (31 loc) · 725 Bytes
/
ping.go
File metadata and controls
35 lines (31 loc) · 725 Bytes
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
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
)
var cmdPing = &Command{
UsageLine: "ping",
Short: "Test certs with a ping to c10n",
}
func init() {
cmdPing.Run = runPing
}
func runPing(cmd *Command, args []string) {
client := &http.Client{
Transport: tlsTransport,
}
resp, err := client.PostForm("https://api.core-os.net/v1/c10n/group", url.Values{"c10n_url": {"test.net"}, "ip_list": {"test"}})
if err != nil {
fmt.Printf("Error: Could not ping c10n service: %v", err.Error())
os.Exit(-1)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Printf("Error: Error reading response body: %v", err.Error())
os.Exit(-1)
}
fmt.Printf("%v\n%v", resp, string(body))
}