Skip to content

Commit

Permalink
fix default metadata config: ensure that AddResourceMetadataConfig.No…
Browse files Browse the repository at this point in the history
…de and AddResourceMetadataConfig.Namespace are different objects

Signed-off-by: Tetiana Kravchenko <[email protected]>
  • Loading branch information
tetianakravchenko committed Dec 19, 2023
1 parent 75a19b0 commit 303117f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kubernetes/metadata/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ func (c *Config) Unmarshal(cfg *config.C) error {
func GetDefaultResourceMetadataConfig() *AddResourceMetadataConfig {
metaConfig := Config{}
metaConfig.InitDefaults()
metaCfg, _ := config.NewConfigFrom(&metaConfig)
nodeCfg, _ := config.NewConfigFrom(metaConfig)
nsCfg, _ := config.NewConfigFrom(metaConfig)
return &AddResourceMetadataConfig{
Node: metaCfg,
Namespace: metaCfg,
Node: nodeCfg,
Namespace: nsCfg,
Deployment: false,
CronJob: false,
}
Expand Down
1 change: 1 addition & 0 deletions kubernetes/metadata/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ func TestPod_Generate(t *testing.T) {
"annotations.dedot": false,
})
assert.NoError(t, err)
assert.NotEqual(t, *addResourceMetadata.Namespace, *addResourceMetadata.Node)

replicaSets := cache.NewStore(cache.MetaNamespaceKeyFunc)
err = replicaSets.Add(rs)
Expand Down

0 comments on commit 303117f

Please sign in to comment.