Skip to content

Commit

Permalink
Modified serviceName string handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9211 committed Oct 4, 2021
1 parent 0a9ef38 commit e38f2b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/config/viperconfig.go
Expand Up @@ -24,7 +24,7 @@ type ViperConfig struct {
// Wire-Jacket uses envfile format if there is no file extension.
// You can use the --config flag to explicitly specify a config file.
//
// The Twelve-Factors recommands use environment variables for
// The Twelve-Factors recommends use environment variables for
// configuration. Because it's good in container, cloud environments.
// However, it is not efficient to express all configs as environment
// variables.
Expand Down
9 changes: 9 additions & 0 deletions wirejacket.go
Expand Up @@ -79,6 +79,10 @@ func New() *WireJacket {
//
// If serviceName exists, WireJacket reads value of
// '{serviceName}_modules' in config.
// the spaces of serviceName will be changed to '_'.
// serviceName will be used in config, we don't recommend it
// to contain space.
//
// By default, WireJacket reads app.conf. Or you can specify
// file with '--config' flag.(see viperconfig.go)
//
Expand Down Expand Up @@ -107,6 +111,11 @@ func NewWithServiceName(serviceName string) *WireJacket {

func (wj *WireJacket) readActivatingModules(serviceName string) []string {
var activatingModuleNames []string
if strings.Contains(serviceName, " ") {
serviceName = strings.ReplaceAll(
strings.Join(strings.Fields(serviceName), " "),
" ", "_")
}
if serviceName == "" {
activatingModuleNames = wj.config.GetStringSlice(
"modules", []string{},
Expand Down

0 comments on commit e38f2b3

Please sign in to comment.