@@ -18,7 +18,6 @@ package ccvm
18
18
19
19
import (
20
20
"context"
21
- "errors"
22
21
"flag"
23
22
"fmt"
24
23
"os"
@@ -98,7 +97,8 @@ func (d *drives) Set(value string) error {
98
97
return nil
99
98
}
100
99
101
- func vmFlags (fs * flag.FlagSet , customSpec * VMSpec ) {
100
+ // VMFlags provides common flags for customising a workload
101
+ func VMFlags (fs * flag.FlagSet , customSpec * VMSpec ) {
102
102
fs .IntVar (& customSpec .MemGiB , "mem" , customSpec .MemGiB , "Gigabytes of RAM allocated to VM" )
103
103
fs .IntVar (& customSpec .CPUs , "cpus" , customSpec .CPUs , "VCPUs assigned to VM" )
104
104
fs .Var (& customSpec .Mounts , "mount" , "directory to mount in guest VM via 9p. Format is tag,security_model,path" )
@@ -128,48 +128,6 @@ func checkDirectory(dir string) error {
128
128
return nil
129
129
}
130
130
131
- // CreateFlags parses the flags to the create command
132
- func CreateFlags () (string , bool , bool , VMSpec , error ) {
133
- var debug bool
134
- var update bool
135
- var customSpec VMSpec
136
- fs := flag .NewFlagSet ("create" , flag .ExitOnError )
137
- fs .Usage = func () {
138
- fmt .Fprintf (os .Stderr , "Usage: %s create <workload> \n \n " , os .Args [0 ])
139
- fmt .Fprintf (os .Stderr , " <workload>\t Name of the workload to create\n \n " )
140
- fs .PrintDefaults ()
141
- }
142
- vmFlags (fs , & customSpec )
143
- fs .BoolVar (& debug , "debug" , false , "Enables debug mode" )
144
- fs .BoolVar (& update , "package-upgrade" , false ,
145
- "Hint to enable or disable update of VM packages. Should be true or false" )
146
-
147
- if err := fs .Parse (flag .Args ()[1 :]); err != nil {
148
- return "" , debug , update , customSpec , err
149
- }
150
-
151
- if fs .NArg () != 1 {
152
- fs .Usage ()
153
- return "" , debug , update , customSpec , errors .New ("no workload specified" )
154
- }
155
- workloadName := fs .Arg (0 )
156
-
157
- return workloadName , debug , update , customSpec , nil
158
- }
159
-
160
- // StartFlags parsed the flags for the start command
161
- func StartFlags () (VMSpec , error ) {
162
- var customSpec VMSpec
163
-
164
- fs := flag .NewFlagSet ("start" , flag .ExitOnError )
165
- vmFlags (fs , & customSpec )
166
- if err := fs .Parse (flag .Args ()[1 :]); err != nil {
167
- return customSpec , err
168
- }
169
-
170
- return customSpec , nil
171
- }
172
-
173
131
func prepareCreate (ctx context.Context , workloadName string , debug bool , update bool , customSpec * VMSpec ) (* workload , * workspace , error ) {
174
132
ws , err := prepareEnv (ctx )
175
133
if err != nil {
0 commit comments