Skip to content

Commit 5c72967

Browse files
committed
various: Add missing docstrings to fix linter error
1 parent 81a1f68 commit 5c72967

File tree

7 files changed

+24
-3
lines changed

7 files changed

+24
-3
lines changed

mod-frrouting/init.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ type frroutingModule struct {
3535
TelnetPassword string
3636
}
3737

38-
func NewFrroutingModule() *frroutingModule {
38+
// NewFrroutingModule instantiates frroutingModule and all contained plugins
39+
func NewFrroutingModule() nagocheck.Module {
3940
return &frroutingModule{
4041
Module: nagocheck.NewModule("frrouting",
4142
nagocheck.ModuleDescription("FRRouting"),

mod-system/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type systemModule struct {
2424
nagocheck.Module
2525
}
2626

27+
// NewSystemModule instantiates systemModule and all contained plugins
2728
func NewSystemModule() nagocheck.Module {
2829
return &systemModule{
2930
Module: nagocheck.NewModule("system",

nagocheck/kingpin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"gopkg.in/alecthomas/kingpin.v2"
66
)
77

8+
// KingpinNode is a unified interface for kingpin, which allows using Arg() and Flag() at root- and command-level
89
type KingpinNode interface {
910
Arg(name, help string) *kingpin.ArgClause
1011
Flag(name, help string) *kingpin.FlagClause

nagocheck/module.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"gopkg.in/alecthomas/kingpin.v2"
2525
)
2626

27-
// Module collects several plugin commands underneath a module command and offers the possibility to define CLI flags
27+
// Module consists out of several plugins and offers methods for executing them
2828
type Module interface {
2929
Name() string
3030
Description() string
@@ -37,6 +37,7 @@ type Module interface {
3737
GetPluginByName(pluginName string) (Plugin, error)
3838
}
3939

40+
// ModuleOpt is a type alias for functional options used by NewModule()
4041
type ModuleOpt func(*baseModule)
4142

4243
type baseModule struct {
@@ -45,6 +46,8 @@ type baseModule struct {
4546
plugins map[string]Plugin
4647
}
4748

49+
// RegisterModules returns a map of modules with their name as the respective key. Additionally, all plugins contained
50+
// by these modules are being registered to their respective module using Plugin.setModule()
4851
func RegisterModules(modules ...Module) map[string]Module {
4952
result := make(map[string]Module)
5053
for _, module := range modules {
@@ -57,7 +60,7 @@ func RegisterModules(modules ...Module) map[string]Module {
5760
return result
5861
}
5962

60-
// NewModule instantiates a new baseModule, which should be inherited by user-defined module types
63+
// NewModule instantiates baseModule with the given functional options
6164
func NewModule(name string, options ...ModuleOpt) Module {
6265
module := &baseModule{
6366
name: name,
@@ -72,12 +75,14 @@ func NewModule(name string, options ...ModuleOpt) Module {
7275
return module
7376
}
7477

78+
// ModuleDescription is a functional option for NewModule(), which sets the module description
7579
func ModuleDescription(description string) ModuleOpt {
7680
return func(m *baseModule) {
7781
m.description = description
7882
}
7983
}
8084

85+
// ModulePlugin is a functional option for NewModule(), which registers a plugin using Module.RegisterPlugin()
8186
func ModulePlugin(plugin Plugin) ModuleOpt {
8287
return func(m *baseModule) {
8388
m.RegisterPlugin(plugin)

nagocheck/plugin.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/snapserv/nagopher"
55
)
66

7+
// Plugin represents a single check including its CLI arguments
78
type Plugin interface {
89
Name() string
910
Description() string
@@ -19,6 +20,7 @@ type Plugin interface {
1920
defineDefaultFlags(node KingpinNode)
2021
}
2122

23+
// PluginOpt is a type alias for functional options used by NewPlugin()
2224
type PluginOpt func(*basePlugin)
2325

2426
type basePlugin struct {
@@ -33,6 +35,7 @@ type basePlugin struct {
3335
criticalThreshold nagopher.OptionalBounds
3436
}
3537

38+
// NewPlugin instantiates basePlugin with the given functional options
3639
func NewPlugin(name string, options ...PluginOpt) Plugin {
3740
plugin := &basePlugin{
3841
name: name,
@@ -48,18 +51,21 @@ func NewPlugin(name string, options ...PluginOpt) Plugin {
4851
return plugin
4952
}
5053

54+
// PluginDescription is a functional option for NewPlugin(), which sets the module description
5155
func PluginDescription(description string) PluginOpt {
5256
return func(p *basePlugin) {
5357
p.description = description
5458
}
5559
}
5660

61+
// PluginDefaultFlags is a functional option for NewPlugin(), which toggles the definition of default flags
5762
func PluginDefaultFlags(enabled bool) PluginOpt {
5863
return func(p *basePlugin) {
5964
p.useDefaultFlags = enabled
6065
}
6166
}
6267

68+
// PluginDefaultThresholds is a functional option for NewPlugin(), which toggles the definition of default thresholds
6369
func PluginDefaultThresholds(enabled bool) PluginOpt {
6470
return func(p *basePlugin) {
6571
p.useDefaultThresholds = enabled

nagocheck/resource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import (
1010
"syscall"
1111
)
1212

13+
// Resource provides a base type for nagocheck resources, which embeds nagopher.Resource
1314
type Resource interface {
1415
nagopher.Resource
1516
Plugin() Plugin
1617
}
1718

19+
// ResourceOpt is a type alias for functional options used by NewSummarizer()
1820
type ResourceOpt func(*baseResource)
1921

2022
type baseResource struct {
@@ -27,6 +29,7 @@ type baseResource struct {
2729
const shmOpenFlags = os.O_CREATE | os.O_RDONLY | syscall.O_DSYNC | syscall.O_RSYNC
2830
const shmDefaultMode = 0600
2931

32+
// NewResource instantiates baseResource with the given functional options
3033
func NewResource(plugin Plugin, options ...ResourceOpt) Resource {
3134
resource := &baseResource{
3235
Resource: nagopher.NewResource(),
@@ -40,6 +43,7 @@ func NewResource(plugin Plugin, options ...ResourceOpt) Resource {
4043
return resource
4144
}
4245

46+
// ResourcePersistence is a functional option for NewResource(), which enables resource persistence with the given key
4347
func ResourcePersistence(uniqueKey string) ResourceOpt {
4448
return func(r *baseResource) {
4549
r.persistenceKey = r.Plugin().Name() + uniqueKey

nagocheck/summarizer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@ package nagocheck
22

33
import "github.com/snapserv/nagopher"
44

5+
// Summarizer provides a base type for nagocheck summarizers, which embeds nagopher.Summarizer
56
type Summarizer interface {
67
nagopher.Summarizer
78
Plugin() Plugin
89
}
910

11+
// SummarizerOpt is a type alias for functional options used by NewSummarizer()
1012
type SummarizerOpt func(*baseSummarizer)
1113

1214
type baseSummarizer struct {
1315
nagopher.Summarizer
1416
plugin Plugin
1517
}
1618

19+
// NewSummarizer instantiates baseSummarizer with the given functional options
1720
func NewSummarizer(plugin Plugin, options ...SummarizerOpt) Summarizer {
1821
summarizer := &baseSummarizer{
1922
Summarizer: nagopher.NewSummarizer(),

0 commit comments

Comments
 (0)