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() {
...
@@ -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
...
@@ -2,6 +2,7 @@ package plugins
import
(
import
(
"fmt"
"fmt"
"os"
"os/exec"
"os/exec"
"path/filepath"
"path/filepath"
...
@@ -9,6 +10,7 @@ import (
...
@@ -9,6 +10,7 @@ import (
plugin
"github.com/hashicorp/go-plugin"
plugin
"github.com/hashicorp/go-plugin"
"github.com/link33/sidecar/internal/repo"
"github.com/link33/sidecar/internal/repo"
"github.com/link33/sidecar/tool"
)
)
var
logger
=
hclog
.
New
(
&
hclog
.
LoggerOptions
{
var
logger
=
hclog
.
New
(
&
hclog
.
LoggerOptions
{
...
@@ -43,7 +45,7 @@ func CreateClient(sidecarID string, appchainConfig repo.Appchain, extra []byte)
...
@@ -43,7 +45,7 @@ func CreateClient(sidecarID string, appchainConfig repo.Appchain, extra []byte)
}
}
// Request the plugin
// Request the plugin
raw
,
err
:=
rpcClient
.
Dispense
(
PluginName
)
raw
,
err
:=
rpcClient
.
Dispense
(
appchainConfig
.
Plugin
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
...
@@ -74,7 +76,14 @@ func CreateClients(appchainConfigs repo.Appchains, extra []byte) []Client {
...
@@ -74,7 +76,14 @@ func CreateClients(appchainConfigs repo.Appchains, extra []byte) []Client {
var
clients
[]
Client
var
clients
[]
Client
for
_
,
appchainConfig
:=
range
appchainConfigs
.
Appchains
{
for
_
,
appchainConfig
:=
range
appchainConfigs
.
Appchains
{
pluginConfigPath
:=
filepath
.
Join
(
rootPath
,
appchainConfig
.
Config
)
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
{
kernel
:=
plugin
.
NewClient
(
&
plugin
.
ClientConfig
{
HandshakeConfig
:
Handshake
,
HandshakeConfig
:
Handshake
,
Plugins
:
PluginMap
,
Plugins
:
PluginMap
,
...
@@ -86,27 +95,21 @@ func CreateClients(appchainConfigs repo.Appchains, extra []byte) []Client {
...
@@ -86,27 +95,21 @@ func CreateClients(appchainConfigs repo.Appchains, extra []byte) []Client {
})
})
// Connect via RPC
// Connect via RPC
rpcClient
,
err
:=
kernel
.
Client
()
rpcClient
,
err
:=
kernel
.
Client
()
if
err
!=
nil
{
tool
.
Asset
(
err
)
panic
(
err
)
}
// Request the plugin
// Request the plugin
raw
,
err
:=
rpcClient
.
Dispense
(
PluginName
)
raw
,
err
:=
rpcClient
.
Dispense
(
appchainConfig
.
Plugin
)
if
err
!=
nil
{
tool
.
Asset
(
err
)
panic
(
err
)
}
var
appchain
Client
var
appchain
Client
switch
raw
.
(
type
)
{
switch
raw
.
(
type
)
{
case
*
GRPCClient
:
case
*
GRPCClient
:
appchain
=
raw
.
(
*
GRPCClient
)
appchain
=
raw
.
(
*
GRPCClient
)
default
:
default
:
panic
(
fmt
.
Errorf
(
"unsupported kernel type"
))
tool
.
Asset
(
fmt
.
Errorf
(
"unsupported kernel type"
))
}
}
// initialize our kernel plugin
// initialize our kernel plugin
err
=
appchain
.
Initialize
(
pluginConfigPath
,
appchainConfig
.
DID
,
extra
)
err
=
appchain
.
Initialize
(
pluginConfigPath
,
appchainConfig
.
DID
,
extra
)
if
err
!=
nil
{
tool
.
Asset
(
err
)
panic
(
err
)
}
appchain
.
Bind
(
kernel
)
appchain
.
Bind
(
kernel
)
clients
=
append
(
clients
,
appchain
)
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