Skip to content

Commit d4fd3c6

Browse files
committed
bugfix: check int type is empty
check int type is empty when do the merge. Signed-off-by: Rudy Zhang <[email protected]>
1 parent 270093c commit d4fd3c6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

daemon/config/config.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/alibaba/pouch/pkg/utils"
1818
"github.com/alibaba/pouch/storage/volume"
1919

20+
"github.com/sirupsen/logrus"
2021
"github.com/spf13/pflag"
2122
)
2223

@@ -131,6 +132,10 @@ func (cfg *Config) GetCgroupDriver() string {
131132

132133
// Validate validates the user input config.
133134
func (cfg *Config) Validate() error {
135+
// for debug config file.
136+
b, _ := json.Marshal(cfg)
137+
logrus.Debugf("daemon config: (%s)", string(b))
138+
134139
// deduplicated elements in slice if there is any.
135140
cfg.Listen = utils.DeDuplicate(cfg.Listen)
136141
cfg.Labels = utils.DeDuplicate(cfg.Labels)
@@ -193,7 +198,6 @@ func (cfg *Config) MergeConfigurations(flagSet *pflag.FlagSet) error {
193198
// merge configurations from command line flags and config file
194199
err = mergeConfigurations(fileConfig, cfg.delValue(flagSet, fileFlags))
195200
return err
196-
197201
}
198202

199203
// delValue deleles value in config, since we do not do conflict check for slice

pkg/utils/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ func isEmptyValue(v reflect.Value) bool {
122122
switch v.Kind() {
123123
case reflect.Array, reflect.Map, reflect.Slice, reflect.String:
124124
return v.Len() == 0
125+
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
126+
return v.Int() == 0
125127
case reflect.Uintptr:
126128
return v.Uint() == 0
127129
case reflect.Float32, reflect.Float64:

0 commit comments

Comments
 (0)