Skip to content

Commit

Permalink
Fix ci failures
Browse files Browse the repository at this point in the history
Signed-off-by: Parthvi Vala <[email protected]>
  • Loading branch information
valaparthvi committed Apr 3, 2023
1 parent 8b337ae commit 3cf0901
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pkg/odo/cli/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type DevOptions struct {
runCommandFlag string
ignoreLocalhostFlag bool
forwardLocalhostFlag bool
portForwardFlag []string
portForwardFlag []string
}

var _ genericclioptions.Runnable = (*DevOptions)(nil)
Expand Down Expand Up @@ -384,9 +384,10 @@ func parsePortForwardFlag(portForwardFlag []string) (forwardedPorts []api.Forwar
// acceptable examples: 8000:runtime_123:8080, 8000:9000, 8000:runtime:8080, 20001:20000
// unacceptable examples: :8000, 80000:
pattern := `^(\d{1,5})(:\w*)?:(\d{1,5})$`
portReg := regexp.MustCompile(pattern)
const largestPortValue = 65535
for _, portData := range portForwardFlag {
if matched, _ := regexp.MatchString(pattern, portData); !matched {
if !portReg.MatchString(portData) {
return nil, errors.New("ports are not defined properly, acceptable formats are: <localPort>:<containerPort>, <localPort>:<containerName>:<containerPort>")
}
var portF api.ForwardedPort
Expand Down
6 changes: 3 additions & 3 deletions tests/helper/helper_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func GetRandomFreePort(portRange ...int) string {
max := 65535
min := 1024
var (
startPort = rand.Intn(max-min) + min
startPort = rand.Intn(max-min) + min // #nosec // cannot use crypto/rand library here
endPort = max
)
// WARN: If length of portRange is anything other than 2 and first index is gte second index, it will be ignored
Expand All @@ -68,8 +68,8 @@ func GetRandomFreePort(portRange ...int) string {
}
freePort, err := util.NextFreePort(startPort, endPort, nil)
if err != nil {
Fail(fmt.Sprintf("failed to obtain a free port"))
Fail("failed to obtain a free port")
}
return strconv.Itoa(freePort)

}
}
1 change: 1 addition & 0 deletions tests/helper/helper_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func CmdRunner(program string, args ...string) *gexec.Session {
func WaitForOutputToContain(substring string, timeoutInSeconds int, intervalInSeconds int, session *gexec.Session) {

Eventually(func() string {
// TODO: if the session has exited, return early
contents := string(session.Out.Contents())
return contents
}, timeoutInSeconds, intervalInSeconds).Should(ContainSubstring(substring))
Expand Down

0 comments on commit 3cf0901

Please sign in to comment.