-
Notifications
You must be signed in to change notification settings - Fork 9
/
provider.go
78 lines (70 loc) · 3.2 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package github
import (
"reflect"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// The provider type for the github package. By default, resources use package-wide configuration
// settings, however an explicit `Provider` instance may be created and passed during resource
// construction to achieve fine-grained programmatic control over provider settings. See the
// [documentation](https://www.pulumi.com/docs/reference/programming-model/#providers) for more information.
type Provider struct {
pulumi.ProviderResourceState
}
// NewProvider registers a new resource with the given unique name, arguments, and options.
func NewProvider(ctx *pulumi.Context,
name string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error) {
if args == nil {
args = &ProviderArgs{}
}
if args.BaseUrl == nil {
args.BaseUrl = pulumi.StringPtr(getEnvOrDefault("https://api.github.com/", nil, "GITHUB_BASE_URL").(string))
}
if args.Organization == nil {
args.Organization = pulumi.StringPtr(getEnvOrDefault("", nil, "GITHUB_ORGANIZATION").(string))
}
if args.Token == nil {
args.Token = pulumi.StringPtr(getEnvOrDefault("", nil, "GITHUB_TOKEN").(string))
}
var resource Provider
err := ctx.RegisterResource("pulumi:providers:github", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
type providerArgs struct {
// Authenticate without a token. When `anonymous`is true, the provider will not be able to access resourcesthat require
// authentication.
Anonymous *bool `pulumi:"anonymous"`
// The GitHub Base API URL
BaseUrl *string `pulumi:"baseUrl"`
// Run outside an organization. When `individual`is true, the provider will run outside the scope of anorganization.
Individual *bool `pulumi:"individual"`
// Whether server should be accessed without verifying the TLS certificate.
Insecure *bool `pulumi:"insecure"`
// The GitHub organization name to manage. If `individual` is false, `organization` is required.
Organization *string `pulumi:"organization"`
// The OAuth token used to connect to GitHub. If `anonymous` is false, `token` is required.
Token *string `pulumi:"token"`
}
// The set of arguments for constructing a Provider resource.
type ProviderArgs struct {
// Authenticate without a token. When `anonymous`is true, the provider will not be able to access resourcesthat require
// authentication.
Anonymous pulumi.BoolPtrInput
// The GitHub Base API URL
BaseUrl pulumi.StringPtrInput
// Run outside an organization. When `individual`is true, the provider will run outside the scope of anorganization.
Individual pulumi.BoolPtrInput
// Whether server should be accessed without verifying the TLS certificate.
Insecure pulumi.BoolPtrInput
// The GitHub organization name to manage. If `individual` is false, `organization` is required.
Organization pulumi.StringPtrInput
// The OAuth token used to connect to GitHub. If `anonymous` is false, `token` is required.
Token pulumi.StringPtrInput
}
func (ProviderArgs) ElementType() reflect.Type {
return reflect.TypeOf((*providerArgs)(nil)).Elem()
}