-
Notifications
You must be signed in to change notification settings - Fork 785
/
bdd_clusters.go
35 lines (30 loc) · 929 Bytes
/
bdd_clusters.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
package bdd
import (
"github.com/pkg/errors"
"sigs.k8s.io/yaml"
"io/ioutil"
)
// CreateClusters contains an array of clusters
type CreateClusters struct {
Clusters []*CreateCluster `json:"clusters,omitempty"`
}
// CreateCluster defines how to create a cluster
type CreateCluster struct {
Name string `json:"name,omitempty"`
Args []string `json:"args,omitempty"`
NoLabels bool `json:"noLabels,omitempty"`
Labels string `json:"labels,omitempty"`
}
// LoadBddClusters loads the cluster configuration from the given file
func LoadBddClusters(fileName string) (*CreateClusters, error) {
data, err := ioutil.ReadFile(fileName)
if err != nil {
return nil, errors.Wrapf(err, "failed to load file %s", fileName)
}
answer := &CreateClusters{}
err = yaml.Unmarshal(data, answer)
if err != nil {
return nil, errors.Wrapf(err, "failed to unmarshal YAML in file %s", fileName)
}
return answer, nil
}