forked from openshift/oc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
56 lines (48 loc) · 909 Bytes
/
types.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package newapp
import (
"fmt"
"strings"
"k8s.io/klog"
)
type Tester interface {
Has(dir string) (string, bool, error)
}
type Strategy int
const (
StrategyUnspecified Strategy = iota
StrategySource
StrategyDocker
StrategyPipeline
)
func (s Strategy) String() string {
switch s {
case StrategyUnspecified:
return ""
case StrategySource:
return "source"
case StrategyDocker:
return "Docker"
case StrategyPipeline:
return "pipeline"
}
klog.Error("unknown strategy")
return ""
}
func (s Strategy) Type() string {
return "strategy"
}
func (s *Strategy) Set(str string) error {
switch strings.ToLower(str) {
case "":
*s = StrategyUnspecified
case "docker":
*s = StrategyDocker
case "pipeline":
*s = StrategyPipeline
case "source":
*s = StrategySource
default:
return fmt.Errorf("invalid strategy: %s. Must be 'docker', 'pipeline' or 'source'.", str)
}
return nil
}