mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 14:26:23 -04:00
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:
parent
f9391ed903
commit
cf822f7eee
19 changed files with 464 additions and 451 deletions
|
@ -14,6 +14,7 @@ go_library(
|
|||
importpath = "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/internal/cloud/aws/client",
|
||||
visibility = ["//operators/constellation-node-operator:__subpackages__"],
|
||||
deps = [
|
||||
"//internal/constants",
|
||||
"//operators/constellation-node-operator/api/v1alpha1",
|
||||
"//operators/constellation-node-operator/internal/cloud/api",
|
||||
"@com_github_aws_aws_sdk_go_v2_config//:config",
|
||||
|
@ -36,6 +37,7 @@ go_test(
|
|||
],
|
||||
embed = [":client"],
|
||||
deps = [
|
||||
"//internal/constants",
|
||||
"//operators/constellation-node-operator/api/v1alpha1",
|
||||
"//operators/constellation-node-operator/internal/cloud/api",
|
||||
"@com_github_aws_aws_sdk_go_v2_service_autoscaling//:autoscaling",
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
scalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
"github.com/aws/aws-sdk-go-v2/service/ec2"
|
||||
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
|
||||
"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"
|
||||
)
|
||||
|
@ -185,9 +186,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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import (
|
|||
scalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
"github.com/aws/aws-sdk-go-v2/service/ec2"
|
||||
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
|
||||
"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"
|
||||
|
@ -279,14 +280,14 @@ func TestListScalingGroups(t *testing.T) {
|
|||
wantGroups: []cspapi.ScalingGroup{
|
||||
{
|
||||
Name: "control-plane-asg",
|
||||
NodeGroupName: "control_plane_default",
|
||||
NodeGroupName: constants.ControlPlaneDefault,
|
||||
GroupID: "control-plane-asg",
|
||||
AutoscalingGroupName: "control-plane-asg",
|
||||
Role: "ControlPlane",
|
||||
},
|
||||
{
|
||||
Name: "worker-asg",
|
||||
NodeGroupName: "worker_default",
|
||||
NodeGroupName: constants.WorkerDefault,
|
||||
GroupID: "worker-asg",
|
||||
AutoscalingGroupName: "worker-asg",
|
||||
Role: "Worker",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -22,6 +22,7 @@ go_library(
|
|||
importpath = "github.com/edgelesssys/constellation/v2/operators/constellation-node-operator/v2/internal/cloud/gcp/client",
|
||||
visibility = ["//operators/constellation-node-operator:__subpackages__"],
|
||||
deps = [
|
||||
"//internal/constants",
|
||||
"//operators/constellation-node-operator/api/v1alpha1",
|
||||
"//operators/constellation-node-operator/internal/cloud/api",
|
||||
"@com_github_googleapis_gax_go_v2//:gax-go",
|
||||
|
@ -51,6 +52,7 @@ go_test(
|
|||
],
|
||||
embed = [":client"],
|
||||
deps = [
|
||||
"//internal/constants",
|
||||
"//operators/constellation-node-operator/api/v1alpha1",
|
||||
"//operators/constellation-node-operator/internal/cloud/api",
|
||||
"@com_github_googleapis_gax_go_v2//:gax-go",
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"cloud.google.com/go/compute/apiv1/computepb"
|
||||
"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"
|
||||
"google.golang.org/api/iterator"
|
||||
|
@ -164,9 +165,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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"cloud.google.com/go/compute/apiv1/computepb"
|
||||
"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"
|
||||
|
@ -356,7 +357,7 @@ func TestListScalingGroups(t *testing.T) {
|
|||
wantGroups: []cspapi.ScalingGroup{
|
||||
{
|
||||
Name: "test-control-plane-uid",
|
||||
NodeGroupName: "control_plane_default",
|
||||
NodeGroupName: constants.ControlPlaneDefault,
|
||||
GroupID: "projects/project/zones/zone/instanceGroupManagers/test-control-plane-uid",
|
||||
AutoscalingGroupName: "https://www.googleapis.com/compute/v1/projects/project/zones/zone/instanceGroups/test-control-plane-uid",
|
||||
Role: "ControlPlane",
|
||||
|
@ -374,7 +375,7 @@ func TestListScalingGroups(t *testing.T) {
|
|||
wantGroups: []cspapi.ScalingGroup{
|
||||
{
|
||||
Name: "test-worker-uid",
|
||||
NodeGroupName: "worker_default",
|
||||
NodeGroupName: constants.WorkerDefault,
|
||||
GroupID: "projects/project/zones/zone/instanceGroupManagers/test-worker-uid",
|
||||
AutoscalingGroupName: "https://www.googleapis.com/compute/v1/projects/project/zones/zone/instanceGroups/test-worker-uid",
|
||||
Role: "Worker",
|
||||
|
@ -411,7 +412,7 @@ func TestListScalingGroups(t *testing.T) {
|
|||
wantGroups: []cspapi.ScalingGroup{
|
||||
{
|
||||
Name: "some-instance-group-manager",
|
||||
NodeGroupName: "control_plane_default",
|
||||
NodeGroupName: constants.ControlPlaneDefault,
|
||||
GroupID: "projects/project/zones/zone/instanceGroupManagers/some-instance-group-manager",
|
||||
AutoscalingGroupName: "https://www.googleapis.com/compute/v1/projects/project/zones/zone/instanceGroups/some-instance-group-manager",
|
||||
Role: "ControlPlane",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue