Skip to content

Commit

Permalink
Allow cluster creation without only project id
Browse files Browse the repository at this point in the history
  • Loading branch information
phiphi282 authored and multi-io committed Feb 22, 2024
1 parent a62dc8d commit 0d43d4c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
12 changes: 1 addition & 11 deletions metakube/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions metakube/resource_node_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func metakubeResourceNodeDeployment() *schema.Resource {
"project_id": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Description: "Project the cluster belongs to",
},

Expand Down

0 comments on commit 0d43d4c

Please sign in to comment.