generated from pulumi/pulumi-tf-provider-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
resources.go
170 lines (158 loc) · 6.77 KB
/
resources.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
// Copyright 2016-2023, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package onepassword
import (
"fmt"
"path"
// Allow embedding bridge-metadata.json in the provider.
_ "embed"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge"
"github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge/tokens"
shim "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim"
shimv2 "github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfshim/sdk-v2"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
// Replace this provider with the provider you are bridging.
onepassword "github.com/1Password/terraform-provider-onepassword/onepassword"
"github.com/1Password/pulumi-onepassword/provider/pkg/version"
)
// all of the token components used below.
const (
// This variable controls the default name of the package in the package
// registries for nodejs and python:
mainPkg = "onepassword"
// modules:
mainMod = "index" // the onepassword module
)
// preConfigureCallback is called before the providerConfigure function of the underlying provider.
// It should validate that the provider can be configured, and provide actionable errors in the case
// it cannot be. Configuration variables can be read from `vars` using the `stringValue` function -
// for example `stringValue(vars, "accessKey")`.
func preConfigureCallback(resource.PropertyMap, shim.ResourceConfig) error {
return nil
}
//go:embed cmd/pulumi-resource-onepassword/bridge-metadata.json
var metadata []byte
// Provider returns additional overlaid schema and metadata associated with the provider..
func Provider() tfbridge.ProviderInfo {
// Create a Pulumi provider mapping
prov := tfbridge.ProviderInfo{
// Instantiate the Terraform provider
P: shimv2.NewProvider(onepassword.Provider()),
Name: "onepassword",
// DisplayName is a way to be able to change the casing of the provider
// name when being displayed on the Pulumi registry
DisplayName: "",
// The default publisher for all packages is Pulumi.
// Change this to your personal name (or a company name) that you
// would like to be shown in the Pulumi Registry if this package is published
// there.
Publisher: "Pulumi",
// LogoURL is optional but useful to help identify your package in the Pulumi Registry
// if this package is published there.
//
// You may host a logo on a domain you control or add an SVG logo for your package
// in your repository and use the raw content URL for that file as your logo URL.
LogoURL: "",
// PluginDownloadURL is an optional URL used to download the Provider
// for use in Pulumi programs
// e.g github://api.github.com/org/pulumi-provider-name
PluginDownloadURL: "github://api.github.com/1Password/pulumi-onepassword",
Description: "Use the 1Password Pulumi provider to access and manage items in your 1Password vaults.",
// category/cloud tag helps with categorizing the package in the Pulumi Registry.
// For all available categories, see `Keywords` in
// https://www.pulumi.com/docs/guides/pulumi-packages/schema/#package.
Keywords: []string{"pulumi", "onepassword", "1Password", "category/cloud"},
License: "Apache-2.0",
Homepage: "https://www.pulumi.com",
Repository: "https://github.com/1Password/pulumi-onepassword",
// The GitHub Org for the provider - defaults to `terraform-providers`. Note that this
// should match the TF provider module's require directive, not any replace directives.
GitHubOrg: "1Password",
Version: version.Version,
MetadataInfo: tfbridge.NewProviderMetadata(metadata),
Config: map[string]*tfbridge.SchemaInfo{
// Add any required configuration here, or remove the example below if
// no additional points are required.
// "region": {
// Type: tfbridge.MakeType("region", "Region"),
// Default: &tfbridge.DefaultInfo{
// EnvVars: []string{"AWS_REGION", "AWS_DEFAULT_REGION"},
// },
// },
},
PreConfigureCallback: preConfigureCallback,
Resources: map[string]*tfbridge.ResourceInfo{
// Map each resource in the Terraform provider to a Pulumi type. Two examples
// are below - the single line form is the common case. The multi-line form is
// needed only if you wish to override types or other default options.
//
// "aws_iam_role": {Tok: tfbridge.MakeResource(mainPkg, mainMod, "IamRole")}
//
// "aws_acm_certificate": {
// Tok: tfbridge.MakeResource(mainPkg, mainMod, "Certificate"),
// Fields: map[string]*tfbridge.SchemaInfo{
// "tags": {Type: tfbridge.MakeType(mainPkg, "Tags")},
// },
// },
},
DataSources: map[string]*tfbridge.DataSourceInfo{
// Map each resource in the Terraform provider to a Pulumi function. An example
// is below.
// "aws_ami": {Tok: tfbridge.MakeDataSource(mainPkg, mainMod, "getAmi")},
},
JavaScript: &tfbridge.JavaScriptInfo{
// List any npm dependencies and their versions
Dependencies: map[string]string{
"@pulumi/pulumi": "^3.0.0",
},
DevDependencies: map[string]string{
"@types/node": "^10.0.0", // so we can access strongly typed node definitions.
"@types/mime": "^2.0.0",
},
// See the documentation for tfbridge.OverlayInfo for how to lay out this
// section, or refer to the AWS provider. Delete this section if there are
// no overlay files.
//Overlay: &tfbridge.OverlayInfo{},
},
Python: &tfbridge.PythonInfo{
// List any Python dependencies and their version ranges
Requires: map[string]string{
"pulumi": ">=3.0.0,<4.0.0",
},
},
Golang: &tfbridge.GolangInfo{
ImportBasePath: path.Join(
fmt.Sprintf("github.com/pulumi/pulumi-%[1]s/sdk/", mainPkg),
tfbridge.GetModuleMajorVersion(version.Version),
"go",
mainPkg,
),
GenerateResourceContainerTypes: true,
},
CSharp: &tfbridge.CSharpInfo{
PackageReferences: map[string]string{
"Pulumi": "3.*",
},
},
}
// These are new API's that you may opt to use to automatically compute resource
// tokens, and apply auto aliasing for full backwards compatibility. For more
// information, please reference:
// https://pkg.go.dev/github.com/pulumi/pulumi-terraform-bridge/v3/pkg/tfbridge#ProviderInfo.ComputeTokens
prov.MustComputeTokens(tokens.SingleModule("onepassword_", mainMod,
tokens.MakeStandard(mainPkg)))
prov.MustApplyAutoAliases()
prov.SetAutonaming(255, "-")
return prov
}