mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -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
|
@ -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