Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
goSDN
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
danet
goSDN
Commits
8694ce92
Commit
8694ce92
authored
1 year ago
by
Malte Bauch
Browse files
Options
Downloads
Patches
Plain Diff
Plugin registry stores plugin information to file
parent
ecf73f50
No related branches found
No related tags found
1 merge request
!690
Add a file storage to plugin registry
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
go.mod
+1
-3
1 addition, 3 deletions
go.mod
go.sum
+10
-249
10 additions, 249 deletions
go.sum
plugin-registry/main.go
+33
-19
33 additions, 19 deletions
plugin-registry/main.go
plugin-registry/registry.go
+1
-0
1 addition, 0 deletions
plugin-registry/registry.go
with
45 additions
and
271 deletions
go.mod
+
1
−
3
View file @
8694ce92
...
...
@@ -55,7 +55,6 @@ require (
github.com/mattn/go-isatty
v0.0.19 // indirect
github.com/mattn/go-runewidth
v0.0.15 // indirect
github.com/mattn/go-tty
v0.0.3 // indirect
github.com/matttproud/golang_protobuf_extensions
v1.0.4 // indirect
github.com/mitchellh/mapstructure
v1.5.0 // indirect
github.com/montanaflynn/stats
v0.7.1 // indirect
github.com/opencontainers/go-digest
v1.0.0 // indirect
...
...
@@ -73,7 +72,6 @@ require (
github.com/sethvargo/go-retry
v0.2.4
github.com/spf13/afero
v1.11.0 // indirect
github.com/spf13/cast
v1.6.0 // indirect
github.com/spf13/jwalterweatherman
v1.1.0 // indirect
github.com/subosito/gotenv
v1.6.0 // indirect
github.com/xdg-go/pbkdf2
v1.0.0 // indirect
github.com/xdg-go/scram
v1.1.2 // indirect
...
...
@@ -94,6 +92,7 @@ require (
github.com/hashicorp/go-multierror
v1.1.1
github.com/hashicorp/go-plugin
v1.4.10
github.com/lesismal/nbio
v1.3.21
golang.org/x/mod
v0.14.0
google.golang.org/genproto/googleapis/api
v0.0.0-20240102182953-50ed04b92917
)
...
...
@@ -101,7 +100,6 @@ require (
atomicgo.dev/cursor
v0.2.0 // indirect
atomicgo.dev/keyboard
v0.2.9 // indirect
atomicgo.dev/schedule
v0.1.0 // indirect
github.com/antlr/antlr4/runtime/Go/antlr/v4
v4.0.0-20230512164433-5d1fd1a340c9 // indirect
github.com/antlr4-go/antlr/v4
v4.13.0 // indirect
github.com/containerd/console
v1.0.3 // indirect
github.com/fatih/color
v1.15.0 // indirect
...
...
This diff is collapsed.
Click to expand it.
go.sum
+
10
−
249
View file @
8694ce92
This diff is collapsed.
Click to expand it.
plugin-registry/main.go
+
33
−
19
View file @
8694ce92
...
...
@@ -9,13 +9,15 @@ import (
pb
"code.fbi.h-da.de/danet/gosdn/api/go/gosdn/plugin-registry"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/plugin"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/util"
"github.com/google/uuid"
"golang.org/x/mod/sumdb/dirhash"
"google.golang.org/grpc"
)
const
(
pluginFilePath
=
"plugins"
plugin
Name
=
"bundled_plugin.zip
"
pluginFilePath
=
"plugins"
plugin
StorePath
=
"plugin-store.json
"
)
func
main
()
{
...
...
@@ -41,37 +43,45 @@ func main() {
// after reboot. Therefore it would make sense to use a database. For a simple
// prototype this is currently hardcoded.
func
registerPlugins
()
*
PluginRegistry
{
file
s
,
err
:=
os
.
ReadDir
(
pluginFilePath
)
dir
s
,
err
:=
os
.
ReadDir
(
pluginFilePath
)
if
err
!=
nil
{
panic
(
err
)
}
pr
:=
&
PluginRegistry
{}
pluginStore
:=
NewStore
(
pluginStorePath
)
for
i
,
file
:=
range
file
s
{
fmt
.
Printf
(
"File %+v
\n
"
,
file
)
for
_
,
dir
:=
range
dir
s
{
fmt
.
Printf
(
"File %+v
\n
"
,
dir
)
if
file
.
IsDir
()
{
manifest
,
err
:=
plugin
.
ReadManifestFromFile
(
filepath
.
Join
(
pluginFilePath
,
file
.
Name
()))
if
dir
.
IsDir
()
{
dirPath
:=
filepath
.
Join
(
pluginFilePath
,
dir
.
Name
())
manifest
,
err
:=
plugin
.
ReadManifestFromFile
(
dirPath
)
if
err
!=
nil
{
panic
(
err
)
}
var
id
uuid
.
UUID
switch
i
{
case
0
:
id
=
uuid
.
MustParse
(
"e2c358b3-6482-4010-b0d8-679dff73153b"
)
case
1
:
id
=
uuid
.
MustParse
(
"d1c269a2-6482-4010-b0d8-679dff73153b"
)
case
2
:
id
=
uuid
.
MustParse
(
"f3b474c2-6482-4010-b0d8-679dff73153b"
)
default
:
break
dirHashed
,
err
:=
dirhash
.
HashDir
(
dirPath
,
dir
.
Name
()
+
manifest
.
Firmware
,
dirhash
.
DefaultHash
)
if
err
!=
nil
{
panic
(
err
)
}
//var id uuid.UUID
//switch i {
//case 0:
// id = uuid.MustParse("e2c358b3-6482-4010-b0d8-679dff73153b")
//case 1:
// id = uuid.MustParse("d1c269a2-6482-4010-b0d8-679dff73153b")
//case 2:
// id = uuid.MustParse("f3b474c2-6482-4010-b0d8-679dff73153b")
//default:
// break
//}
plugin
:=
&
Plugin
{
ID
:
id
,
Path
:
filepath
.
Join
(
pluginFilePath
,
file
.
Name
(),
pluginName
),
ID
:
uuid
.
New
(),
Path
:
filepath
.
Join
(
dirPath
,
util
.
BundledPluginName
),
Hash
:
dirHashed
,
Manifest
:
manifest
,
}
...
...
@@ -79,5 +89,9 @@ func registerPlugins() *PluginRegistry {
}
}
if
err
:=
pluginStore
.
Update
(
pr
.
Plugins
);
err
!=
nil
{
fmt
.
Println
(
err
)
}
return
pr
}
This diff is collapsed.
Click to expand it.
plugin-registry/registry.go
+
1
−
0
View file @
8694ce92
...
...
@@ -11,6 +11,7 @@ import (
type
Plugin
struct
{
ID
uuid
.
UUID
`json:"id,omitempty"`
Path
string
`json:"path,omitempty"`
Hash
string
`json:"hash,omitempty"`
Manifest
*
plugin
.
Manifest
`json:"manifest,omitempty"`
}
...
...
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