Skip to content

Commit

Permalink
rename ConfigHook => CfgHook (lint failure)
Browse files Browse the repository at this point in the history
Signed-off-by: Peekjef72 <67902897+peekjef72@users.noreply.github.com>
  • Loading branch information
peekjef72 committed Apr 22, 2023
1 parent 65793ad commit 88503c1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ type collectorBuilder func() (Collector, error)
var (
builders = make(map[string]collectorBuilder)
perfCounterDependencies = make(map[string]string)
config_hooks = make(map[string]config.ConfigHook)
config_hooks = make(map[string]config.CfgHook)
)

func registerCollector(name string, builder collectorBuilder, hooks map[string]config.ConfigHook, perfCounterNames ...string) {
func registerCollector(name string, builder collectorBuilder, hooks map[string]config.CfgHook, perfCounterNames ...string) {
builders[name] = builder
addPerfCounterDependencies(name, perfCounterNames)
for k, v := range hooks {
Expand All @@ -82,7 +82,7 @@ func Available() []string {
}
return cs
}
func ConfigHooks() map[string]config.ConfigHook {
func CfgHooks() map[string]config.CfgHook {
return config_hooks
}
func Build(collector string) (Collector, error) {
Expand Down
4 changes: 2 additions & 2 deletions collector/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type collectorInit struct {
// Perflib counter names for the collector.
// These will be included in the Perflib scrape scope by the exporter.
perfCounterNames []string
// builder fonction to intercept parameters for a collector
config_hooks map[string]config.ConfigHook
// builder function to intercept parameters for a collector
config_hooks map[string]config.CfgHook
}

func getCPUCollectorDeps() string {
Expand Down
6 changes: 3 additions & 3 deletions collector/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ func expandServiceWhere(services string) string {
return b.String()
}

func ServiceBuildHook() map[string]config.ConfigHook {
config_hooks := &config.ConfigHook{
func ServiceBuildHook() map[string]config.CfgHook {
config_hooks := &config.CfgHook{
ConfigAttrs: []string{"collector", "service", "services"},
Hook: ServiceBuildMap,
}
entry := make(map[string]config.ConfigHook)
entry := make(map[string]config.CfgHook)
entry["services-list"] = *config_hooks
return entry
}
Expand Down
14 changes: 7 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ type Resolver struct {

type HookFunc func(interface{}) map[string]string

type ConfigHook struct {
type CfgHook struct {
ConfigAttrs []string
Hook HookFunc
}

type ConfigHooks map[string]ConfigHook
type CfgHooks map[string]CfgHook

func (c *ConfigHook) match(key string, val interface{}, level int) (bool, interface{}) {
var ok bool = false
func (c *CfgHook) match(key string, val interface{}, level int) (bool, interface{}) {
var res interface{}
ok := false
if level < len(c.ConfigAttrs) {
if c.ConfigAttrs[level] == key {
level++
Expand Down Expand Up @@ -74,9 +74,9 @@ func (c *ConfigHook) match(key string, val interface{}, level int) (bool, interf
return ok, res
}

func (c *ConfigHooks) Match(key string, val interface{}) (map[string]interface{}, bool) {
var ok bool = false
func (c *CfgHooks) Match(key string, val interface{}) (map[string]interface{}, bool) {
var value interface{}
ok := false
params := make(map[string]interface{})

for varname, hook := range *c {
Expand All @@ -89,7 +89,7 @@ func (c *ConfigHooks) Match(key string, val interface{}) (map[string]interface{}
}

// NewResolver returns a Resolver structure.
func NewResolver(file string, hooks ConfigHooks) (*Resolver, error) {
func NewResolver(file string, hooks CfgHooks) (*Resolver, error) {
flags := map[string]string{}
log.Infof("Loading configuration file: %v", file)
if _, err := os.Stat(file); err != nil {
Expand Down

0 comments on commit 88503c1

Please sign in to comment.