Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: invalid local vars #29

Merged
merged 1 commit into from
Jan 14, 2025
Merged

fix: invalid local vars #29

merged 1 commit into from
Jan 14, 2025

Conversation

eliecharra
Copy link
Member

@eliecharra eliecharra commented Jan 13, 2025

This fixes an issue where Terraform complains because the default of network and subnetwork is null.

See https://spacelift-io.app.spacelift.io/module/terraform-google-spacelift-selfhosted/run/01JH2SJSAPHDNZ01NRM3T5T7CS

│ Error: Inconsistent conditional result types
│
│   on .terraform/modules/spacelift/main.tf line 6, in locals:
│    6:   network                   = var.enable_network ? module.network.network : var.network
│     ├────────────────
│     │ module.network.network is object with 16 attributes
│     │ var.enable_network is true
│     │ var.network is null
│
│ The true and false result expressions must have consistent types. The 'true' value includes object attribute "auto_create_subnetworks", which is absent in the 'false' value.

2025-01-13_15-20

The hack here is to transform those to a tuple and use the ternary operator to set the proper tuple index to use.

I'm not sure why I did not catched that while working on it back in December ...

This fixes an issue where Terraform complains because the default of network and subnetwork is `null`.

```
│ Error: Inconsistent conditional result types
│
│   on .terraform/modules/spacelift/main.tf line 6, in locals:
│    6:   network                   = var.enable_network ? module.network.network : var.network
│     ├────────────────
│     │ module.network.network is object with 16 attributes
│     │ var.enable_network is true
│     │ var.network is null
│
│ The true and false result expressions must have consistent types. The 'true' value includes object attribute "auto_create_subnetworks", which is absent in the 'false' value.
```

The hack here is to transform those to a tuple and use the ternary operator to set the proper tuple index to use.

I'm not sure why I did not catched that while working on it back in December ...
@eliecharra eliecharra force-pushed the fix/invalid_local_vars branch from f601168 to 0a5749f Compare January 13, 2025 14:29
@eliecharra eliecharra merged commit 8f9b539 into main Jan 14, 2025
1 of 2 checks passed
@eliecharra eliecharra deleted the fix/invalid_local_vars branch January 14, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants