deploymenttheory / terraform-provider-jamfpro

Jamf Pro Terraform Provider/Plugin written with the TF Provider SDK v2. Written in go
Mozilla Public License 2.0
28 stars 10 forks source link

Upgrading to newer versions of extension attribute resource fails b/c of a change in `input_type`'s input type #338

Closed w0de closed 3 days ago

w0de commented 1 month ago

Older versions of jamfpro_computer_extension_attribute expected an interface for input_type. Managing an extension attribute with older versions created Terraform state of this shape:

      "type": "jamfpro_computer_extension_attribute",
      "name": "device_repair_status",
      "provider": "provider[\"registry.terraform.io/deploymenttheory/jamfpro\"]",
      "instances": [
        {
          "schema_version": 0,
          "attributes": {
            "data_type": "Integer",
            "description": "",
            "enabled": true,
            "id": "12",
            "input_type": [
              {
                "choices": [
                  "Out for repair",
                  "Repaired and returned"
                ],
                "platform": "",
                "script": "",
                "type": "Pop-up Menu"
              }
            ],

intput_type's input type is now string. Attempting to upgrade to the latest version of provider therefore generates this error:

│ Error: string is required
│
│   with jamfpro_computer_extension_attribute.device_repair_status,
│   on extension_attributes.tf line 6, in resource "jamfpro_computer_extension_attribute" "device_repair_status":
│    6:   input_type        = "Pop-up Menu"

The referenced value is the new value - but the error appears to be actually caused by the state's value.

Presently, to work around this problem, I'm just re-importing my extension attributes. However, I think the optimal solution may be a state migration function for the resource. (If not feasible or a priority for this resource, its still a good for future schema changes.)

thejoeker12 commented 1 month ago

Having a look into this one today.

ShocOne commented 4 days ago

Will have a look at this when i refactor computer ext atts to support the jamf pro api as part of the next provider release for jamf v11.9. It's under consideration, but i cannot commit to implementing something.

ShocOne commented 3 days ago

i've refactored computer extension attributes to align with the data model for the jamf pro api. there is a state migration for provider v0.2.0 to v0.3.0. However i've decided that i won't be retrofitting state migration functionality for this resource prior to v0.2.0 due to this alpha status of the release in question.