forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pool_slug.go
38 lines (29 loc) · 798 Bytes
/
pool_slug.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package director
import (
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type InstanceGroupSlug struct {
name string
}
func NewInstanceGroupSlug(name string) InstanceGroupSlug {
if len(name) == 0 {
panic("Expected non-empty pool name")
}
return InstanceGroupSlug{name: name}
}
func (s InstanceGroupSlug) Name() string { return s.name }
func (s InstanceGroupSlug) String() string { return s.name }
func (s *InstanceGroupSlug) UnmarshalFlag(data string) error {
slug, err := parseInstanceGroupSlug(data)
if err != nil {
return err
}
*s = slug
return nil
}
func parseInstanceGroupSlug(str string) (InstanceGroupSlug, error) {
if len(str) == 0 {
return InstanceGroupSlug{}, bosherr.Error("Expected non-empty pool name")
}
return InstanceGroupSlug{name: str}, nil
}