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

Commit

Permalink
Merge pull request #5 from magneticio/installerextended
Browse files Browse the repository at this point in the history
Added mode and database name settings to installation configuration
  • Loading branch information
bgokden authored Feb 12, 2019
2 parents a076fa3 + 5c14611 commit f0a74db
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
6 changes: 5 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ Return the error object with message to be returned
It can be used after checking with IsError
*/
func getError(resp *resty.Response) error {
return errors.New(resp.Error().(*ErrorResponse).Message)
message := resp.Error().(*ErrorResponse).Message
if message == "" {
message = string(resp.Body())
}
return errors.New(message)
}

/*
Expand Down
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
34 changes: 32 additions & 2 deletions kubernetes/kubeclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,39 @@ import (
type VampConfig struct {
RootPassword string `yaml:"rootPassword,omitempty" json:"rootPassword,omitempty"`
DatabaseUrl string `yaml:"databaseUrl,omitempty" json:"databaseUrl,omitempty"`
DatabaseName string `yaml:"databaseName,omitempty" json:"databaseName,omitempty"`
RepoUsername string `yaml:"repoUsername,omitempty" json:"repoUsername,omitempty"`
RepoPassword string `yaml:"repoPassword,omitempty" json:"repoPassword,omitempty"`
VampVersion string `yaml:"vampVersion,omitempty" json:"vampVersion,omitempty"`
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 {
Expand Down Expand Up @@ -458,15 +488,15 @@ func InstallVamp(clientset *kubernetes.Clientset, ns string, config *VampConfig)
Env: []apiv1.EnvVar{
{
Name: "MODE",
Value: "IN_CLUSTER",
Value: config.Mode,
},
{
Name: "DBURL",
Value: config.DatabaseUrl,
},
{
Name: "DBNAME",
Value: "vamp",
Value: config.DatabaseName,
},
{
Name: "API_SSL",
Expand Down

0 comments on commit f0a74db

Please sign in to comment.