cli: unify terraform variable creation (#2119)

Before we defined the variables twice.
Once for upgrades, once for create.
Also move default node group names into a constant
This commit is contained in:
Otto Bittner 2023-07-21 10:04:29 +02:00 committed by GitHub
parent f9391ed903
commit cf822f7eee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 464 additions and 451 deletions

View file

@ -18,6 +18,7 @@ go_library(
importpath = "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/internal/cloud/azure/client",
visibility = ["//operators/constellation-node-operator:__subpackages__"],
deps = [
"//internal/constants",
"//operators/constellation-node-operator/api/v1alpha1",
"//operators/constellation-node-operator/internal/cloud/api",
"//operators/constellation-node-operator/internal/poller",
@ -44,6 +45,7 @@ go_test(
],
embed = [":client"],
deps = [
"//internal/constants",
"//operators/constellation-node-operator/api/v1alpha1",
"//operators/constellation-node-operator/internal/cloud/api",
"//operators/constellation-node-operator/internal/poller",

View file

@ -13,6 +13,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4"
"github.com/edgelesssys/constellation/v2/internal/constants"
updatev1alpha1 "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/api/v1alpha1"
cspapi "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/internal/cloud/api"
)
@ -117,9 +118,9 @@ func (c *Client) ListScalingGroups(ctx context.Context, uid string) ([]cspapi.Sc
if nodeGroupName == "" {
switch role {
case updatev1alpha1.ControlPlaneRole:
nodeGroupName = "control_plane_default"
nodeGroupName = constants.ControlPlaneDefault
case updatev1alpha1.WorkerRole:
nodeGroupName = "worker_default"
nodeGroupName = constants.WorkerDefault
}
}

View file

@ -13,6 +13,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v4"
"github.com/edgelesssys/constellation/v2/internal/constants"
cspapi "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/internal/cloud/api"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -202,7 +203,7 @@ func TestListScalingGroups(t *testing.T) {
wantGroups: []cspapi.ScalingGroup{
{
Name: "constellation-scale-set-control-planes-uid",
NodeGroupName: "control_plane_default",
NodeGroupName: constants.ControlPlaneDefault,
GroupID: "/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/constellation-scale-set-control-planes-uid",
AutoscalingGroupName: "constellation-scale-set-control-planes-uid",
Role: "ControlPlane",
@ -221,7 +222,7 @@ func TestListScalingGroups(t *testing.T) {
wantGroups: []cspapi.ScalingGroup{
{
Name: "constellation-scale-set-workers-uid",
NodeGroupName: "worker_default",
NodeGroupName: constants.WorkerDefault,
GroupID: "/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/constellation-scale-set-workers-uid",
AutoscalingGroupName: "constellation-scale-set-workers-uid",
Role: "Worker",
@ -240,7 +241,7 @@ func TestListScalingGroups(t *testing.T) {
wantGroups: []cspapi.ScalingGroup{
{
Name: "some-scale-set",
NodeGroupName: "control_plane_default",
NodeGroupName: constants.ControlPlaneDefault,
GroupID: "/subscriptions/subscription-id/resourceGroups/resource-group/providers/Microsoft.Compute/virtualMachineScaleSets/some-scale-set",
AutoscalingGroupName: "some-scale-set",
Role: "ControlPlane",