-
Notifications
You must be signed in to change notification settings - Fork 0
/
requiredflags.go
41 lines (32 loc) · 904 Bytes
/
requiredflags.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
package main
import (
"errors"
"strings"
)
func checkRequiredFlags(configurationType string, image string, imageTag string, filePath string) error {
if filePath == "" {
err := `The "file-path" flag must be set`
return errors.New(err)
}
if image == "" && imageTag == "" {
err := `Either the "image" or "tag" flag MUST be passed in. Both cannot be empty`
return errors.New(err)
}
// Currently only deployments are supported
if configurationType != "" && configurationType != "deployment" {
err := `Only the "deployment" type is supported at this time`
return errors.New(err)
}
if image != "" {
tag := strings.Split(image, ":")
if len(tag) <= 1 {
err := `No tag was supplied in the image flag`
return errors.New(err)
}
}
if image != "" && imageTag != "" {
err := `Set either the "image" or "imageTag" flag, NOT both`
return errors.New(err)
}
return nil
}