Skip to content

Commit

Permalink
feat: addd main_config.yaml sample to ConfigDir
Browse files Browse the repository at this point in the history
  • Loading branch information
menuka94 committed Dec 7, 2017
1 parent 939d9f2 commit 1d19537
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 30 deletions.
6 changes: 5 additions & 1 deletion import-export-cli/cmd/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ var envsCmd = &cobra.Command{
utils.Logln(utils.LogPrefixInfo + listCmdLiteral + " " + EnvsCmdLiteral + " called")

envs := utils.GetMainConfigFromFile(utils.MainConfigFilePath).Environments
printEnvs(envs)
if len(envs) > 0 {
printEnvs(envs)
} else {
fmt.Println("No configured environments found")
}
fmt.Printf("Environments available in file '%s'\n", utils.MainConfigFileName)
},
}
Expand Down
12 changes: 9 additions & 3 deletions import-export-cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func init() {
if err != nil {
utils.HandleErrorAndExit("Error reading "+utils.MainConfigFilePath+".", err)
}

}

func createConfigFiles() {
Expand All @@ -102,16 +101,23 @@ func createConfigFiles() {
}

if !utils.IsFileExist(utils.MainConfigFilePath) {
var mainConfig = new(utils.MainConfig)
mainConfig.Config = utils.Config{utils.DefaultHttpRequestTimeout, utils.ExportDirPath}
utils.WriteConfigFile(mainConfig, utils.MainConfigFilePath)
}

if !utils.IsFileExist(utils.SampleMainConfigFilePath) {
var mainConfig = new(utils.MainConfig)
mainConfig.Config = utils.Config{utils.DefaultHttpRequestTimeout, utils.ExportDirPath}
mainConfig.Environments = make(map[string]utils.EnvEndpoints)
mainConfig.Environments["testEnv"] = utils.EnvEndpoints{
mainConfig.Environments["sampleEnv"] = utils.EnvEndpoints{
"https://localhost/publisher",
"http://localhost/register",
"http://localhost/token",
}
utils.WriteConfigFile(mainConfig, utils.MainConfigFilePath)
utils.WriteConfigFile(mainConfig, utils.SampleMainConfigFilePath)
}

if !utils.IsFileExist(utils.EnvKeysAllFilePath) {
os.Create(utils.EnvKeysAllFilePath)
}
Expand Down
10 changes: 1 addition & 9 deletions import-export-cli/main_config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config:
http_request_timeout: 1000000
export_directory: /home/menuka/Desktop/exported
export_directory: /home/user/Desktop/exported
environments:
dev:
publisher_endpoint: https://localhost:9292/api/am/publisher/v1.0
Expand All @@ -10,11 +10,3 @@ environments:
publisher_endpoint: publisher
registration_endpoint: registration
token_endpoint: token
vm1:
publisher_endpoint: https://35.195.132.29:9292/api/am/publisher/v1.0
registration_endpoint: https://35.195.132.29:9443/identity/connect/register
token_endpoint: https://35.195.132.29:9443/oauth2/token
vm2:
publisher_endpoint: https://35.195.70.177:9292/api/am/publisher/v1.0
registration_endpoint: https://35.195.70.177:9443/identity/connect/register
token_endpoint: https://35.195.70.177:9443/oauth2/token
17 changes: 0 additions & 17 deletions import-export-cli/main_config.yaml.sample

This file was deleted.

2 changes: 2 additions & 0 deletions import-export-cli/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ const EnvKeysAllFileName = "env_keys_all.yaml"
var EnvKeysAllFilePath = filepath.Join(ConfigDirPath, EnvKeysAllFileName)

const MainConfigFileName = "main_config.yaml"
const SampleMainConfigFileName = "main_config.yaml.sample"

var MainConfigFilePath = filepath.Join(ConfigDirPath, MainConfigFileName)
var SampleMainConfigFilePath = filepath.Join(ConfigDirPath, SampleMainConfigFileName)

const ExportDirName = "exported"

Expand Down

0 comments on commit 1d19537

Please sign in to comment.