-
Notifications
You must be signed in to change notification settings - Fork 274
/
helm.go
62 lines (50 loc) · 1.24 KB
/
helm.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
57
58
59
60
61
62
package cmd
// This file contains functions that where blatantly copied from
// https://github.wdf.sap.corp/kubernetes/helm
import (
"errors"
"fmt"
"os"
"strings"
)
/////////////// Source: cmd/helm/install.go /////////////////////////
type valueFiles []string
func (v *valueFiles) String() string {
return fmt.Sprint(*v)
}
// Ensures all valuesFiles exist
func (v *valueFiles) Valid() error {
errStr := ""
for _, valuesFile := range *v {
if strings.TrimSpace(valuesFile) != "-" {
if _, err := os.Stat(valuesFile); os.IsNotExist(err) {
errStr += err.Error()
}
}
}
if errStr == "" {
return nil
}
return errors.New(errStr)
}
func (v *valueFiles) Type() string {
return "valueFiles"
}
func (v *valueFiles) Set(value string) error {
for _, filePath := range strings.Split(value, ",") {
*v = append(*v, filePath)
}
return nil
}
/////////////// Source: cmd/helm/helm.go ////////////////////////////
func checkArgsLength(argsReceived int, requiredArgs ...string) error {
expectedNum := len(requiredArgs)
if argsReceived != expectedNum {
arg := "arguments"
if expectedNum == 1 {
arg = "argument"
}
return fmt.Errorf("This command needs %v %s: %s", expectedNum, arg, strings.Join(requiredArgs, ", "))
}
return nil
}