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

Commit

Permalink
Added Vamp Installation Config Validation
Browse files Browse the repository at this point in the history
  • Loading branch information
bgokden committed Feb 12, 2019
1 parent 394767c commit 40b6848
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ Leave databaseUrl empty to deploy an internal one
if unmarshallError != nil {
return unmarshallError
}
url, cert, _, err := kubeclient.InstallVampService(&config)
validatedConfig, configError := kubeclient.VampConfigValidateAndSetupDefaults(&config)
if configError != nil {
return configError
}
fmt.Printf("Vamp Configuration validated.\n")
url, cert, _, err := kubeclient.InstallVampService(validatedConfig)
if err != nil {
return err
}
Expand Down
28 changes: 28 additions & 0 deletions kubernetes/kubeclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ type VampConfig struct {
Mode string `yaml:"mode,omitempty" json:"mode,omitempty"`
}

func VampConfigValidateAndSetupDefaults(config *VampConfig) (*VampConfig, error) {
if config.RootPassword == "" {
// This is enforced
return config, errors.New("Root Password can not be empty.")
}
if config.RepoUsername == "" {
return config, errors.New("Repo Username can not be empty.")
}
if config.RepoPassword == "" {
return config, errors.New("Repo Password can not be empty.")
}
if config.DatabaseName == "" {
config.DatabaseName = "vamp"
fmt.Printf("Database Name set to default value: %v\n", config.DatabaseName)
}
if config.VampVersion == "" {
config.VampVersion = "0.7.0"
fmt.Printf("Vamp Version set to default value: %v\n", config.VampVersion)
}
if config.Mode != "IN_CLUSTER" &&
config.Mode != "OUT_CLUSTER" &&
config.Mode != "OUT_OF_CLUSTER" {
config.Mode = "IN_CLUSTER"
fmt.Printf("Vamp Mode set to default value: %v\n", config.Mode)
}
return config, nil
}

func GetKubeConfigPath(configPath string) *string {
if configPath == "" {
home := homeDir()
Expand Down

0 comments on commit 40b6848

Please sign in to comment.