Skip to content

Commit

Permalink
Merge pull request containerd#42 from Iceber/plugin_name
Browse files Browse the repository at this point in the history
fix the `NRI_PLUGIN_NAME` env value when launching a pre-installed plugin
  • Loading branch information
mikebrow committed May 23, 2023
2 parents 4ba54cc + 4a4cea6 commit f9e231f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/adaptation/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (r *Adaptation) newLaunchedPlugin(dir, idx, base, cfg string) (p *plugin, r
cmd := exec.Command(filepath.Join(dir, name))
cmd.ExtraFiles = []*os.File{peerFile}
cmd.Env = []string{
api.PluginNameEnvVar + "=" + name,
api.PluginNameEnvVar + "=" + base,
api.PluginIdxEnvVar + "=" + idx,
api.PluginSocketEnvVar + "=3",
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/stub/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func New(p interface{}, opts ...Option) (Stub, error) {
return nil, err
}

if err := stub.getIdentity(); err != nil {
if err := stub.ensureIdentity(); err != nil {
return nil, err
}

Expand Down Expand Up @@ -678,8 +678,8 @@ func (stub *stub) StateChange(ctx context.Context, evt *api.StateChangeEvent) (*
return &api.StateChangeResponse{}, err
}

// getIdentity gets plugin index and name from the binary if those are unset.
func (stub *stub) getIdentity() error {
// ensureIdentity sets plugin index and name from the binary if those are unset.
func (stub *stub) ensureIdentity() error {
if stub.idx != "" && stub.name != "" {
return nil
}
Expand Down

0 comments on commit f9e231f

Please sign in to comment.