-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid error log when unmarshalling config for MC controller
The MultiClusterConfig struct does not have yaml tags, only json tags. Therefore, trying to unmarshal it as YAML (by calling yaml.UnmarshalLenient) will not work, and will show a log indicating that strict unmarshalling has failed. The resulting struct object will be all empty, since none of the fields can be decoded without a tag. A key observation is that calling yaml.UnmarshalLenient does not serve any purpose, as we are also calling runtime.DecodeInto (which will first convert the YAML data to JSON data, before unmarshalling). Hence we can just remove the call to yaml.UnmarshalLenient. We add a couple of unit tests, and in particular we validate that the default controller_manager_config.yaml config can be unmarshalled (strictly) to MultiClusterConfig. While this is slightly orthogonal to the issue being addressed here, it may help avoid issues in the future as it ensures that the default config is always in sync with the struct definition. Signed-off-by: Antonin Bas <[email protected]>
- Loading branch information
1 parent
9c7424a
commit 2ce03d9
Showing
3 changed files
with
36 additions
and
12 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
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,6 @@ | ||
package multicluster | ||
|
||
import _ "embed" | ||
|
||
//go:embed config/default/configmap/controller_manager_config.yaml | ||
var DefaultControllerManagerConfigBytes []byte |