@@ -2,7 +2,6 @@ package cmd
22
33import (
44 "fmt"
5- "net"
65 "runtime"
76 "strings"
87
@@ -16,7 +15,7 @@ import (
1615
1716// startCmd represents the start command
1817var startCmd = & cobra.Command {
19- Use : "start" ,
18+ Use : "start [profile] " ,
2019 Short : "start Colima" ,
2120 Long : `Start Colima with the specified container runtime (and kubernetes if --with-kubernetes is passed).
2221The --runtime, --disk and --arch flags are only used on initial start and ignored on subsequent starts.
@@ -28,14 +27,11 @@ The --runtime, --disk and --arch flags are only used on initial start and ignore
2827 " colima start --cpu 4 --memory 8 --disk 100\n " +
2928 " colima start --arch aarch64\n " +
3029 " colima start --dns 1.1.1.1 --dns 8.8.8.8" ,
31- Args : cobra .NoArgs ,
30+ Args : cobra .MaximumNArgs ( 1 ) ,
3231 RunE : func (cmd * cobra.Command , args []string ) error {
3332 return newApp ().Start (startCmdArgs .Config )
3433 },
3534 PreRunE : func (cmd * cobra.Command , args []string ) error {
36- // set port
37- startCmdArgs .VM .SSHPort = randomAvailablePort ()
38-
3935 current , err := config .Load ()
4036 if err != nil {
4137 // not fatal, will proceed with defaults
@@ -69,9 +65,6 @@ The --runtime, --disk and --arch flags are only used on initial start and ignore
6965 if ! cmd .Flag ("mount" ).Changed {
7066 startCmdArgs .VM .Mounts = current .VM .Mounts
7167 }
72- if ! cmd .Flag ("port-interface" ).Changed {
73- startCmdArgs .PortInterface = current .PortInterface
74- }
7568 if ! cmd .Flag ("ssh-agent" ).Changed {
7669 startCmdArgs .VM .ForwardAgent = current .VM .ForwardAgent
7770 }
@@ -100,23 +93,9 @@ var startCmdArgs struct {
10093 config.Config
10194}
10295
103- func randomAvailablePort () int {
104- listener , err := net .Listen ("tcp" , ":0" )
105- if err != nil {
106- log .Fatal (fmt .Errorf ("error picking an available port: %w" , err ))
107- }
108-
109- if err := listener .Close (); err != nil {
110- log .Fatal (fmt .Errorf ("error closing temporary port listener: %w" , err ))
111- }
112-
113- return listener .Addr ().(* net.TCPAddr ).Port
114- }
115-
11696func init () {
11797 runtimes := strings .Join (environment .ContainerRuntimes (), ", " )
11898 defaultArch := string (environment .Arch (runtime .GOARCH ).Value ())
119- defaultPortInterface := net .ParseIP ("0.0.0.0" )
12099
121100 root .Cmd ().AddCommand (startCmd )
122101 startCmd .Flags ().StringVarP (& startCmdArgs .Runtime , "runtime" , "r" , docker .Name , "container runtime (" + runtimes + ")" )
@@ -128,9 +107,6 @@ func init() {
128107 // mounts
129108 startCmd .Flags ().StringSliceVarP (& startCmdArgs .VM .Mounts , "mount" , "v" , nil , "directories to mount, suffix ':w' for writable" )
130109
131- // port forwarding
132- startCmd .Flags ().IPVarP (& startCmdArgs .PortInterface , "port-interface" , "i" , defaultPortInterface , "interface to use for forwarded ports" )
133-
134110 // ssh agent
135111 startCmd .Flags ().BoolVarP (& startCmdArgs .VM .ForwardAgent , "ssh-agent" , "s" , false , "forward SSH agent to the VM" )
136112
0 commit comments