MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / Set

Method Set

src/cmd/linuxkit/util.go:215–243  ·  view source on GitHub ↗

Set is used by flag to configure value from CLI

(value string)

Source from the content-addressed store, hash-verified

213
214// Set is used by flag to configure value from CLI
215func (l *Disks) Set(value string) error {
216 d := DiskConfig{}
217 s := strings.Split(value, ",")
218 for _, p := range s {
219 c := strings.SplitN(p, "=", 2)
220 switch len(c) {
221 case 1:
222 // assume it is a filename even if no file=x
223 d.Path = c[0]
224 case 2:
225 switch c[0] {
226 case "file":
227 d.Path = c[1]
228 case "size":
229 size, err := getDiskSizeMB(c[1])
230 if err != nil {
231 return err
232 }
233 d.Size = size
234 case "format":
235 d.Format = c[1]
236 default:
237 return fmt.Errorf("unknown disk config: %s", c[0])
238 }
239 }
240 }
241 *l = append(*l, d)
242 return nil
243}
244
245// PublishedPort is used by some backends to expose a VMs port on the host
246type PublishedPort struct {

Callers 3

gcpGetFunction · 0.45
pkgPushCmdFunction · 0.45
testGetBoolPkgFunction · 0.45

Calls 1

getDiskSizeMBFunction · 0.85

Tested by 1

testGetBoolPkgFunction · 0.36