Skip to content

Commit

Permalink
fix: host add a local config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Qiu Jian committed Dec 8, 2023
1 parent 4959215 commit 9373170
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/hostman/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ package options
import (
"os"

"yunion.io/x/log"
"yunion.io/x/structarg"

common_options "yunion.io/x/onecloud/pkg/cloudcommon/options"
"yunion.io/x/onecloud/pkg/util/fileutils2"
"yunion.io/x/onecloud/pkg/util/ovnutils"
Expand Down Expand Up @@ -50,6 +53,7 @@ type SHostOptions struct {
SHostBaseOptions

CommonConfigFile string `help:"common config file for container"`
LocalConfigFile string `help:"local config file" default:"/etc/yunion/host_local.conf"`

HostType string `help:"Host server type, either hypervisor or kubelet" default:"hypervisor"`
ListenInterface string `help:"Master address of host server"`
Expand Down Expand Up @@ -216,6 +220,17 @@ func Parse() (hostOpts SHostOptions) {
// keep base options
hostOpts.BaseOptions.BaseOptions = baseOpt
}
if len(hostOpts.LocalConfigFile) > 0 && fileutils2.Exists(hostOpts.LocalConfigFile) {
log.Infof("Use local configuration file: %s", hostOpts.Config)
parser, err := structarg.NewArgumentParser(&hostOpts, "", "", "")
if err != nil {
log.Fatalf("fail to create local parse %s", err)
}
err = parser.ParseFile(hostOpts.LocalConfigFile)
if err != nil {
log.Fatalf("Parse local configuration file: %v", err)
}
}
return hostOpts
}

Expand Down

0 comments on commit 9373170

Please sign in to comment.