Skip to content

Bug [jetbrains-gateway]: Errors produced when jetbrains_ide_versions aren't a covering set #22

Open
@angrycub

Description

@angrycub

Issue

When I specify jetbrains_ide_versions, it causes the template to throw errors unless all of the versions are set in the template. As a user, I would prefer to only set versions for the specific versions that I need to make explicit.

For example, if I only need a specific version of IntelliJ IDEA Ultimate, I would like to have my variables set like the following:

module "jetbrains_gateway" {
  jetbrains_ides = ["IU"]
  default        = "IU"
  latest         = false
  jetbrains_ide_versions = {
    "IU" = {
      build_number = "243.26053.27"
      version      = "2024.3"
    }
  }
}

However, if I do that currently, I receive three errors per product identifier, even for the ones I do not have configured, like the following:

╷
│ Error: Invalid index
│ 
│   on jetbrains-gateway/main.tf line 186, in locals:
│  186:       build_number  = var.jetbrains_ide_versions["GO"].build_number,
│     ├────────────────
│     │ var.jetbrains_ide_versions is map of object with 1 element
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on jetbrains-gateway/main.tf line 187, in locals:
│  187:       download_link = "${var.download_base_link}/go/goland-${var.jetbrains_ide_versions["GO"].version}.tar.gz"
│     ├────────────────
│     │ var.jetbrains_ide_versions is map of object with 1 element
│ 
│ The given key does not identify an element in this collection value.
╵
╷
│ Error: Invalid index
│ 
│   on jetbrains-gateway/main.tf line 188, in locals:
│  188:       version       = var.jetbrains_ide_versions["GO"].version
│     ├────────────────
│     │ var.jetbrains_ide_versions is map of object with 1 element
│ 
│ The given key does not identify an element in this collection value.
╵

This looks to be related to the lines like this, which would be attempting to access variables that don't exist in the replaced set of values.

Potential remediations

If we move the current default list of IDE versions to a local, we could then merge in a user-supplied jetbrains_ide_versions to create a fully-covering map. Perhaps we could do the same thing with the default list of IDEs; however in that case, we might want to step on the defaults if the template admins provides a specific list of IDEs to show.

The super-sized fix for this would fetch the output for the Jetbrains product API, cache the values as a local latest which would be put in amber for each version of the module. This has the side benefit of providing an object that we could merge both user supplied and freshly-fetched latest version data from the product API into the cached data. That object would also contain information about all of the platform specific download URLs. We still have to maintain a separate object to hold the product code, full IDE names, and icons to use.

Externalizing the data as JSON files and loading them in from the module also makes them a bit more editable/loadable without having to edit the template source anytime we want to update the in-built defaults.

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions