Skip to content

Commit

Permalink
Bugfix: Preserve inline profile names.
Browse files Browse the repository at this point in the history
  • Loading branch information
dplepage-dd committed Jan 29, 2025
1 parent bfeef40 commit c536c76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ func loadInitConfigProfiles(rawInitConfigProfiles ProfileConfigMap) (ProfileConf
log.Warnf("unable to load profile %q: %s", name, err)
continue
}
if profDefinition.Name == "" {
profDefinition.Name = name
}
profConfig.Definition = *profDefinition
}
if profConfig.Definition.Name == "" {
profConfig.Definition.Name = name
}
initConfigProfiles[name] = profConfig
}

Expand Down
10 changes: 2 additions & 8 deletions pkg/collector/corechecks/snmp/internal/profile/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,9 @@ func Test_loadProfiles(t *testing.T) {
name: "OK Use init config profiles",
mockConfd: "conf.d",
profiles: ProfileConfigMap{
"my-init-config-profile": ProfileConfig{
Definition: profiledefinition.ProfileDefinition{
Name: "my-init-config-profile",
},
},
"my-init-config-profile": ProfileConfig{},
"f5-big-ip": ProfileConfig{ // should have precedence over user profiles
Definition: profiledefinition.ProfileDefinition{
Name: "f5-big-ip",
Metrics: []profiledefinition.MetricsConfig{
{
Symbol: profiledefinition.SymbolConfig{
Expand All @@ -64,7 +59,6 @@ func Test_loadProfiles(t *testing.T) {
profiles: ProfileConfigMap{
"my-init-config-profile": ProfileConfig{
Definition: profiledefinition.ProfileDefinition{
Name: "my-init-config-profile",
MetricTags: profiledefinition.MetricTagConfigList{
{
Match: "invalidRegex({[",
Expand Down Expand Up @@ -102,7 +96,7 @@ func Test_loadProfiles(t *testing.T) {
}
var actualProfilesNames []string
for profileName := range actualProfiles {
actualProfilesNames = append(actualProfilesNames, profileName)
actualProfilesNames = append(actualProfilesNames, actualProfiles[profileName].Definition.Name)
}
sort.Strings(actualProfilesNames)
sort.Strings(tt.expectedProfileNames)
Expand Down

0 comments on commit c536c76

Please sign in to comment.