mirror of
				https://github.com/edgelesssys/constellation.git
				synced 2025-10-31 03:39:04 -04:00 
			
		
		
		
	operator: move control plane label to constants
This commit is contained in:
		
							parent
							
								
									ebee6b3398
								
							
						
					
					
						commit
						3ddd6389e3
					
				
					 9 changed files with 15 additions and 6 deletions
				
			
		|  | @ -81,6 +81,7 @@ go_test( | |||
|         "//3rdparty/node-maintenance-operator/api/v1beta1", | ||||
|         "//internal/constants", | ||||
|         "//operators/constellation-node-operator/api/v1alpha1", | ||||
|         "//operators/constellation-node-operator/internal/constants", | ||||
|         "@com_github_onsi_ginkgo_v2//:ginkgo", | ||||
|         "@com_github_onsi_gomega//:gomega", | ||||
|         "@com_github_stretchr_testify//assert", | ||||
|  |  | |||
|  | @ -19,4 +19,6 @@ const ( | |||
| 	PlaceholderControlPlaneScalingGroupName = "control-planes-id" | ||||
| 	// PlaceholderWorkerScalingGroupName name of the worker scaling group used if upgrades are not yet supported. | ||||
| 	PlaceholderWorkerScalingGroupName = "workers-id" | ||||
| 	// ControlPlaneRoleLabel label used to identify control plane nodes. | ||||
| 	ControlPlaneRoleLabel = "node-role.kubernetes.io/control-plane" | ||||
| ) | ||||
|  |  | |||
|  | @ -18,6 +18,7 @@ go_test( | |||
|     srcs = ["controlplane_test.go"], | ||||
|     embed = [":controlplane"], | ||||
|     deps = [ | ||||
|         "//operators/constellation-node-operator/internal/constants", | ||||
|         "@com_github_stretchr_testify//assert", | ||||
|         "@com_github_stretchr_testify//require", | ||||
|         "@io_k8s_api//core/v1:core", | ||||
|  |  | |||
|  | @ -11,6 +11,7 @@ import ( | |||
| 	"errors" | ||||
| 	"testing" | ||||
| 
 | ||||
| 	"github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/internal/constants" | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| 	corev1 "k8s.io/api/core/v1" | ||||
|  | @ -29,7 +30,7 @@ func TestListControlPlaneIPs(t *testing.T) { | |||
| 			nodes: []corev1.Node{ | ||||
| 				{ | ||||
| 					ObjectMeta: metav1.ObjectMeta{ | ||||
| 						Labels: map[string]string{"node-role.kubernetes.io/control-plane": ""}, | ||||
| 						Labels: map[string]string{constants.ControlPlaneRoleLabel: ""}, | ||||
| 					}, | ||||
| 					Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{ | ||||
| 						Type:    corev1.NodeInternalIP, | ||||
|  |  | |||
|  | @ -19,6 +19,7 @@ go_test( | |||
|     srcs = ["etcd_test.go"], | ||||
|     embed = [":etcd"], | ||||
|     deps = [ | ||||
|         "//operators/constellation-node-operator/internal/constants", | ||||
|         "@com_github_stretchr_testify//assert", | ||||
|         "@com_github_stretchr_testify//require", | ||||
|         "@io_etcd_go_etcd_api_v3//etcdserverpb", | ||||
|  |  | |||
|  | @ -11,6 +11,7 @@ import ( | |||
| 	"errors" | ||||
| 	"testing" | ||||
| 
 | ||||
| 	"github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/internal/constants" | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| 	pb "go.etcd.io/etcd/api/v3/etcdserverpb" | ||||
|  | @ -124,7 +125,7 @@ func TestGetInitialEndpoints(t *testing.T) { | |||
| 			nodes: []corev1.Node{ | ||||
| 				{ | ||||
| 					ObjectMeta: metav1.ObjectMeta{ | ||||
| 						Labels: map[string]string{"node-role.kubernetes.io/control-plane": ""}, | ||||
| 						Labels: map[string]string{constants.ControlPlaneRoleLabel: ""}, | ||||
| 					}, | ||||
| 					Status: corev1.NodeStatus{Addresses: []corev1.NodeAddress{{ | ||||
| 						Type:    corev1.NodeInternalIP, | ||||
|  |  | |||
|  | @ -8,6 +8,7 @@ go_library( | |||
|     visibility = ["//operators/constellation-node-operator:__subpackages__"], | ||||
|     deps = [ | ||||
|         "//operators/constellation-node-operator/api/v1alpha1", | ||||
|         "//operators/constellation-node-operator/internal/constants", | ||||
|         "@io_k8s_api//core/v1:core", | ||||
|     ], | ||||
| ) | ||||
|  | @ -18,6 +19,7 @@ go_test( | |||
|     embed = [":node"], | ||||
|     deps = [ | ||||
|         "//operators/constellation-node-operator/api/v1alpha1", | ||||
|         "//operators/constellation-node-operator/internal/constants", | ||||
|         "@com_github_stretchr_testify//assert", | ||||
|         "@com_github_stretchr_testify//require", | ||||
|         "@io_k8s_api//core/v1:core", | ||||
|  |  | |||
|  | @ -11,11 +11,10 @@ import ( | |||
| 	"regexp" | ||||
| 
 | ||||
| 	updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/api/v1alpha1" | ||||
| 	"github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/internal/constants" | ||||
| 	corev1 "k8s.io/api/core/v1" | ||||
| ) | ||||
| 
 | ||||
| const controlPlaneRoleLabel = "node-role.kubernetes.io/control-plane" | ||||
| 
 | ||||
| var reservedHostRegex = regexp.MustCompile(`^(.+\.|)(kubernetes|k8s)\.io(/.*)?$`) | ||||
| 
 | ||||
| // Ready checks if a kubernetes node has the `NodeReady` condition set to true. | ||||
|  | @ -40,7 +39,7 @@ func VPCIP(node *corev1.Node) (string, error) { | |||
| 
 | ||||
| // IsControlPlaneNode returns true if the node is a control plane node. | ||||
| func IsControlPlaneNode(node *corev1.Node) bool { | ||||
| 	_, ok := node.Labels[controlPlaneRoleLabel] | ||||
| 	_, ok := node.Labels[constants.ControlPlaneRoleLabel] | ||||
| 	return ok | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -10,6 +10,7 @@ import ( | |||
| 	"testing" | ||||
| 
 | ||||
| 	updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/api/v1alpha1" | ||||
| 	"github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/internal/constants" | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| 	"github.com/stretchr/testify/require" | ||||
| 	corev1 "k8s.io/api/core/v1" | ||||
|  | @ -69,7 +70,7 @@ func TestIsControlPlaneNode(t *testing.T) { | |||
| 		"node with control-plane role label": { | ||||
| 			node: corev1.Node{ | ||||
| 				ObjectMeta: metav1.ObjectMeta{ | ||||
| 					Labels: map[string]string{controlPlaneRoleLabel: ""}, | ||||
| 					Labels: map[string]string{constants.ControlPlaneRoleLabel: ""}, | ||||
| 				}, | ||||
| 			}, | ||||
| 			wantControlPlane: true, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Leonard Cohnen
						Leonard Cohnen