-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need to read config properly #153
Comments
I would like to know more about this issue since I am interested in working on this topic. Thank you |
@ChobobDev I'm happy to hear that 😄 I'm looking for a nice way to set configs. At the very beginning, I wanted to protect critical information and modify it easily by users so that I create the below configs.
With these configs, users can run several executable files (e.g., admin-web, controller, agent, clad-service) in any directory. (CB-Larva, which aims for microservice architecture, is divided into executable files.) Even when I run the controller on a Docker container, it's fine ^^ But... The problem is that I have many duplicated I would like to follow Golang's package programming philosophy and discuss ways to improve it with you ^^ If you have any further questions, comments, and concerns, feel free to tell me 😄 |
[Additional description] On
An example of func init() {
fmt.Println("Start......... init() of controller.go")
ex, err := os.Executable()
if err != nil {
panic(err)
}
exePath := filepath.Dir(ex)
fmt.Printf("exePath: %v\n", exePath)
// Load cb-log config from the current directory (usually for the production)
logConfPath := filepath.Join(exePath, "config", "log_conf.yaml")
fmt.Printf("logConfPath: %v\n", logConfPath)
if !file.Exists(logConfPath) {
// Load cb-log config from the project directory (usually for development)
path, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
if err != nil {
panic(err)
}
projectPath := strings.TrimSpace(string(path))
logConfPath = filepath.Join(projectPath, "poc-cb-net", "config", "log_conf.yaml")
}
CBLogger = cblog.GetLoggerWithConfigPath("cb-network", logConfPath)
CBLogger.Debugf("Load %v", logConfPath)
// Load cb-network config from the current directory (usually for the production)
configPath := filepath.Join(exePath, "config", "config.yaml")
fmt.Printf("configPath: %v\n", configPath)
if !file.Exists(configPath) {
// Load cb-network config from the project directory (usually for the development)
path, err := exec.Command("git", "rev-parse", "--show-toplevel").Output()
if err != nil {
panic(err)
}
projectPath := strings.TrimSpace(string(path))
configPath = filepath.Join(projectPath, "poc-cb-net", "config", "config.yaml")
}
config, _ = model.LoadConfig(configPath)
CBLogger.Debugf("Load %v", configPath)
fmt.Println("End......... init() of controller.go")
} |
Hi, @ChobobDev If you are working on this issue, could you share your progress? 😄 |
I am sorry @hermitkim1 I am still trying to understand this issue. Thank You |
@ChobobDev, I fully understand your difficulty on this issue If you have any discussion points, feel free to tell me. |
What would you like to be enhanced
: I'd like to read
config
properly.Why is this needed
: The
config
setting code is redundant in manyinit()
.Proposed solution
:
The text was updated successfully, but these errors were encountered: