forked from AliyunContainerService/pouch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: refactor damon config code
1. move daemon config code from main.go to daemon/config/config.go. 2. supports to resolve config file contains nested object. 3. skip check conflict in slice type flags and merge them. Signed-off-by: Ace-Tang <[email protected]>
- Loading branch information
Showing
6 changed files
with
207 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestIterateConfig(t *testing.T) { | ||
assert := assert.New(t) | ||
origin := map[string]interface{}{ | ||
"a": "a", | ||
"b": "b", | ||
"c": "c", | ||
"iter1": map[string]interface{}{ | ||
"i1": "i1", | ||
"i2": "i2", | ||
}, | ||
"iter11": map[string]interface{}{ | ||
"ii1": map[string]interface{}{ | ||
"iii1": "iii1", | ||
"iii2": "iii2", | ||
}, | ||
}, | ||
} | ||
|
||
expect := map[string]interface{}{ | ||
"a": "a", | ||
"b": "b", | ||
"c": "c", | ||
"i1": "i1", | ||
"i2": "i2", | ||
"iii1": "iii1", | ||
"iii2": "iii2", | ||
} | ||
|
||
config := make(map[string]interface{}) | ||
iterateConfig(origin, config) | ||
assert.Equal(config, expect) | ||
|
||
// test nil map will not cause panic | ||
config = make(map[string]interface{}) | ||
iterateConfig(nil, config) | ||
assert.Equal(config, map[string]interface{}{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters