Skip to content

Commit 3dbeece

Browse files
fix: image name parsing (runfinch#1386)
Signed-off-by: Shubharanshu Mahapatra <[email protected]>
1 parent 169b84f commit 3dbeece

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

cmd/finch/nerdctl_darwin_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,33 @@ func TestNerdctlCommand_run(t *testing.T) {
12041204
c.EXPECT().Run()
12051205
},
12061206
},
1207+
{
1208+
name: "with single letter entry in args",
1209+
cmdName: "run",
1210+
fc: &config.Finch{},
1211+
args: []string{"-i", "--name", "myContainer", "--rm", "a", "env"},
1212+
wantErr: nil,
1213+
mockSvc: func(
1214+
_ *testing.T,
1215+
lcc *mocks.NerdctlCmdCreator,
1216+
_ *mocks.CommandCreator,
1217+
ncsd *mocks.NerdctlCommandSystemDeps,
1218+
logger *mocks.Logger,
1219+
ctrl *gomock.Controller,
1220+
_ afero.Fs,
1221+
) {
1222+
getVMStatusC := mocks.NewCommand(ctrl)
1223+
lcc.EXPECT().CreateWithoutStdio("ls", "-f", "{{.Status}}", limaInstanceName).Return(getVMStatusC)
1224+
getVMStatusC.EXPECT().Output().Return([]byte("Running"), nil)
1225+
logger.EXPECT().Debugf("Status of virtual machine: %s", "Running")
1226+
AddEmptyEnvLookUps(ncsd)
1227+
c := mocks.NewCommand(ctrl)
1228+
lcc.EXPECT().
1229+
Create("shell", limaInstanceName, "sudo", "-E", nerdctlCmdName, "container", "run",
1230+
"-i", "--name", "myContainer", "--rm", "a", "env").Return(c)
1231+
c.EXPECT().Run()
1232+
},
1233+
},
12071234
}
12081235

12091236
for _, tc := range testCases {

cmd/finch/nerdctl_remote.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ func (nc *nerdctlCommand) run(cmdName string, args []string) error {
199199
// begins with --<long_flag>
200200
// e.g. --sig-proxy=false
201201
nerdctlArgs = append(nerdctlArgs, arg)
202-
case shortFlagBoolSet.Has(arg[:2]):
202+
case len(arg) > 1 && shortFlagBoolSet.Has(arg[:2]):
203203
// or begins with a defined short no argument flag, but is adjacent to something
204204
// -???? one or more short bool flags; no following values
205205
// -????="<value>" one or more short bool flags ending with a short arg flag equated to value
206206
// -????"<value>" one or more short bool flags ending with a short arg flag concatenated to value
207207
addArg := nc.handleMultipleShortFlags(shortFlagBoolSet, shortFlagArgSet, args, i)
208208
nerdctlArgs = append(nerdctlArgs, addArg)
209-
case shortFlagArgSet.Has(arg) || shortFlagArgSet.Has(arg[:2]):
209+
case shortFlagArgSet.Has(arg) || (len(arg) > 1 && shortFlagArgSet.Has(arg[:2])):
210210
// exact match to a short arg flag: -?
211211
// next arg must be the <value>
212212
// or begins with a short arg flag:

0 commit comments

Comments
 (0)