Skip to content

Commit

Permalink
PCCM-28439 Metal Terraform provider changes to support PCE HA Zones (#…
Browse files Browse the repository at this point in the history
…244)

* PCCM-28439 Metal Terraform provider changes to support PCE HA Zones

* allow sites modification

* review comments
  • Loading branch information
patricia-dibenedetto authored Jan 10, 2025
1 parent 511ec89 commit eaf8721
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
3 changes: 2 additions & 1 deletion examples/resources/hpegl_metal_project/resource.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) Copyright 2020-2022 Hewlett Packard Enterprise Development LP
// (C) Copyright 2020-2022, 2025 Hewlett Packard Enterprise Development LP

resource "hpegl_metal_project" "project" {
name = "blob"
Expand All @@ -16,4 +16,5 @@ resource "hpegl_metal_project" "project" {
volume_capacity = 300
private_networks = 20
}
sites = ["22473578-e18b-4753-a2e6-ba405b8abc32"]
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/golangci/golangci-lint v1.60.1
github.com/hashicorp/terraform-plugin-docs v0.20.1
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/hewlettpackard/hpegl-metal-client v1.5.23
github.com/hewlettpackard/hpegl-metal-client v1.5.29
github.com/hewlettpackard/hpegl-provider-lib v0.0.22
github.com/stretchr/testify v1.10.0
gopkg.in/yaml.v2 v2.4.0
Expand Down Expand Up @@ -231,7 +231,7 @@ require (
golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/oauth2 v0.24.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/hewlettpackard/hpegl-metal-client v1.5.23 h1:EQuYg4qGpUUF11hNYqb3ekzUKgqIfQd2RNg1Y3SCGqc=
github.com/hewlettpackard/hpegl-metal-client v1.5.23/go.mod h1:+BO4BfQXf3IWnsxvk2IdE27Ijrm1jDVYIgpebYh1L9M=
github.com/hewlettpackard/hpegl-metal-client v1.5.29 h1:TQv6ynHQenSPK9GFvJnfBnWo3w4O/Im2K+G7Ls+lOcM=
github.com/hewlettpackard/hpegl-metal-client v1.5.29/go.mod h1:4fj/Mu7DbfuJhYorAP1lONuj8v+EXHh9cJxxGujf4HA=
github.com/hewlettpackard/hpegl-provider-lib v0.0.22 h1:keW0HjvsMSvIyorqAKc1/XRHkIZqdGn8fqekeuVUSCc=
github.com/hewlettpackard/hpegl-provider-lib v0.0.22/go.mod h1:/gEz8+22QLJfmsdSpH8VPVgn4SpGxxGp+X1i17GUgFY=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
Expand Down Expand Up @@ -848,8 +848,8 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
8 changes: 5 additions & 3 deletions internal/acceptance_test/resource_project_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) Copyright 2022,2024 Hewlett Packard Enterprise Development LP
// (C) Copyright 2022,2024-2025 Hewlett Packard Enterprise Development LP

package acceptance_test

Expand Down Expand Up @@ -62,11 +62,13 @@ func projectBasic(op string) string {
name := `"TestHoster1-SimProject1"`
company := `"HPE"`
hosts := 10
sites := `["1ad98170-993e-4bfc-8b84-e689ea9a429b"]`

if op == "update" {
name = `"TestHoster1-SimProject1-Update"`
company = `"HPE-Update"`
hosts = 5
sites = `["22473578-e18b-4753-a2e6-ba405b8abc32", "1ad98170-993e-4bfc-8b84-e689ea9a429b"]`
}

res := fmt.Sprintf(`
Expand All @@ -87,9 +89,9 @@ func projectBasic(op string) string {
volume_capacity = 300
private_networks = 30
}
sites=["1ad98170-993e-4bfc-8b84-e689ea9a429b"]
sites = %s
volume_replication_enabled = true
}`, name, company, hosts)
}`, name, company, hosts, sites)

return common + res
}
Expand Down
14 changes: 12 additions & 2 deletions internal/resources/resource_project.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) Copyright 2020-2024 Hewlett Packard Enterprise Development LP
// (C) Copyright 2020-2025 Hewlett Packard Enterprise Development LP

package resources

Expand Down Expand Up @@ -152,7 +152,6 @@ func projectSchema() map[string]*schema.Schema {
pSites: {
Type: schema.TypeSet,
Optional: true,
ForceNew: true,
Description: "List of Permitted Site IDs",
Elem: &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -436,6 +435,17 @@ func resourceMetalProjectUpdate(d *schema.ResourceData, meta interface{}) (err e
return fmt.Errorf("only 1 limit block is allowed")
}

if f, ok := d.GetOk(pSites); ok {
s, ok := f.(*schema.Set)
if !ok {
err = fmt.Errorf("sites list is not in the expected format")

return err
}

updateProject.PermittedSites = expandStringList(s.List())
}

if f, ok := d.GetOk(pPermittedImages); ok {
s, ok := f.(*schema.Set)
if !ok {
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.63
1.3.64

0 comments on commit eaf8721

Please sign in to comment.