/
parser.go
33 lines (28 loc) · 901 Bytes
/
parser.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
// Package parser is the package responsible for parsing test cases and istio configuration
// to be use on test assertionpackage parser
package parser
import (
"fmt"
v1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3"
)
// Parser contains the parsed files needed to run tests
type Parser struct {
TestCases []*TestCase
VirtualServices []*v1alpha3.VirtualService
}
// New parses and loads the testcases and istio configuration files
func New(testfiles, configfiles []string) (*Parser, error) {
testCases, err := parseTestCases(testfiles)
if err != nil {
return nil, fmt.Errorf("parsing testcases failed: %w", err)
}
virtualServices, err := parseVirtualServices(configfiles)
if err != nil {
return nil, fmt.Errorf("parsing virtualservices failed: %w", err)
}
parser := &Parser{
TestCases: testCases,
VirtualServices: virtualServices,
}
return parser, nil
}