@@ -2,7 +2,6 @@ package cmd
2
2
3
3
import (
4
4
"fmt"
5
- "net"
6
5
"runtime"
7
6
"strings"
8
7
@@ -16,7 +15,7 @@ import (
16
15
17
16
// startCmd represents the start command
18
17
var startCmd = & cobra.Command {
19
- Use : "start" ,
18
+ Use : "start [profile] " ,
20
19
Short : "start Colima" ,
21
20
Long : `Start Colima with the specified container runtime (and kubernetes if --with-kubernetes is passed).
22
21
The --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
28
27
" colima start --cpu 4 --memory 8 --disk 100\n " +
29
28
" colima start --arch aarch64\n " +
30
29
" colima start --dns 1.1.1.1 --dns 8.8.8.8" ,
31
- Args : cobra .NoArgs ,
30
+ Args : cobra .MaximumNArgs ( 1 ) ,
32
31
RunE : func (cmd * cobra.Command , args []string ) error {
33
32
return newApp ().Start (startCmdArgs .Config )
34
33
},
35
34
PreRunE : func (cmd * cobra.Command , args []string ) error {
36
- // set port
37
- startCmdArgs .VM .SSHPort = randomAvailablePort ()
38
-
39
35
current , err := config .Load ()
40
36
if err != nil {
41
37
// not fatal, will proceed with defaults
@@ -69,9 +65,6 @@ The --runtime, --disk and --arch flags are only used on initial start and ignore
69
65
if ! cmd .Flag ("mount" ).Changed {
70
66
startCmdArgs .VM .Mounts = current .VM .Mounts
71
67
}
72
- if ! cmd .Flag ("port-interface" ).Changed {
73
- startCmdArgs .PortInterface = current .PortInterface
74
- }
75
68
if ! cmd .Flag ("ssh-agent" ).Changed {
76
69
startCmdArgs .VM .ForwardAgent = current .VM .ForwardAgent
77
70
}
@@ -100,23 +93,9 @@ var startCmdArgs struct {
100
93
config.Config
101
94
}
102
95
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
-
116
96
func init () {
117
97
runtimes := strings .Join (environment .ContainerRuntimes (), ", " )
118
98
defaultArch := string (environment .Arch (runtime .GOARCH ).Value ())
119
- defaultPortInterface := net .ParseIP ("0.0.0.0" )
120
99
121
100
root .Cmd ().AddCommand (startCmd )
122
101
startCmd .Flags ().StringVarP (& startCmdArgs .Runtime , "runtime" , "r" , docker .Name , "container runtime (" + runtimes + ")" )
@@ -128,9 +107,6 @@ func init() {
128
107
// mounts
129
108
startCmd .Flags ().StringSliceVarP (& startCmdArgs .VM .Mounts , "mount" , "v" , nil , "directories to mount, suffix ':w' for writable" )
130
109
131
- // port forwarding
132
- startCmd .Flags ().IPVarP (& startCmdArgs .PortInterface , "port-interface" , "i" , defaultPortInterface , "interface to use for forwarded ports" )
133
-
134
110
// ssh agent
135
111
startCmd .Flags ().BoolVarP (& startCmdArgs .VM .ForwardAgent , "ssh-agent" , "s" , false , "forward SSH agent to the VM" )
136
112
0 commit comments