-
Notifications
You must be signed in to change notification settings - Fork 70
/
version.go
43 lines (35 loc) · 1.16 KB
/
version.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
package cli
import (
"fmt"
"log"
"regexp"
"github.com/skupperproject/skupper/api/types"
"github.com/skupperproject/skupper/test/utils/base"
)
// VersionTester runs `skupper version` and validates its output
type VersionTester struct{}
func (v *VersionTester) Command(platform types.Platform, cluster *base.ClusterContext) []string {
args := SkupperCommonOptions(platform, cluster)
args = append(args, "version")
return args
}
func (v *VersionTester) Run(platform types.Platform, cluster *base.ClusterContext) (stdout string, stderr string, err error) {
// Execute version command
stdout, stderr, err = RunSkupperCli(v.Command(platform, cluster))
if err != nil {
return
}
// Validate the version for all the components is displayed
log.Printf("Validating 'skupper version'")
components := []string{"client", "transport"}
if platform.IsKubernetes() {
components = append(components, "controller")
}
for _, component := range components {
regex := regexp.MustCompile(fmt.Sprintf(`%s version .* \S`, component))
if !regex.MatchString(stdout) {
err = fmt.Errorf("missing expected content - regex: %s - stdout: %s", regex.String(), stdout)
}
}
return
}