-
Notifications
You must be signed in to change notification settings - Fork 115
/
fake-registry.go
50 lines (40 loc) · 1.16 KB
/
fake-registry.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
41
42
43
44
45
46
47
48
49
50
package main
import (
"flag"
"fmt"
"net/http"
"strings"
bmregistry "github.com/cloudfoundry/bosh-init/registry"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
)
func main() {
user := flag.String("user", "user", "User")
password := flag.String("password", "password", "Password")
host := flag.String("host", "127.0.0.1", "Host")
port := flag.Int("port", 8080, "Port")
instance := flag.String("instance", "", "Instance ID")
settings := flag.String("settings", "", "Instance Settings")
flag.Parse()
logger := boshlog.NewLogger(boshlog.LevelDebug)
serverManager := bmregistry.NewServerManager(logger)
_, err := serverManager.Start(*user, *password, *host, *port)
if err != nil {
panic("Error starting registry")
}
if *instance != "" && *settings != "" {
request, err := http.NewRequest(
"PUT",
fmt.Sprintf("http://%s:%s@%s:%d/instances/%s/settings", *user, *password, *host, *port, *instance),
strings.NewReader(*settings),
)
if err != nil {
panic("Couldn't create request")
}
client := http.DefaultClient
_, err = client.Do(request)
if err != nil {
panic(fmt.Sprintf("Error sending request: %s", err.Error()))
}
}
select {}
}