Skip to content

Commit

Permalink
v0.11.0 release (#11)
Browse files Browse the repository at this point in the history
Added support for V10MP2R2 model
Removed support for specifying version plan by specific version (e.g
6.6.4)

Co-authored-by: Tomas Simacek <[email protected]>
  • Loading branch information
tsimacek and Tomas Simacek authored Sep 20, 2024
1 parent b56e7da commit 4cb6a84
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 71 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.11.0 (Sep, 20, 2024)
* Added support for V10MP2R2 model
* Removed support for specifying version plan by specific version (e.g `6.6.4`)

## 0.10.0 (July 9, 2024)

* Added support for tagging by resource type, refer to the [documentation](docs/resources/array_azure.md#nested-schema-for-resource_tags)
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ setup-basic:
@mkdir -p .build-logs/

setup-goreleaser:
@curl -sfLO https://github.com/goreleaser/goreleaser/releases/download/v1.9.2/goreleaser_Linux_x86_64.tar.gz
@curl -sfLO https://github.com/goreleaser/goreleaser/releases/download/v2.0.1/goreleaser_Linux_x86_64.tar.gz
@mkdir -p $(TMPBIN)
@tar -C $(TMPBIN) -xf goreleaser_Linux_x86_64.tar.gz
@rm goreleaser_Linux_x86_64.tar.gz
Expand All @@ -36,7 +36,7 @@ test-goreleaser-release: setup-goreleaser setup-basic
@gpg --batch --delete-secret-keys $(TEST_GPG_FINGERPRINT) &>/dev/null || true
@gpg --batch --delete-keys $(TEST_GPG_FINGERPRINT) &>/dev/null || true
@gpg --import < testing/private-key.gpg >> .build-logs/goreleaser-release 2>&1
@GPG_FINGERPRINT=$(TEST_GPG_FINGERPRINT) CI="" goreleaser release --debug --snapshot --rm-dist >> .build-logs/goreleaser-release 2>&1
@GPG_FINGERPRINT=$(TEST_GPG_FINGERPRINT) CI="" goreleaser release --verbose --snapshot --clean >> .build-logs/goreleaser-release 2>&1

test-goreleaser-check: setup-goreleaser setup-basic
@CI="" goreleaser check >> .build-logs/goreleaser-check 2>&1
Expand Down
4 changes: 2 additions & 2 deletions cbs/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ func validateAzureManagedApplicationName(v interface{}, k string) (warnings []st
func validateVersionPrefixTag(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)

pattern := `^\d+\.\d+(?:\.\d+|\.x)?$`
pattern := `^\d+\.\d+\.x$`
regexpPattern := regexp.MustCompile(pattern)

if !regexpPattern.MatchString(value) {
errors = append(errors, fmt.Errorf("version prefix tag format not correct"))
errors = append(errors, fmt.Errorf("%q must follow {major}.{minor}.x format. See documentation for examples", k))
}

return warnings, errors
Expand Down
8 changes: 6 additions & 2 deletions cbs/data_azure_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (a PlanByVersion) Len() int { return len(a) }
func (a PlanByVersion) Less(i, j int) bool { return a[i].Version.LessThan(&a[j].Version) }
func (a PlanByVersion) Swap(i, j int) { a[i], a[j] = a[j], a[i] }

var plan_name_regexp = regexp.MustCompile(`^[\w]+_([\d]+)_([\d]+)_([\d]+)$`)
var plan_name_regexp = regexp.MustCompile(`^[\w]+_([\d]+)_([\d]+)_(x)$`)

// Retrieve a plan information from Azure DefaultTemplate artifact
func GetPlanFromTemplateJson(data []byte) (*Plan, error) {
Expand All @@ -152,7 +152,11 @@ func versionPlans(plans []Plan) ([]VersionedPlan, error) {
var versioned_plans []VersionedPlan
for _, plan := range plans {
match := plan_name_regexp.FindStringSubmatch(plan.Name)
version, err := version.NewVersion(fmt.Sprintf("%s.%s.%s", match[1], match[2], match[3]))
patch := match[3]
if patch == "x" {
patch = "99"
}
version, err := version.NewVersion(fmt.Sprintf("%s.%s.%s", match[1], match[2], patch))
if err != nil {
return nil, fmt.Errorf("Unable to parse version string in plan name: %s", plan.Name)
}
Expand Down
21 changes: 9 additions & 12 deletions cbs/data_azure_plans_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,12 @@ func testAccDataAzurePlans() resource.TestCheckFunc {
for i := 0; i < plans_size; i++ {
// Check product version derivation from plan name makes sense.
plan_name := data_resource.Primary.Attributes["plans."+strconv.Itoa(i)+".name"]
name_match := plan_name_regexp.FindStringSubmatch(plan_name)
name_version, err := version.NewVersion(fmt.Sprintf("%s.%s.%s", name_match[1], name_match[2], name_match[3]))
if err != nil {
return err
}
reference_version, _ := version.NewVersion("6.0.0")
if name_version.LessThanOrEqual(reference_version) {
return fmt.Errorf("Incorrect product version: %s", name_version.String())
if !plan_name_regexp.MatchString(plan_name) {
return fmt.Errorf("Incorrect plan id/name: %s, it should be in format of ", plan_name)
}

// We expect that product and publisher is a well-known string.
plan_product := data_resource.Primary.Attributes["plans."+strconv.Itoa(i)+".product"]
if plan_product != "pure_storage_cloud_block_store_deployment" {
if plan_product != "pure_storage_cloud_block_store_deployment" && plan_product != "pure_cloud_block_store_product_deployment" {
return fmt.Errorf("Incorrect plan product: %s", plan_product)
}
plan_publisher := data_resource.Primary.Attributes["plans."+strconv.Itoa(i)+".publisher"]
Expand Down Expand Up @@ -138,13 +131,17 @@ func testAccDataCbsPlanAzure() resource.TestCheckFunc {

plan_name := data_resource.Primary.Attributes["name"]
match := plan_name_regexp.FindStringSubmatch(plan_name)
version_tag := fmt.Sprintf("%s.%s.%s", match[1], match[2], match[3])
patch := match[3]
if patch == "x" {
patch = "99"
}
version_tag := fmt.Sprintf("%s.%s.%s", match[1], match[2], patch)
if len(match) != 4 || !re.MatchString(version_tag) {
return fmt.Errorf("Incorrect plan name: %s", plan_name)
}

plan_product := data_resource.Primary.Attributes["product"]
if plan_product != "pure_storage_cloud_block_store_deployment" {
if plan_product != "pure_storage_cloud_block_store_deployment" && plan_product != "pure_cloud_block_store_product_deployment" {
return fmt.Errorf("Incorrect plan product : %s", plan_product)
}

Expand Down
5 changes: 3 additions & 2 deletions cbs/resource_array_azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import (

// Default managed application plan
const (
defaultPlanName = "cbs_azure_6_3_8"
defaultPlanProduct = "pure_storage_cloud_block_store_deployment"
defaultPlanName = "cbs_azure_6_5_x"
defaultPlanProduct = "pure_cloud_block_store_product_deployment"
defaultPlanPublisher = "purestoragemarketplaceadmin"
defaultPlanVersion = "1.0.0"
)
Expand Down Expand Up @@ -166,6 +166,7 @@ func resourceArrayAzure() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{
"V10MUR1",
"V20MUR1",
"V10MP2R2",
"V20MP2R2",
}, false),
},
Expand Down
2 changes: 1 addition & 1 deletion cbs/resource_array_azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestAccArrayAzure_basic(t *testing.T) {
// when tags are provided plan is needed to get plan specific
// list of resources to assign all tags to each resource
cbsAzureParam.PlanName = plans[0].Plan.Name
cbsAzureParam.PlanProduct = "pure_storage_cloud_block_store_deployment"
cbsAzureParam.PlanProduct = plans[0].Plan.Product
cbsAzureParam.PlanPublisher = "purestoragemarketplaceadmin"
cbsAzureParam.PlanVersion = plans[0].Plan.Version

Expand Down
14 changes: 7 additions & 7 deletions docs/data-sources/azure_plans.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ description: |-

# cbs_plan_azure (Data Source)

Provides plan specific details specified by plan version parameter (or version prefix e.g. `6.6.4` or `6.6.x`)
Provides plan specific details specified by plan version parameter. The version needs to be specified in format of version prefix e.g. `6.5.x` or `6.6.x` and similar. Specific versions like `6.6.10` are not supported as only the latest version in a given release line is svailable in the marketplace offer for deployment.

## Example Usage
```hcl
data "cbs_plan_azure" "66x_latest_plan" {
data "cbs_plan_azure" "cbs_plan_66x" {
plan_version = "6.6.x"
}
resource "cbs_array_azure" "azure_instance" {
(...)
plan {
name = data.cbs_plan_azure.66x_latest_plan.name
product = data.cbs_plan_azure.66x_latest_plan.product
publisher = data.cbs_plan_azure.66x_latest_plan.publisher
version = data.cbs_plan_azure.66x_latest_plan.version
name = data.cbs_plan_azure.cbs_plan_66x.name
product = data.cbs_plan_azure.cbs_plan_66x.product
publisher = data.cbs_plan_azure.cbs_plan_66x.publisher
version = data.cbs_plan_azure.cbs_plan_66x.version
}
lifecycle {
Expand All @@ -34,7 +34,7 @@ resource "cbs_array_azure" "azure_instance" {
}
output "cbs_azure_available_plans" {
value = data.cbs_plan_azure.66x_latest_plan
value = data.cbs_plan_azure.cbs_plan_66x
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/array_azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ resource "cbs_array_azure" "azure_instance" {
## Argument Reference

- `alert_recipients` (Optional) - List of email addresses to receive alerts.
- `array_model` (Required) - CBS array size to launch. The possible values are `V10MUR1`, `V20MUR1` or `V20MP2R2`.
- `array_model` (Required) - CBS array size to launch. The possible values are `V10MUR1`, `V20MUR1`, `V10MP2R2` or `V20MP2R2`.
- `array_name` (Required) - Name of the array, and the name of the managed application.
Required when the array is deployed for use in a Fusion cluster.
- `iscsi_subnet` (Required) - Subnet containing the iSCSI interfaces on the array.
Expand Down
2 changes: 1 addition & 1 deletion examples/aws_array/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
cbs = {
source = "PureStorage-OpenConnect/cbs"
version = "~> 0.10.0"
version = "~> 0.11.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/azure_array/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
cbs = {
source = "PureStorage-OpenConnect/cbs"
version = "~> 0.10.0"
version = "~> 0.11.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/azure_array/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resource_group_name = "resource_xxxx"
license_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx"
log_sender_domain = "example-company.org"
alert_recipients = ["[email protected]", "[email protected]"]
array_model = "V10MUR1"
array_model = "V10MP2R2"
zone = 1
virtual_network_id = "/subscriptions/xxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxxxxx/providers/Microsoft.Network/virtualNetworks/xxxxxxxxxxxxxx"
key_vault_id = "/subscriptions/xxxxxxxxxxxxxx/resourceGroups/xxxxxxxxxxxxxx/providers/Microsoft.KeyVault/vaults/xxxxxxxxxxxxxx"
Expand Down
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ require (
github.com/mattn/go-sqlite3 v1.14.16
github.com/stretchr/testify v1.8.4
github.com/terraform-providers/terraform-provider-azurerm v1.44.0
golang.org/x/crypto v0.14.0
golang.org/x/term v0.13.0
golang.org/x/crypto v0.21.0
golang.org/x/term v0.18.0
)

require github.com/google/uuid v1.3.1 // indirect
Expand All @@ -45,23 +45,23 @@ require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/loads v0.21.2 // indirect
github.com/go-openapi/spec v0.20.7 // indirect
github.com/gofrs/uuid v4.3.0+incompatible // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.3.1 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.5 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/hc-install v0.4.0 // indirect
github.com/hashicorp/hcl/v2 v2.14.1 // indirect
Expand All @@ -78,7 +78,7 @@ require (
github.com/manicminer/hamilton v0.50.0 // indirect
github.com/manicminer/hamilton-autorest v0.3.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
Expand All @@ -94,14 +94,14 @@ require (
github.com/vmihailenco/tagparser v0.1.2 // indirect
github.com/zclconf/go-cty v1.11.1 // indirect
go.mongodb.org/mongo-driver v1.10.3 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.1.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71 // indirect
google.golang.org/grpc v1.50.1 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.56.3 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 4cb6a84

Please sign in to comment.