Skip to content

Commit

Permalink
Ensure issue labels behavior is documented (#746)
Browse files Browse the repository at this point in the history
#744, while really an
instance of pulumi/pulumi#918, happens in this
particular way because this particular resource does a courtesy
import/create for already existing (usually, github default) issue
labels.

The [upstream
documentation](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/issue_label)
to this effect was elided via docsgen. This pull request ensures that
the information persists to our API docs.

Closes #744.
  • Loading branch information
guineveresaenger authored Aug 13, 2024
1 parent 560bc17 commit efaea17
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 1 deletion.
2 changes: 1 addition & 1 deletion provider/cmd/pulumi-resource-github/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5968,7 +5968,7 @@
}
},
"github:index/issueLabel:IssueLabel": {
"description": "## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as github from \"@pulumi/github\";\n\n// Create a new, red colored label\nconst testRepo = new github.IssueLabel(\"test_repo\", {\n repository: \"test-repo\",\n name: \"Urgent\",\n color: \"FF0000\",\n});\n```\n```python\nimport pulumi\nimport pulumi_github as github\n\n# Create a new, red colored label\ntest_repo = github.IssueLabel(\"test_repo\",\n repository=\"test-repo\",\n name=\"Urgent\",\n color=\"FF0000\")\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Github = Pulumi.Github;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n // Create a new, red colored label\n var testRepo = new Github.IssueLabel(\"test_repo\", new()\n {\n Repository = \"test-repo\",\n Name = \"Urgent\",\n Color = \"FF0000\",\n });\n\n});\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-github/sdk/v6/go/github\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t// Create a new, red colored label\n\t\t_, err := github.NewIssueLabel(ctx, \"test_repo\", \u0026github.IssueLabelArgs{\n\t\t\tRepository: pulumi.String(\"test-repo\"),\n\t\t\tName: pulumi.String(\"Urgent\"),\n\t\t\tColor: pulumi.String(\"FF0000\"),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.github.IssueLabel;\nimport com.pulumi.github.IssueLabelArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n // Create a new, red colored label\n var testRepo = new IssueLabel(\"testRepo\", IssueLabelArgs.builder()\n .repository(\"test-repo\")\n .name(\"Urgent\")\n .color(\"FF0000\")\n .build());\n\n }\n}\n```\n```yaml\nresources:\n # Create a new, red colored label\n testRepo:\n type: github:IssueLabel\n name: test_repo\n properties:\n repository: test-repo\n name: Urgent\n color: FF0000\n```\n\u003c!--End PulumiCodeChooser --\u003e\n\n## Import\n\nGitHub Issue Labels can be imported using an ID made up of `repository:name`, e.g.\n\n```sh\n$ pulumi import github:index/issueLabel:IssueLabel panic_label terraform:panic\n```\n",
"description": "Provides a GitHub issue label resource.\n\nThis resource allows you to create and manage issue labels within your\nGitHub organization.\n\nIssue labels are keyed off of their \"name\", so pre-existing issue labels result\nin a 422 HTTP error if they exist outside of Pulumi. Normally this would not\nbe an issue, except new repositories are created with a \"default\" set of labels,\nand those labels easily conflict with custom ones.\n\nThis resource will first check if the label exists, and then issue an update,\notherwise it will create.\n\n## Example Usage\n\n\u003c!--Start PulumiCodeChooser --\u003e\n```typescript\nimport * as pulumi from \"@pulumi/pulumi\";\nimport * as github from \"@pulumi/github\";\n\n// Create a new, red colored label\nconst testRepo = new github.IssueLabel(\"test_repo\", {\n repository: \"test-repo\",\n name: \"Urgent\",\n color: \"FF0000\",\n});\n```\n```python\nimport pulumi\nimport pulumi_github as github\n\n# Create a new, red colored label\ntest_repo = github.IssueLabel(\"test_repo\",\n repository=\"test-repo\",\n name=\"Urgent\",\n color=\"FF0000\")\n```\n```csharp\nusing System.Collections.Generic;\nusing System.Linq;\nusing Pulumi;\nusing Github = Pulumi.Github;\n\nreturn await Deployment.RunAsync(() =\u003e \n{\n // Create a new, red colored label\n var testRepo = new Github.IssueLabel(\"test_repo\", new()\n {\n Repository = \"test-repo\",\n Name = \"Urgent\",\n Color = \"FF0000\",\n });\n\n});\n```\n```go\npackage main\n\nimport (\n\t\"github.com/pulumi/pulumi-github/sdk/v6/go/github\"\n\t\"github.com/pulumi/pulumi/sdk/v3/go/pulumi\"\n)\n\nfunc main() {\n\tpulumi.Run(func(ctx *pulumi.Context) error {\n\t\t// Create a new, red colored label\n\t\t_, err := github.NewIssueLabel(ctx, \"test_repo\", \u0026github.IssueLabelArgs{\n\t\t\tRepository: pulumi.String(\"test-repo\"),\n\t\t\tName: pulumi.String(\"Urgent\"),\n\t\t\tColor: pulumi.String(\"FF0000\"),\n\t\t})\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t})\n}\n```\n```java\npackage generated_program;\n\nimport com.pulumi.Context;\nimport com.pulumi.Pulumi;\nimport com.pulumi.core.Output;\nimport com.pulumi.github.IssueLabel;\nimport com.pulumi.github.IssueLabelArgs;\nimport java.util.List;\nimport java.util.ArrayList;\nimport java.util.Map;\nimport java.io.File;\nimport java.nio.file.Files;\nimport java.nio.file.Paths;\n\npublic class App {\n public static void main(String[] args) {\n Pulumi.run(App::stack);\n }\n\n public static void stack(Context ctx) {\n // Create a new, red colored label\n var testRepo = new IssueLabel(\"testRepo\", IssueLabelArgs.builder()\n .repository(\"test-repo\")\n .name(\"Urgent\")\n .color(\"FF0000\")\n .build());\n\n }\n}\n```\n```yaml\nresources:\n # Create a new, red colored label\n testRepo:\n type: github:IssueLabel\n name: test_repo\n properties:\n repository: test-repo\n name: Urgent\n color: FF0000\n```\n\u003c!--End PulumiCodeChooser --\u003e\n\n## Import\n\nGitHub Issue Labels can be imported using an ID made up of `repository:name`, e.g.\n\n```sh\n$ pulumi import github:index/issueLabel:IssueLabel panic_label terraform:panic\n```\n",
"properties": {
"color": {
"type": "string",
Expand Down
21 changes: 21 additions & 0 deletions provider/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package github

import (
"bytes"
"fmt"
"path/filepath"
"unicode"
Expand Down Expand Up @@ -86,6 +87,7 @@ func Provider() tfbridge.ProviderInfo {
Version: version.Version,
MetadataInfo: tfbridge.NewProviderMetadata(metadata),
UpstreamRepoPath: "./upstream",
DocRules: &tfbridge.DocRuleInfo{EditRules: editRules},
Config: map[string]*tfbridge.SchemaInfo{
"base_url": {
Default: &tfbridge.DefaultInfo{
Expand Down Expand Up @@ -274,5 +276,24 @@ func Provider() tfbridge.ProviderInfo {
return prov
}

// Docs Edits

// Ensure the text of IssueLabel makes it into the API documentation.
// It contains important information on a courtesy labels import-before-create.
var ensureIssueLabelsContent = tfbridge.DocsEdit{
Path: "*issue_label.html.markdown",
Edit: func(_ string, content []byte) ([]byte, error) {
content = bytes.ReplaceAll(content,
[]byte("Terraform"), []byte("Pulumi"))
return content, nil
},
}

func editRules(defaults []tfbridge.DocsEdit) []tfbridge.DocsEdit {
return append(defaults,
ensureIssueLabelsContent,
)
}

//go:embed cmd/pulumi-resource-github/bridge-metadata.json
var metadata []byte
13 changes: 13 additions & 0 deletions sdk/dotnet/IssueLabel.cs

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

13 changes: 13 additions & 0 deletions sdk/go/github/issueLabel.go

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

13 changes: 13 additions & 0 deletions sdk/java/src/main/java/com/pulumi/github/IssueLabel.java

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

13 changes: 13 additions & 0 deletions sdk/nodejs/issueLabel.ts

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

26 changes: 26 additions & 0 deletions sdk/python/pulumi_github/issue_label.py

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

0 comments on commit efaea17

Please sign in to comment.