Skip to content

Commit

Permalink
Fix IAM resource member documentation (#1924)
Browse files Browse the repository at this point in the history
Adds a DocsEditRule to ensure the bridge can find property descriptions
for both `member` and `members` fields on all IAM resources in this
provider.

Fixes #1920, but that is not
the only instance of this bug.


- Ensure bridge can find content for both members and memebr properties
for IAM resources
- Generate SDKs
  • Loading branch information
guineveresaenger committed Apr 16, 2024
2 parents 48e6413 + 679b9b5 commit c1d736f
Show file tree
Hide file tree
Showing 2,026 changed files with 217,419 additions and 75,719 deletions.
3,500 changes: 2,038 additions & 1,462 deletions provider/cmd/pulumi-resource-gcp/schema.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions provider/doc_edits.go
Expand Up @@ -14,6 +14,7 @@ func editRules(defaults []tfbridge.DocsEdit) []tfbridge.DocsEdit {
removeSecretsInPlainTextNote,
removeBetaFromDescriptionField,
substituteRandomSuffix,
rewritemembersField,
)
}

Expand Down Expand Up @@ -88,3 +89,26 @@ var substituteRandomSuffix = (func() tfbridge.DocsEdit {
},
}
})()

// Docs discovery gets tripped up on `member/members` fields for IAM-type properties and doesn't align the content
// correctly.
var memberRegexp = regexp.MustCompile("`member/members`")

var rewritemembersField = tfbridge.DocsEdit{
Path: "*iam.html.markdown",
Edit: func(path string, content []byte) ([]byte, error) {
membersByte := []byte("`members`")
memberByte := []byte("`member`")
var returnContent []byte
membersContent := memberRegexp.ReplaceAllLiteral(content, membersByte)
memberContent := memberRegexp.ReplaceAllLiteral(content, memberByte)
// Because the IamBinding property matches to a `members` field, while the `IAMMember` property matches to a
//`member` field, we need to create content for both `members` and `member` so the bridge can match each.
//The easiest way to do this is to duplicate the content in its entirety, once for `members` and once for
//`member`, and let the bridge figure it out.
// See https://github.com/pulumi/pulumi-gcp/issues/1920 for context.
returnContent = append(returnContent, membersContent...)
returnContent = append(returnContent, memberContent...)
return returnContent, nil
},
}
20 changes: 20 additions & 0 deletions provider/doc_edits_test.go
Expand Up @@ -124,3 +124,23 @@ func TestBetaDescription(t *testing.T) {
})
}
}

func TestRewriteMembersField(t *testing.T) {
t.Parallel()
tests := []struct{ text, expected string }{
{
"`member/members` - Identities that will be granted privileges\n",
"`members` - Identities that will be granted privileges\n" +
"`member` - Identities that will be granted privileges\n",
},
}

for _, tt := range tests {
tt := tt
t.Run(tt.text, func(t *testing.T) {
actual, err := rewritemembersField.Edit("doc.md", []byte(tt.text))
require.NoError(t, err)
assert.Equal(t, tt.expected, string(actual))
})
}
}
132 changes: 110 additions & 22 deletions sdk/dotnet/AccessContextManager/AccessPolicyIamBinding.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c1d736f

Please sign in to comment.