Skip to content

Commit 45f92ed

Browse files
authored
Merge pull request #194 from janog-netcon/add-exec-command-for-admin
Add execCommandForAdmin subcommand
2 parents f917aea + 66f0786 commit 45f92ed

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

cmd/access-helper/exec.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ func (h *ExecAccessHelper) access(
2222
ctx context.Context,
2323
nodeDefinition containerlab.NodeDefinition,
2424
containerDetails containerlab.ContainerDetails,
25-
_isAdmin bool,
25+
isAdmin bool,
2626
) error {
2727
execCommand := defaultExecCommand
28-
if v, ok := nodeDefinition.Labels[execCommandKey]; ok {
28+
if v, ok := nodeDefinition.Labels[execCommandForAdminKey]; ok && isAdmin {
29+
execCommand = v
30+
} else if v, ok := nodeDefinition.Labels[execCommandKey]; ok {
2931
execCommand = v
3032
}
3133

cmd/access-helper/labels.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const (
1212
// ref: https://uokada.hatenablog.jp/entry/2015/05/20/001208
1313
defaultSSHPassword string = "clab@123"
1414

15+
defaultSSHPort uint16 = 22
16+
17+
defaultExecCommand = "sh"
18+
1519
// AccessMethodKey is the label key to specify the access method.
1620
// The possible values are either "ssh" or "exec".
1721
// With "ssh", access-helper will try to connect to the Node via SSH.
@@ -40,11 +44,10 @@ const (
4044

4145
// sshPortKey is the label key to specify port number for SSH access.
4246
// The default value is defaultPort.
43-
sshPortKey = "netcon.janog.gr.jp/sshPort"
44-
defaultSSHPort uint16 = 22
47+
sshPortKey = "netcon.janog.gr.jp/sshPort"
4548

4649
// execCommandKey is the label key to specify command for exec access.
4750
// The default value is defaultExecCommand.
48-
execCommandKey = "netcon.janog.gr.jp/execCommand"
49-
defaultExecCommand = "sh"
51+
execCommandKey = "netcon.janog.gr.jp/execCommand"
52+
execCommandForAdminKey = "netcon.janog.gr.jp/execCommandForAdmin"
5053
)

0 commit comments

Comments
 (0)