/
provider.go
79 lines (69 loc) · 2.66 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! ***
// nolint: lll
package mysql
import (
"reflect"
"github.com/pulumi/pulumi/sdk/go/pulumi"
)
// The provider type for the mysql 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.
//
// > This content is derived from https://github.com/terraform-providers/terraform-provider-mysql/blob/master/website/docs/index.html.markdown.
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.Endpoint == nil {
args.Endpoint = pulumi.StringPtr(getEnvOrDefault("", nil, "MYSQL_ENDPOINT").(string))
}
if args.Password == nil {
args.Password = pulumi.StringPtr(getEnvOrDefault("", nil, "MYSQL_PASSWORD").(string))
}
if args.Proxy == nil {
args.Proxy = pulumi.StringPtr(getEnvOrDefault("", nil, "ALL_PROXY", "all_proxy").(string))
}
if args.Tls == nil {
args.Tls = pulumi.StringPtr(getEnvOrDefault("false", nil, "MYSQL_TLS_CONFIG").(string))
}
if args.Username == nil {
args.Username = pulumi.StringPtr(getEnvOrDefault("", nil, "MYSQL_USERNAME").(string))
}
var resource Provider
err := ctx.RegisterResource("pulumi:providers:mysql", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
type providerArgs struct {
AuthenticationPlugin *string `pulumi:"authenticationPlugin"`
Endpoint *string `pulumi:"endpoint"`
MaxConnLifetimeSec *int `pulumi:"maxConnLifetimeSec"`
MaxOpenConns *int `pulumi:"maxOpenConns"`
Password *string `pulumi:"password"`
Proxy *string `pulumi:"proxy"`
Tls *string `pulumi:"tls"`
Username *string `pulumi:"username"`
}
// The set of arguments for constructing a Provider resource.
type ProviderArgs struct {
AuthenticationPlugin pulumi.StringPtrInput
Endpoint pulumi.StringPtrInput
MaxConnLifetimeSec pulumi.IntPtrInput
MaxOpenConns pulumi.IntPtrInput
Password pulumi.StringPtrInput
Proxy pulumi.StringPtrInput
Tls pulumi.StringPtrInput
Username pulumi.StringPtrInput
}
func (ProviderArgs) ElementType() reflect.Type {
return reflect.TypeOf((*providerArgs)(nil)).Elem()
}