Skip to content

Commit

Permalink
Rename cmd/channel to cmd/channels
Browse files Browse the repository at this point in the history
There are multiple channel plugins under cmd/channel. Especially later
in the installation, the channels directory will contain multiple
channels, not just one.

For consistency, the YAML configuration channel-plugin-dir was renamed
to channels-dir. The "plugin" part was dropped as it is redundant here.

Closes #224
  • Loading branch information
oxzi authored and julianbrost committed Jun 27, 2024
1 parent e6f870d commit 32bf26e
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ all:
-o build/ \
-ldflags "-X '$(pkg).LibExecDir=$(libexecdir)' -X '$(pkg).SysConfDir=$(sysconfdir)'" \
./cmd/icinga-notifications
go build -o build/channel/ ./cmd/channel/...
go build -o build/channels/ ./cmd/channels/...

test:
go test ./...
Expand All @@ -28,9 +28,9 @@ install:
install -m644 config.example.yml $(DESTDIR)$(sysconfdir)/icinga-notifications/config.yml
@# dameon
install -D build/icinga-notifications $(DESTDIR)$(sbindir)/icinga-notifications
@# channel plugins
install -d $(DESTDIR)$(libexecdir)/icinga-notifications/channel
install build/channel/* $(DESTDIR)$(libexecdir)/icinga-notifications/channel/
@# channels
install -d $(DESTDIR)$(libexecdir)/icinga-notifications/channels
install build/channels/* $(DESTDIR)$(libexecdir)/icinga-notifications/channels/
@# database schema
install -d $(DESTDIR)$(datadir)/icinga-notifications
cp -rv --no-dereference schema $(DESTDIR)$(datadir)/icinga-notifications
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/icinga-notifications/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
logger.Fatalf("Cannot connect to the database: %+v", err)
}

channel.UpsertPlugins(ctx, conf.ChannelPluginDir, logs.GetChildLogger("channel"), db)
channel.UpsertPlugins(ctx, conf.ChannelsDir, logs.GetChildLogger("channel"), db)

icinga2Launcher := &icinga2.Launcher{
Ctx: ctx,
Expand Down
2 changes: 1 addition & 1 deletion config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#debug-password: "put-something-secret-here"

icingaweb2-url: http://localhost/icingaweb2/
#channel-plugin-dir: /usr/libexec/icinga-notifications/channel
#channels-dir: /usr/libexec/icinga-notifications/channels
api-timeout: 1m

database:
Expand Down
2 changes: 1 addition & 1 deletion internal/channel/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Plugin struct {

// NewPlugin starts and returns a new plugin instance. If the start of the plugin fails, an error is returned
func NewPlugin(pluginType string, logger *zap.SugaredLogger) (*Plugin, error) {
file := filepath.Join(daemon.Config().ChannelPluginDir, pluginType)
file := filepath.Join(daemon.Config().ChannelsDir, pluginType)

logger.Debugw("Starting new channel plugin process", zap.String("path", file))

Expand Down
18 changes: 9 additions & 9 deletions internal/daemon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ import (
)

type ConfigFile struct {
Listen string `yaml:"listen" default:"localhost:5680"`
DebugPassword string `yaml:"debug-password"`
ChannelPluginDir string `yaml:"channel-plugin-dir"`
ApiTimeout time.Duration `yaml:"api-timeout" default:"1m"`
Icingaweb2URL string `yaml:"icingaweb2-url"`
Database database.Config `yaml:"database"`
Logging logging.Config `yaml:"logging"`
Listen string `yaml:"listen" default:"localhost:5680"`
DebugPassword string `yaml:"debug-password"`
ChannelsDir string `yaml:"channels-dir"`
ApiTimeout time.Duration `yaml:"api-timeout" default:"1m"`
Icingaweb2URL string `yaml:"icingaweb2-url"`
Database database.Config `yaml:"database"`
Logging logging.Config `yaml:"logging"`
}

// SetDefaults implements the defaults.Setter interface.
func (c *ConfigFile) SetDefaults() {
if defaults.CanUpdate(c.ChannelPluginDir) {
c.ChannelPluginDir = internal.LibExecDir + "/icinga-notifications/channel"
if defaults.CanUpdate(c.ChannelsDir) {
c.ChannelsDir = internal.LibExecDir + "/icinga-notifications/channels"
}
}

Expand Down

0 comments on commit 32bf26e

Please sign in to comment.