Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename cmd/channel to cmd/channels #225

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading