mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
* provider/github: add repository_webhook resource `repository_webhook` can be used to manage webhooks for repositories. It is currently limited to organization repositories only. The changeset includes both documentation and tests. The tests are green: ``` make testacc TEST=./builtin/providers/github TESTARGS='-run=TestAccGithubRepositoryWebhook_basic' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/03/21 16:20:07 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/github -v -run=TestAccGithubRepositoryWebhook_basic -timeout 120m === RUN TestAccGithubRepositoryWebhook_basic --- PASS: TestAccGithubRepositoryWebhook_basic (5.10s) PASS ok github.com/hashicorp/terraform/builtin/providers/github 5.113s ``` * provider/github: add github_organization_webhook the `github_organization_webhook` resource is similar to the `github_repository_webhook` resource, but it manages webhooks for an organization. the tests are green: ``` make testacc TEST=./builtin/providers/github TESTARGS='-run=TestAccGithubOrganizationWebhook' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/03/21 17:23:33 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/github -v -run=TestAccGithubOrganizationWebhook -timeout 120m === RUN TestAccGithubOrganizationWebhook_basic --- PASS: TestAccGithubOrganizationWebhook_basic (2.09s) PASS ok github.com/hashicorp/terraform/builtin/providers/github 2.109s ```
71 lines
2.1 KiB
Go
71 lines
2.1 KiB
Go
package github
|
|
|
|
import (
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
"github.com/hashicorp/terraform/terraform"
|
|
)
|
|
|
|
// Provider returns a terraform.ResourceProvider.
|
|
func Provider() terraform.ResourceProvider {
|
|
|
|
// The actual provider
|
|
return &schema.Provider{
|
|
Schema: map[string]*schema.Schema{
|
|
"token": &schema.Schema{
|
|
Type: schema.TypeString,
|
|
Required: true,
|
|
DefaultFunc: schema.EnvDefaultFunc("GITHUB_TOKEN", nil),
|
|
Description: descriptions["token"],
|
|
},
|
|
"organization": &schema.Schema{
|
|
Type: schema.TypeString,
|
|
Required: true,
|
|
DefaultFunc: schema.EnvDefaultFunc("GITHUB_ORGANIZATION", nil),
|
|
Description: descriptions["organization"],
|
|
},
|
|
"base_url": &schema.Schema{
|
|
Type: schema.TypeString,
|
|
Optional: true,
|
|
DefaultFunc: schema.EnvDefaultFunc("GITHUB_BASE_URL", ""),
|
|
Description: descriptions["base_url"],
|
|
},
|
|
},
|
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
|
"github_team": resourceGithubTeam(),
|
|
"github_team_membership": resourceGithubTeamMembership(),
|
|
"github_team_repository": resourceGithubTeamRepository(),
|
|
"github_membership": resourceGithubMembership(),
|
|
"github_repository": resourceGithubRepository(),
|
|
"github_repository_webhook": resourceGithubRepositoryWebhook(),
|
|
"github_organization_webhook": resourceGithubOrganizationWebhook(),
|
|
"github_repository_collaborator": resourceGithubRepositoryCollaborator(),
|
|
"github_issue_label": resourceGithubIssueLabel(),
|
|
},
|
|
|
|
ConfigureFunc: providerConfigure,
|
|
}
|
|
}
|
|
|
|
var descriptions map[string]string
|
|
|
|
func init() {
|
|
descriptions = map[string]string{
|
|
"token": "The OAuth token used to connect to GitHub.",
|
|
|
|
"organization": "The GitHub organization name to manage.",
|
|
|
|
"base_url": "The GitHub Base API URL",
|
|
}
|
|
}
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
config := Config{
|
|
Token: d.Get("token").(string),
|
|
Organization: d.Get("organization").(string),
|
|
BaseURL: d.Get("base_url").(string),
|
|
}
|
|
|
|
return config.Client()
|
|
}
|