-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate: Prevent incorrect attribute association with very deep nest…
…ing (#382) Reference: #380 After introducing the new unit test matching the given schema and expected output, prior to the logic change: ``` --- FAIL: TestRender (0.00s) --- FAIL: TestRender/deep_nested_attributes (0.00s) /Users/bflad/src/github.com/hashicorp/terraform-plugin-docs/internal/schemamd/render_test.go:91: Unexpected diff (-wanted, +got): strings.Join({ ... // 1062 identical bytes "el_two.level_three.level_four_primary. (see [below for nested sc", "hema](#nestedatt--level_one--level_two--level_three--level_four_", - "prim", + "second", "ary--level_five))\n- `level_four_primary_string` (String) Parent ", "should be level_one.level_two.level_three.level_four_primary.\n\n<", `a id="nestedatt--level_one--level_two--level_three--level_four_`, - "prim", + "second", "ary--level_five\"></a>\n### Nested Schema for `level_one.level_two", ".level_three.level_four_", - "prim", + "second", "ary.level_five`\n\nOptional:\n\n- `level_five_string` (String) Paren", "t should be level_one.level_two.level_three.level_four_primary.l", "evel_five.", }, "") ```
- Loading branch information
Showing
5 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
kind: BUG FIXES | ||
body: 'generate: Prevented incorrect attribute paths with nested attributes that contain multiple attributes' | ||
time: 2024-06-03T09:29:11.314279-07:00 | ||
custom: | ||
Issue: "380" |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
## Schema | ||
|
||
### Required | ||
|
||
- `level_one` (Attributes) (see [below for nested schema](#nestedatt--level_one)) | ||
|
||
### Read-Only | ||
|
||
- `id` (String) Example identifier | ||
|
||
<a id="nestedatt--level_one"></a> | ||
### Nested Schema for `level_one` | ||
|
||
Optional: | ||
|
||
- `level_two` (Attributes) (see [below for nested schema](#nestedatt--level_one--level_two)) | ||
|
||
<a id="nestedatt--level_one--level_two"></a> | ||
### Nested Schema for `level_one.level_two` | ||
|
||
Optional: | ||
|
||
- `level_three` (Attributes) (see [below for nested schema](#nestedatt--level_one--level_two--level_three)) | ||
|
||
<a id="nestedatt--level_one--level_two--level_three"></a> | ||
### Nested Schema for `level_one.level_two.level_three` | ||
|
||
Optional: | ||
|
||
- `level_four_primary` (Attributes) (see [below for nested schema](#nestedatt--level_one--level_two--level_three--level_four_primary)) | ||
- `level_four_secondary` (String) | ||
|
||
<a id="nestedatt--level_one--level_two--level_three--level_four_primary"></a> | ||
### Nested Schema for `level_one.level_two.level_three.level_four_primary` | ||
|
||
Optional: | ||
|
||
- `level_five` (Attributes) Parent should be level_one.level_two.level_three.level_four_primary. (see [below for nested schema](#nestedatt--level_one--level_two--level_three--level_four_primary--level_five)) | ||
- `level_four_primary_string` (String) Parent should be level_one.level_two.level_three.level_four_primary. | ||
|
||
<a id="nestedatt--level_one--level_two--level_three--level_four_primary--level_five"></a> | ||
### Nested Schema for `level_one.level_two.level_three.level_four_primary.level_five` | ||
|
||
Optional: | ||
|
||
- `level_five_string` (String) Parent should be level_one.level_two.level_three.level_four_primary.level_five. |
78 changes: 78 additions & 0 deletions
78
internal/schemamd/testdata/deep_nested_attributes.schema.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"version": 0, | ||
"block": { | ||
"attributes": { | ||
"id": { | ||
"type": "string", | ||
"description": "Example identifier", | ||
"description_kind": "markdown", | ||
"computed": true | ||
}, | ||
"level_one": { | ||
"nested_type": { | ||
"attributes": { | ||
"level_two": { | ||
"nested_type": { | ||
"attributes": { | ||
"level_three": { | ||
"nested_type": { | ||
"attributes": { | ||
"level_four_primary": { | ||
"nested_type": { | ||
"attributes": { | ||
"level_five": { | ||
"nested_type": { | ||
"attributes": { | ||
"level_five_string": { | ||
"type": "string", | ||
"description": "Parent should be level_one.level_two.level_three.level_four_primary.level_five.", | ||
"description_kind": "plain", | ||
"optional": true | ||
} | ||
}, | ||
"nesting_mode": "single" | ||
}, | ||
"description": "Parent should be level_one.level_two.level_three.level_four_primary.", | ||
"description_kind": "plain", | ||
"optional": true | ||
}, | ||
"level_four_primary_string": { | ||
"type": "string", | ||
"description": "Parent should be level_one.level_two.level_three.level_four_primary.", | ||
"description_kind": "plain", | ||
"optional": true | ||
} | ||
}, | ||
"nesting_mode": "single" | ||
}, | ||
"description_kind": "plain", | ||
"optional": true | ||
}, | ||
"level_four_secondary": { | ||
"type": "string", | ||
"description_kind": "plain", | ||
"optional": true | ||
} | ||
}, | ||
"nesting_mode": "single" | ||
}, | ||
"description_kind": "plain", | ||
"optional": true | ||
} | ||
}, | ||
"nesting_mode": "single" | ||
}, | ||
"description_kind": "plain", | ||
"optional": true | ||
} | ||
}, | ||
"nesting_mode": "single" | ||
}, | ||
"description_kind": "plain", | ||
"required": true | ||
} | ||
}, | ||
"description": "Example resource", | ||
"description_kind": "markdown" | ||
} | ||
} |