Skip to content

Commit 411d870

Browse files
authored
Added write-only support to generate (#434)
* Added write-only as a descriptor, handled similarly to "sensitive" * Added write-only tests to respective test files * Ran linter * Added more Write-Only unit tests for nested blocks and attributes * Added acceptance testing * Update internal/schemamd/render.go ---------
1 parent 40e402f commit 411d870

23 files changed

+225
-54
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: FEATURES
2+
body: 'generate: Add support for write-only arguments'
3+
time: 2025-02-12T16:58:19.098098-05:00
4+
custom:
5+
Issue: "434"

.golangci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
issues:
2-
max-per-linter: 0
2+
max-issues-per-linter: 0
33
max-same-issues: 0
44

55
linters:
66
disable-all: true
77
enable:
8+
- copyloopvar
89
- durationcheck
910
- errcheck
10-
- exportloopref
1111
- forcetypeassert
1212
- gofmt
1313
- gosimple
@@ -19,10 +19,10 @@ linters:
1919
- paralleltest
2020
- predeclared
2121
- staticcheck
22-
- tenv
2322
- unconvert
2423
- unparam
2524
- unused
25+
- usetesting
2626

2727
run:
2828
# Prevent false positive timeouts in CI

cmd/tfplugindocs/testdata/scripts/schema-json/generate/framework_provider_success_all_framework_types.txtar

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ example resource
9393
- `single_nested_block` (Block, Optional) example single nested block (see [below for nested schema](#nestedblock--single_nested_block))
9494
- `single_nested_block_sensitive_nested_attribute` (Block, Optional) example sensitive single nested block (see [below for nested schema](#nestedblock--single_nested_block_sensitive_nested_attribute))
9595
- `string_attribute` (String) example string attribute
96+
- `write_only_string_attribute` (String, Write-only) example write-only string attribute
9697

9798
### Read-Only
9899

@@ -418,6 +419,13 @@ scaffolding(stringInput string, boolInput bool, float64Input number, int64Input
418419
"description": "example string attribute",
419420
"description_kind": "markdown",
420421
"optional": true
422+
},
423+
"write_only_string_attribute": {
424+
"type": "string",
425+
"description": "example write-only string attribute",
426+
"description_kind": "markdown",
427+
"optional": true,
428+
"write_only": true
421429
}
422430
},
423431
"block_types": {

internal/check/directory_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ func TestMixedDirectoriesCheck(t *testing.T) {
111111
}
112112

113113
for name, testCase := range testCases {
114-
name := name
115-
testCase := testCase
116114
t.Run(name, func(t *testing.T) {
117115
t.Parallel()
118116

internal/check/file_extension_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ func TestTrimFileExtension(t *testing.T) {
3636
}
3737

3838
for name, testCase := range testCases {
39-
name := name
40-
testCase := testCase
4139
t.Run(name, func(t *testing.T) {
4240
t.Parallel()
4341
got := TrimFileExtension(testCase.Path)

internal/check/file_mismatch_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ func TestFileHasResource(t *testing.T) {
3838
}
3939

4040
for name, testCase := range testCases {
41-
name := name
42-
testCase := testCase
4341
t.Run(name, func(t *testing.T) {
4442
t.Parallel()
4543

@@ -78,8 +76,6 @@ func TestFileResourceName(t *testing.T) {
7876
}
7977

8078
for name, testCase := range testCases {
81-
name := name
82-
testCase := testCase
8379
t.Run(name, func(t *testing.T) {
8480
t.Parallel()
8581
got := fileResourceNameWithProvider("test", testCase.File)
@@ -333,8 +329,6 @@ func TestFileMismatchCheck(t *testing.T) {
333329
}
334330

335331
for name, testCase := range testCases {
336-
name := name
337-
testCase := testCase
338332
t.Run(name, func(t *testing.T) {
339333
t.Parallel()
340334

@@ -381,8 +375,6 @@ func TestResourceHasFile(t *testing.T) {
381375
}
382376

383377
for name, testCase := range testCases {
384-
name := name
385-
testCase := testCase
386378
t.Run(name, func(t *testing.T) {
387379
t.Parallel()
388380

@@ -424,8 +416,6 @@ func TestFunctionHasFile(t *testing.T) {
424416
}
425417

426418
for name, testCase := range testCases {
427-
name := name
428-
testCase := testCase
429419
t.Run(name, func(t *testing.T) {
430420
t.Parallel()
431421

@@ -464,8 +454,6 @@ func TestResourceNames(t *testing.T) {
464454
}
465455

466456
for name, testCase := range testCases {
467-
name := name
468-
testCase := testCase
469457
t.Run(name, func(t *testing.T) {
470458
t.Parallel()
471459

internal/check/file_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ func TestFileSizeCheck(t *testing.T) {
4343
}
4444

4545
for name, testCase := range testCases {
46-
name := name
47-
testCase := testCase
4846
t.Run(name, func(t *testing.T) {
4947
t.Parallel()
5048

@@ -83,8 +81,6 @@ func TestFullPath(t *testing.T) {
8381
}
8482

8583
for name, testCase := range testCases {
86-
name := name
87-
testCase := testCase
8884
t.Run(name, func(t *testing.T) {
8985
t.Parallel()
9086

internal/check/frontmatter_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ subcategory: Example Subcategory
141141
}
142142

143143
for name, testCase := range testCases {
144-
name := name
145-
testCase := testCase
146144
t.Run(name, func(t *testing.T) {
147145
t.Parallel()
148146

internal/provider/util_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ func Test_resourceSchema(t *testing.T) {
6868
}
6969

7070
for name, c := range cases {
71-
name := name
72-
c := c
7371
t.Run(name, func(t *testing.T) {
7472
t.Parallel()
7573

internal/provider/validate_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ func TestValidateStaticDocs_DirectoryChecks(t *testing.T) {
183183
}
184184

185185
for name, testCase := range testCases {
186-
name := name
187-
testCase := testCase
188186
t.Run(name, func(t *testing.T) {
189187
t.Parallel()
190188

@@ -409,8 +407,6 @@ func TestValidateStaticDocs_FileChecks(t *testing.T) {
409407
}
410408

411409
for name, testCase := range testCases {
412-
name := name
413-
testCase := testCase
414410
t.Run(name, func(t *testing.T) {
415411
t.Parallel()
416412

@@ -557,8 +553,6 @@ func TestValidateStaticDocs_FileMismatchCheck(t *testing.T) {
557553
}
558554

559555
for name, testCase := range testCases {
560-
name := name
561-
testCase := testCase
562556
t.Run(name, func(t *testing.T) {
563557
t.Parallel()
564558

@@ -671,8 +665,6 @@ func TestValidateLegacyWebsite_DirectoryChecks(t *testing.T) {
671665
}
672666

673667
for name, testCase := range testCases {
674-
name := name
675-
testCase := testCase
676668
t.Run(name, func(t *testing.T) {
677669
t.Parallel()
678670

@@ -905,8 +897,6 @@ func TestValidateLegacyWebsite_FileChecks(t *testing.T) {
905897
}
906898

907899
for name, testCase := range testCases {
908-
name := name
909-
testCase := testCase
910900
t.Run(name, func(t *testing.T) {
911901
t.Parallel()
912902

@@ -1053,8 +1043,6 @@ func TestValidateLegacyWebsite_FileMismatchCheck(t *testing.T) {
10531043
}
10541044

10551045
for name, testCase := range testCases {
1056-
name := name
1057-
testCase := testCase
10581046
t.Run(name, func(t *testing.T) {
10591047
t.Parallel()
10601048

@@ -1116,8 +1104,6 @@ func TestDocumentationDirGlobPattern(t *testing.T) {
11161104
}
11171105

11181106
for name, testCase := range testCases {
1119-
name := name
1120-
testCase := testCase
11211107
t.Run(name, func(t *testing.T) {
11221108
t.Parallel()
11231109

0 commit comments

Comments
 (0)