Skip to content

Commit

Permalink
Don't allow config map to override existing facts
Browse files Browse the repository at this point in the history
  • Loading branch information
bastjan committed Nov 14, 2023
1 parent 47423b4 commit 506f6bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func main() {
app.
Flag(
"additional-facts-config-map",
"Additional facts added to the dynamic facts in the cluster object. Keys in the configmap's data field override existing keys.").
"Additional facts added to the dynamic facts in the cluster object. Keys in the configmap's data field can't override existing keys.").
Default("additional-facts").
StringVar(&agent.AdditionalFactsConfigMap)
app.
Expand Down
17 changes: 9 additions & 8 deletions pkg/agent/facts/facts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ type FactCollector struct {

func (col FactCollector) FetchDynamicFacts(ctx context.Context) (*api.DynamicClusterFacts, error) {
facts := api.DynamicClusterFacts{}

additionalFacts, err := col.fetchAdditionalFacts(ctx)
if err != nil {
klog.Errorf("Error fetching additional facts: %v", err)
}
for k, v := range additionalFacts {
facts[k] = v
}

kubeVersion, err := col.fetchKubernetesVersion(ctx)
if err != nil {
klog.Errorf("Error fetching kubernetes version: %v", err)
Expand All @@ -49,14 +58,6 @@ func (col FactCollector) FetchDynamicFacts(ctx context.Context) (*api.DynamicClu
facts["openshiftOAuthRoute"] = ocpOAuthRoute
}

additionalFacts, err := col.fetchAdditionalFacts(ctx)
if err != nil {
klog.Errorf("Error fetching additional facts: %v", err)
}
for k, v := range additionalFacts {
facts[k] = v
}

return &facts, nil
}

Expand Down

0 comments on commit 506f6bf

Please sign in to comment.