Skip to content

Commit e693b00

Browse files
author
Gabriel Monroy
committed
feat(deisctl): check for required configuration on platform install
1 parent e986794 commit e693b00

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

deisctl/cmd/cmd.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,21 @@ func Start(b backend.Backend, targets []string) error {
7979
return nil
8080
}
8181

82+
// checkRequiredKeys exist in etcd
83+
func checkRequiredKeys() error {
84+
if err := config.CheckConfig("/deis/platform/", "domain"); err != nil {
85+
return fmt.Errorf(`Missing platform domain, use:
86+
deisctl config platform set domain=<your-domain>`)
87+
}
88+
89+
if err := config.CheckConfig("/deis/platform/", "sshPrivateKey"); err != nil {
90+
fmt.Printf(`Warning: Missing sshPrivateKey, "deis run" will be unavailable. Use:
91+
deisctl config platform set sshPrivateKey=<path-to-key>
92+
`)
93+
}
94+
return nil
95+
}
96+
8297
func StartPlatform(b backend.Backend) error {
8398

8499
outchan := make(chan string)
@@ -256,6 +271,10 @@ func Install(b backend.Backend, targets []string) error {
256271

257272
func InstallPlatform(b backend.Backend) error {
258273

274+
if err := checkRequiredKeys(); err != nil {
275+
return err
276+
}
277+
259278
outchan := make(chan string)
260279
errchan := make(chan error)
261280
var wg sync.WaitGroup

deisctl/config/config.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ func Config() error {
3232
return doConfig(args)
3333
}
3434

35+
// CheckConfig looks for a value at a keyspace path
36+
// and returns an error if a value is not found
37+
func CheckConfig(root string, k string) error {
38+
39+
client, err := getEtcdClient()
40+
if err != nil {
41+
return err
42+
}
43+
44+
_, err = doConfigGet(client, root, []string{k})
45+
if err != nil {
46+
return err
47+
}
48+
49+
return nil
50+
}
51+
3552
// Flags for config package
3653
var Flags struct {
3754
}

0 commit comments

Comments
 (0)