-
Notifications
You must be signed in to change notification settings - Fork 287
/
controlplane_nodes.go
36 lines (29 loc) · 1.25 KB
/
controlplane_nodes.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
package framework
import (
"context"
corev1 "k8s.io/api/core/v1"
"github.com/aws/eks-anywhere/pkg/api/v1alpha1"
)
// ControlPlaneNodeValidation should return an error if either an error is encountered during execution or the validation logically fails.
// This validation function will be executed by ValidateControlPlaneNodes with a Control Plane configuration and a corresponding node
// which was created as a part of that configuration.
type ControlPlaneNodeValidation func(configuration v1alpha1.ControlPlaneConfiguration, node corev1.Node) (err error)
// ValidateControlPlaneNodes deduces the control plane configuration to node mapping
// and for each configuration/node pair executes the provided validation functions.
func (e *ClusterE2ETest) ValidateControlPlaneNodes(validations ...ControlPlaneNodeValidation) {
ctx := context.Background()
c := e.ClusterConfig.Cluster
cpNodes, err := e.KubectlClient.GetControlPlaneNodes(ctx, e.Cluster().KubeconfigFile)
if err != nil {
e.T.Fatal(err)
}
for _, node := range cpNodes {
for _, validation := range validations {
err = validation(c.Spec.ControlPlaneConfiguration, node)
if err != nil {
e.T.Errorf("Control plane node %v is not valid: %v", node.Name, err)
}
}
}
e.StopIfFailed()
}