From 0d43d4cf878fd80a920237294ea334a7c0f480f9 Mon Sep 17 00:00:00 2001 From: Phillip Stagnet Date: Tue, 20 Feb 2024 19:21:31 +0100 Subject: [PATCH] Allow cluster creation without only project id --- metakube/resource_cluster.go | 12 +----------- metakube/resource_node_deployment.go | 1 + 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/metakube/resource_cluster.go b/metakube/resource_cluster.go index 1402d6d..f9459de 100644 --- a/metakube/resource_cluster.go +++ b/metakube/resource_cluster.go @@ -143,22 +143,12 @@ func metakubeResourceClusterCreate(ctx context.Context, d *schema.ResourceData, dcname := d.Get("dc_name").(string) clusterSpec := metakubeResourceClusterExpandSpec(spec, dcname, func(_ string) bool { return true }) clusterLabels := metakubeResourceClusterLabels(d) - resourceProject, err := getProject(meta, d.Get("project_id").(string)) - if err != nil { - return diag.FromErr(err) - } - if key := mapFirstContains(clusterLabels, resourceProject.Labels); key != "" { - return diag.Diagnostics{{ - Summary: fmt.Sprintf("The label '%s' used by project and cannot be used here", key), - AttributePath: cty.GetAttrPath("labels"), - }} - } createClusterSpec := &models.CreateClusterSpec{ Cluster: &models.Cluster{ Name: d.Get("name").(string), Spec: clusterSpec, Type: "kubernetes", - Labels: mapExclude(clusterLabels, resourceProject.Labels), + Labels: clusterLabels, }, } if n := clusterSpec.ClusterNetwork; n != nil { diff --git a/metakube/resource_node_deployment.go b/metakube/resource_node_deployment.go index 9044232..34eeb1f 100644 --- a/metakube/resource_node_deployment.go +++ b/metakube/resource_node_deployment.go @@ -41,6 +41,7 @@ func metakubeResourceNodeDeployment() *schema.Resource { "project_id": { Type: schema.TypeString, Computed: true, + Optional: true, Description: "Project the cluster belongs to", },