Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
firehouse-smokedetection
Backend
Commits
369f7b50
Verified
Commit
369f7b50
authored
1 month ago
by
Jonas Leder
Browse files
Options
Downloads
Patches
Plain Diff
call plugin setup
parent
3008a3ae
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!6
Implement Plugin interface for alarming
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
alarm/init.go
+6
-2
6 additions, 2 deletions
alarm/init.go
with
6 additions
and
2 deletions
alarm/init.go
+
6
−
2
View file @
369f7b50
...
@@ -6,14 +6,16 @@ import (
...
@@ -6,14 +6,16 @@ import (
"plugin"
"plugin"
"strings"
"strings"
"jonasled.dev/firehouse-smokedetection/backend/database"
plugininterface
"jonasled.dev/firehouse-smokedetection/plugin-interface"
plugininterface
"jonasled.dev/firehouse-smokedetection/plugin-interface"
"jonasled.dev/jonasled/go-libs/config"
"jonasled.dev/jonasled/go-libs/config"
"jonasled.dev/jonasled/go-libs/log"
"jonasled.dev/jonasled/go-libs/log"
)
)
var
plugins
[
]
plugininterface
.
Plugin
var
plugins
map
[
string
]
plugininterface
.
Plugin
func
Init
()
{
func
Init
()
{
plugins
=
make
(
map
[
string
]
plugininterface
.
Plugin
)
err
:=
filepath
.
Walk
(
config
.
GetOrDefault
(
"PLUGIN_DIR"
,
"./plugins"
),
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
err
:=
filepath
.
Walk
(
config
.
GetOrDefault
(
"PLUGIN_DIR"
,
"./plugins"
),
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Log
.
Fatal
(
"Failed reading plugin dir: "
,
err
.
Error
())
log
.
Log
.
Fatal
(
"Failed reading plugin dir: "
,
err
.
Error
())
...
@@ -34,9 +36,11 @@ func Init() {
...
@@ -34,9 +36,11 @@ func Init() {
log
.
Log
.
Fatalf
(
"Failed parsing plugin %s as Plugin Interface"
,
path
)
log
.
Log
.
Fatalf
(
"Failed parsing plugin %s as Plugin Interface"
,
path
)
}
}
plugin
.
Setup
(
database
.
Db
)
log
.
Log
.
Infof
(
"Initialized Plugin %s (v%s)"
,
plugin
.
GetMetadata
()
.
Name
,
plugin
.
GetMetadata
()
.
Version
)
log
.
Log
.
Infof
(
"Initialized Plugin %s (v%s)"
,
plugin
.
GetMetadata
()
.
Name
,
plugin
.
GetMetadata
()
.
Version
)
plugins
=
append
(
plugins
,
plugin
)
plugins
[
plugin
.
GetMetadata
()
.
Name
]
=
plugin
}
}
return
nil
return
nil
})
})
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment