OpenNebula / terraform-provider-opennebula

Terraform provider for OpenNebula
https://www.terraform.io/docs/providers/opennebula/
Mozilla Public License 2.0
63 stars 52 forks source link

opennebula_templates: name_regex not working #470

Closed deynekoaa closed 1 year ago

deynekoaa commented 1 year ago

Description

  1. Searching by name_regex not working
    data "opennebula_templates" "found_templates" {
    name_regex = "^.*centos-7.*$"
    has_cpu    = true
    sort_on   = "register_date"
    order      = "ASC"
    }

On every input it return:

Planning failed. Terraform encountered an error while generating this plan.

╷
│ Error: templates filtering failed
│
│   with data.opennebula_templates.found_templates,
│   on main.tf line 21, in data "opennebula_templates" "found_templates":
│   21: data "opennebula_templates" "found_templates" {
│
│ no templates match the constraints
╵
  1. In doc option sort_on declareted twise. It's error. Should be:

    data "opennebula_templates" "example" {
    name_regex = "test.*"
    has_cpu    = true
    sort_on    = "register_date"
    order       = "ASC"
    }
  2. In doc option order should be in uppercase accoding code. I.e.:

    * `order` - (Optional) Ordering of the sort: ASC or DESC.

Terraform and Provider version

# terraform -v
2023-07-17T18:59:15.797Z [INFO]  Terraform version: 1.5.3
2023-07-17T18:59:15.798Z [INFO]  Go runtime version: go1.20
2023-07-17T18:59:15.798Z [INFO]  CLI args: []string{"terraform", "-v"}
2023-07-17T18:59:15.799Z [INFO]  CLI command args: []string{"version", "-v"}
Terraform v1.5.3
on linux_amd64
+ provider registry.terraform.io/opennebula/opennebula v1.2.2

Affected resources and data sources

opennebula_templates

Terraform configuration

terraform {
  required_providers {
    opennebula = {
      source = "OpenNebula/opennebula"
      version = "~> 1.2.2"
    }
  }
}

provider "opennebula" {
 endpoint      = "my_nebula"
}

data "opennebula_templates" "found_templates" {
  name_regex = ".*centos-7.*$"
  has_cpu    = true
  sort_on   = "register_date"
  order      = "ASC"
}

resource "opennebula_virtual_machine" "example2" {
  name        = "test2"
  description = "VM"
  memory      = 64
  cpu         = 1

  template_id = data.opennebula_templates.found_templates.templates[0].id
}

### Expected behavior

Template should be found

### Actual behavior

Planning failed. Terraform encountered an error while generating this plan.

╷ │ Error: templates filtering failed │ │ with data.opennebula_templates.found_templates, │ on main.tf line 21, in data "opennebula_templates" "found_templates": │ 21: data "opennebula_templates" "found_templates" { │ │ no templates match the constraints



### Steps to Reproduce

Just try to search templates by regexp

### Debug output

_No response_

### Panic output

_No response_

### Important factoids

_No response_

### References

https://github.com/OpenNebula/terraform-provider-opennebula/issues/322