Skip to content

Commit

Permalink
allow optional udp to be set via cli flag instead of just config on r…
Browse files Browse the repository at this point in the history
…un/pkg-load (#1668)
  • Loading branch information
eyberg authored Dec 1, 2024
1 parent 0453c99 commit 788a6d6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/flags_run_local_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type RunLocalInstanceCommandFlags struct {
MissingFiles bool
NoTrace []string
Ports []string
UDPPorts []string
SkipBuild bool
Memory string
Smp int
Expand Down Expand Up @@ -145,6 +146,10 @@ func (flags *RunLocalInstanceCommandFlags) MergeToConfig(c *types.Config) error

}

if len(flags.UDPPorts) != 0 {
c.RunConfig.UDPPorts = append(c.RunConfig.UDPPorts, flags.UDPPorts...)
}

for _, port := range flags.Ports {
conn, err := net.DialTimeout("tcp", ":"+port, time.Second)
if err != nil {
Expand Down Expand Up @@ -216,6 +221,11 @@ func NewRunLocalInstanceCommandFlags(cmdFlags *pflag.FlagSet) (flags *RunLocalIn
exitWithError(err.Error())
}

flags.UDPPorts, err = cmdFlags.GetStringArray("udp")
if err != nil {
exitWithError(err.Error())
}

flags.SkipBuild, err = cmdFlags.GetBool("skipbuild")
if err != nil {
exitWithError(err.Error())
Expand Down Expand Up @@ -267,6 +277,7 @@ func NewRunLocalInstanceCommandFlags(cmdFlags *pflag.FlagSet) (flags *RunLocalIn
// PersistRunLocalInstanceCommandFlags append a command the required flags to run an image
func PersistRunLocalInstanceCommandFlags(cmdFlags *pflag.FlagSet) {
cmdFlags.StringArrayP("port", "p", nil, "port to forward")
cmdFlags.StringArrayP("udp", "", nil, "udp ports to forward")
cmdFlags.BoolP("force", "f", false, "update images")
cmdFlags.BoolP("debug", "d", false, "enable interactive debugger")
cmdFlags.BoolP("trace", "", false, "enable required flags to trace")
Expand Down

0 comments on commit 788a6d6

Please sign in to comment.