package helpers

import (
	"encoding/json"
	"os"
)

type IntegrationConfig struct {
	AppsDomain        string `json:"apps_domain"`
	PersistentAppHost string `json:"persistent_app_host"`
}

func LoadConfig() (config IntegrationConfig) {
	path := os.Getenv("CONFIG")
	if path == "" {
		panic("Must set $CONFIG to point to an integration config .json file.")
	}

	return LoadPath(path)
}

func LoadPath(path string) (config IntegrationConfig) {
	configFile, err := os.Open(path)
	if err != nil {
		panic(err)
	}

	decoder := json.NewDecoder(configFile)
	err = decoder.Decode(&config)
	if err != nil {
		panic(err)
	}

	if config.PersistentAppHost == "" {
		config.PersistentAppHost = "persistent-app"
	}

	return
}

package helpers

import (
	"encoding/json"
	"os"
)

type IntegrationConfig struct {
	AppsDomain        string `json:"apps_domain"`
	PersistentAppHost string `json:"persistent_app_host"`
}

func LoadConfig() (config IntegrationConfig) {
	path := os.Getenv("CONFIG")
	if path == "" {
		panic("Must set $CONFIG to point to an integration config .json file.")
	}

	return loadConfigJsonFromPath(path)
}

func loadConfigJsonFromPath(path string) (config IntegrationConfig) {
	configFile, err := os.Open(path)
	if err != nil {
		panic(err)
	}

	decoder := json.NewDecoder(configFile)
	err = decoder.Decode(&config)
	if err != nil {
		panic(err)
	}

	if config.PersistentAppHost == "" {
		config.PersistentAppHost = "persistent-app"
	}

	return
}

Rename for clarity and stop exporting
Rename for clarity and stop exporting

Signed-off-by: Eric Malm <f38766f3ef0e8328064f8aa2a19c8805448432f2@pivotallabs.com>
