Repository navigation
Conversation
Exposes the component type catalog category, so a custom type can be filed under the Infrastructure catalog with `category = "infrastructure"` instead of being patched out of band after creation. The attribute is optional and computed. The API leaves an existing category untouched when the field is omitted, so an unset attribute keeps whatever the type already has rather than resetting it, and the input is omitted entirely rather than sent as an explicit null. No validator: category is a free-form String on the API and the schema documents it as any component category alias on the account, so pinning a closed set here would break importing a type with a category the provider does not know about. Also fixes a pre-existing nil dereference: `icon` is optional but was dereferenced unconditionally on create and update, so any component type configured without an icon block crashed the provider. This is on the path for adopting existing types, which often have no icon in config. Depends on the category support in opslevel-go. The go.mod replace directive and submodules/opslevel-go pointer are temporary and should be swapped for a released version before merge. Co-authored-by: Cursor <cursoragent@cursor.com>
…nfrastructure-component # Conflicts: # go.mod # opslevel/datasource_opslevel_component_type.go # opslevel/resource_opslevel_component_type.go # submodules/opslevel-go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #682 +/- ##
========================================
+ Coverage 0.22% 1.90% +1.67%
========================================
Files 85 107 +22
Lines 9651 12977 +3326
========================================
+ Hits 22 247 +225
- Misses 9626 12707 +3081
- Partials 3 23 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Every component type belongs to a catalog, and "default" is the one that is not Infrastructure, so the API is expected to return it rather than nothing. Reads went through ComputedStringValue, which maps an empty string to null. If the API ever returns empty for an uncategorized type, a config setting category = "default" explicitly would plan "default" and apply to null, and Terraform fails that as an inconsistent result rather than surfacing drift. Map an empty read to "default" instead so that path cannot hard fail, and cover both the read mapping and the write omission with unit tests. Co-authored-by: Cursor <cursoragent@cursor.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
categoryattribute to theopslevel_component_typeresource and to both the singular and plural component type data sources, so infrastructure component types can be managed in Terraform. Settingcategory = "infrastructure"files the type under the Infrastructure catalog.The attribute is a plain string with no validator. The backend treats categories as account-scoped aliases rather than a fixed enum — the same way
allowed_categoriesalready works on relationship definitions — so hardcoding a closed set would be wrong.Optional + Computed, and why
categoryisOptional + ComputedwithUseStateForUnknown. Leaving it out of config preserves whatever category the type already has rather than forcing it back todefault, which matters for adopting existing infrastructure types into Terraform: you canterraform importone without the first apply silently moving it out of the Infrastructure catalog.The corollary is that this attribute can't be "unset" by deleting it from config. Moving a type back to the Components catalog means writing
category = "default"explicitly. That seemed clearly safer than the alternative, but flag it if you'd rather it behave differently.Drive-by bug fix
CreateandUpdateunconditionally dereferencedplanModel.Icon, so the provider panicked on anyopslevel_component_typeconfig that omitted the optionaliconblock. That's pre-existing onmainand easy to hit — it's exactly what you write when adopting an existing type — so it's fixed here along with the matching read path. Separate changie entry.Dependency
Depends on OpsLevel/opslevel-go#647, which adds
CategorytoComponentTypeInputandComponentType. Thego.modreplacedirective and thesubmodules/opslevel-gopointer are temporary and should be swapped for a released version bump before merge.Please read the feature-flag section on #647 before merging this. The short version: if
categoryis still gated behindinfra_component_types_uiat the schema level, then adding it to the client'sComponentTypeselection set breaks reads for accounts without the flag, and this PR shouldn't land either. I've asked there for someone with backend visibility to confirm. That question sank the earlier attempt (OpsLevel/opslevel-go#613) and I'd rather resolve it up front than repeat it.Test plan
task lint— gofumpt, golangci-lint (0 issues),terraform validate,terraform fmt -checktask test— terraform mock tests + Go unit tests, 109 passed / 0 failed, including newcategoryassertions on the resource and both data sourcesinfrastructure, in-place update between categories, no diff when the attribute is dropped from config, destroy, and import-for-adoptiontfplugindocsMade with Cursor