1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
10
"github.com/juju/errors"
12
"github.com/juju/juju/storage"
15
type storageFlag struct {
16
stores *map[string]storage.Constraints
19
// Set implements gnuflag.Value.Set.
20
func (f storageFlag) Set(s string) error {
21
fields := strings.SplitN(s, "=", 2)
23
return errors.New("expected <store>=<constraints>")
25
cons, err := storage.ParseConstraints(fields[1])
27
return errors.Annotate(err, "cannot parse disk constraints")
30
*f.stores = make(map[string]storage.Constraints)
32
(*f.stores)[fields[0]] = cons
36
// Set implements gnuflag.Value.String.
37
func (f storageFlag) String() string {
38
strs := make([]string, 0, len(*f.stores))
39
for store, cons := range *f.stores {
40
strs = append(strs, fmt.Sprintf("%s=%v", store, cons))
42
return strings.Join(strs, " ")