Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
feat(deisctl): check for required configuration on platform install
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel Monroy committed Oct 23, 2014
1 parent e986794 commit e693b00
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions deisctl/cmd/cmd.go
Expand Up @@ -79,6 +79,21 @@ func Start(b backend.Backend, targets []string) error {
return nil
}

// checkRequiredKeys exist in etcd
func checkRequiredKeys() error {
if err := config.CheckConfig("/deis/platform/", "domain"); err != nil {
return fmt.Errorf(`Missing platform domain, use:
deisctl config platform set domain=<your-domain>`)
}

if err := config.CheckConfig("/deis/platform/", "sshPrivateKey"); err != nil {
fmt.Printf(`Warning: Missing sshPrivateKey, "deis run" will be unavailable. Use:
deisctl config platform set sshPrivateKey=<path-to-key>
`)
}
return nil
}

func StartPlatform(b backend.Backend) error {

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

func InstallPlatform(b backend.Backend) error {

if err := checkRequiredKeys(); err != nil {
return err
}

outchan := make(chan string)
errchan := make(chan error)
var wg sync.WaitGroup
Expand Down
17 changes: 17 additions & 0 deletions deisctl/config/config.go
Expand Up @@ -32,6 +32,23 @@ func Config() error {
return doConfig(args)
}

// CheckConfig looks for a value at a keyspace path
// and returns an error if a value is not found
func CheckConfig(root string, k string) error {

client, err := getEtcdClient()
if err != nil {
return err
}

_, err = doConfigGet(client, root, []string{k})
if err != nil {
return err
}

return nil
}

// Flags for config package
var Flags struct {
}
Expand Down

0 comments on commit e693b00

Please sign in to comment.