Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
ef14a915
Commit
ef14a915
authored
Sep 30, 2021
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed CreateClients function bug for plugin create
parent
09b5d909
Pipeline
#8082
failed with stages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
33 deletions
+16
-33
start.go
cmd/sidecar/start.go
+0
-20
start.go
pkg/plugins/start.go
+16
-13
No files found.
cmd/sidecar/start.go
View file @
ef14a915
...
...
@@ -142,23 +142,3 @@ func runtimePProf() {
}
}()
}
func
checkPlugin
(
pluginName
string
)
error
{
// check if plugin exists
pluginRoot
,
err
:=
repo
.
PluginPath
()
if
err
!=
nil
{
return
err
}
pluginPath
:=
filepath
.
Join
(
pluginRoot
,
pluginName
)
_
,
err
=
os
.
Stat
(
pluginPath
)
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
return
fmt
.
Errorf
(
"plugin file `%s` is required"
,
pluginPath
)
}
return
fmt
.
Errorf
(
"get plugin file state error: %w"
,
err
)
}
return
nil
}
pkg/plugins/start.go
View file @
ef14a915
...
...
@@ -2,6 +2,7 @@ package plugins
import
(
"fmt"
"os"
"os/exec"
"path/filepath"
...
...
@@ -9,6 +10,7 @@ import (
plugin
"github.com/hashicorp/go-plugin"
"github.com/link33/sidecar/internal/repo"
"github.com/link33/sidecar/tool"
)
var
logger
=
hclog
.
New
(
&
hclog
.
LoggerOptions
{
...
...
@@ -43,7 +45,7 @@ func CreateClient(sidecarID string, appchainConfig repo.Appchain, extra []byte)
}
// Request the plugin
raw
,
err
:=
rpcClient
.
Dispense
(
PluginName
)
raw
,
err
:=
rpcClient
.
Dispense
(
appchainConfig
.
Plugin
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
...
...
@@ -74,7 +76,14 @@ func CreateClients(appchainConfigs repo.Appchains, extra []byte) []Client {
var
clients
[]
Client
for
_
,
appchainConfig
:=
range
appchainConfigs
.
Appchains
{
pluginConfigPath
:=
filepath
.
Join
(
rootPath
,
appchainConfig
.
Config
)
pluginPath
:=
filepath
.
Join
(
rootPath
,
"plugins"
,
appchainConfig
.
Config
)
pluginPath
:=
filepath
.
Join
(
rootPath
,
"plugins"
,
appchainConfig
.
Plugin
)
_
,
err
=
os
.
Stat
(
pluginPath
)
if
err
!=
nil
{
if
os
.
IsNotExist
(
err
)
{
tool
.
Asset
(
fmt
.
Errorf
(
"plugin file `%s` is required"
,
pluginPath
))
}
tool
.
Asset
(
fmt
.
Errorf
(
"get plugin file state error: %w"
,
err
))
}
kernel
:=
plugin
.
NewClient
(
&
plugin
.
ClientConfig
{
HandshakeConfig
:
Handshake
,
Plugins
:
PluginMap
,
...
...
@@ -86,27 +95,21 @@ func CreateClients(appchainConfigs repo.Appchains, extra []byte) []Client {
})
// Connect via RPC
rpcClient
,
err
:=
kernel
.
Client
()
if
err
!=
nil
{
panic
(
err
)
}
tool
.
Asset
(
err
)
// Request the plugin
raw
,
err
:=
rpcClient
.
Dispense
(
PluginName
)
if
err
!=
nil
{
panic
(
err
)
}
raw
,
err
:=
rpcClient
.
Dispense
(
appchainConfig
.
Plugin
)
tool
.
Asset
(
err
)
var
appchain
Client
switch
raw
.
(
type
)
{
case
*
GRPCClient
:
appchain
=
raw
.
(
*
GRPCClient
)
default
:
panic
(
fmt
.
Errorf
(
"unsupported kernel type"
))
tool
.
Asset
(
fmt
.
Errorf
(
"unsupported kernel type"
))
}
// initialize our kernel plugin
err
=
appchain
.
Initialize
(
pluginConfigPath
,
appchainConfig
.
DID
,
extra
)
if
err
!=
nil
{
panic
(
err
)
}
tool
.
Asset
(
err
)
appchain
.
Bind
(
kernel
)
clients
=
append
(
clients
,
appchain
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment