Skip to content

Commit

Permalink
channel/plugin.go: UpsertPlugins(): use filename as type
Browse files Browse the repository at this point in the history
- The Upsert() func is no longer required because Info{} contains all that properties.
- Fix reciver param name of Info.TableName() method.
- Remove type from GetInfo to make it non-configurable. The file name should always be used as the type.
  • Loading branch information
sukhwinder33445 authored and julianbrost committed Nov 14, 2023
1 parent 3c904bf commit 6f4b437
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 14 deletions.
1 change: 0 additions & 1 deletion cmd/channel/email/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func (ch *Email) GetInfo() *plugin.Info {
}

return &plugin.Info{
Type: "email",
Name: "Email",
Version: internal.Version.Version,
Author: "Icinga GmbH",
Expand Down
1 change: 0 additions & 1 deletion cmd/channel/rocketchat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func (ch *RocketChat) GetInfo() *plugin.Info {
}

return &plugin.Info{
Type: "rocketchat",
Name: "Rocket.Chat",
Version: internal.Version.Version,
Author: "Icinga GmbH",
Expand Down
1 change: 1 addition & 0 deletions internal/channel/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ func UpsertPlugins(channelPluginDir string, logger *logging.Logger, db *icingadb
continue
}
p.Stop()
info.Type = pluginType

pluginTypes = append(pluginTypes, pluginType)
pluginInfos = append(pluginInfos, info)
Expand Down
14 changes: 2 additions & 12 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,18 @@ type ConfigOption struct {

// Info contains plugin information.
type Info struct {
Type string `db:"type" json:"type"`
Type string `db:"type" json:"-"`
Name string `db:"name" json:"name"`
Version string `db:"version" json:"version"`
Author string `db:"author" json:"author"`
ConfigAttributes json.RawMessage `db:"config_attrs" json:"config_attrs"` // ConfigOption(s) as json-encoded list
}

// TableName implements the contracts.TableNamer interface.
func (c *Info) TableName() string {
func (i *Info) TableName() string {
return "available_channel_type"
}

// Upsert implements the contracts.Upserter interface.
func (c *Info) Upsert() interface{} {
return struct {
Name string `db:"name"`
Version string `db:"version"`
Author string `db:"author"`
ConfigAttributes json.RawMessage `db:"config_attrs"`
}{}
}

type Contact struct {
FullName string `json:"full_name"`
Addresses []*Address `json:"addresses"`
Expand Down

0 comments on commit 6f4b437

Please sign in to comment.