File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 99 "fmt"
1010 "os"
1111 "os/exec"
12+ "path/filepath"
1213 "regexp"
1314 "strings"
1415)
@@ -141,7 +142,8 @@ func (o *Option) Subject() []string {
141142
142143// GetNerdctlVersion gets the nerdctl version from the subject. If the subject is neither "nerdctl" nor "finch", it will return an error.
143144func (o * Option ) GetNerdctlVersion () (string , error ) {
144- switch o .subject [0 ] {
145+ execName := filepath .Base (o .subject [0 ])
146+ switch execName {
145147 case "nerdctl" :
146148 //nolint:gosec // G204 is not an issue because subject is fully controlled by the user.
147149 versionBytes , err := exec .Command (o .subject [0 ], "--version" ).Output ()
@@ -165,7 +167,7 @@ func (o *Option) GetNerdctlVersion() (string, error) {
165167 }
166168 return version , nil
167169 default :
168- return "" , fmt .Errorf ("unsupported subject %s" , o . subject [ 0 ] )
170+ return "" , fmt .Errorf ("unsupported subject %s" , execName )
169171 }
170172}
171173
You can’t perform that action at this time.
0 commit comments