Skip to content

Commit

Permalink
Merge a24dec7 into 44e8538
Browse files Browse the repository at this point in the history
  • Loading branch information
komalali committed Sep 16, 2020
2 parents 44e8538 + a24dec7 commit 914bf01
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 34 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ CHANGELOG

## HEAD (Unreleased)

- Refactor schematized types to support enums.
[#266](https://github.com/pulumi/pulumi-terraform-bridge/pull/266)

- Support terraform-plugin-sdk/v2. This is an API breaking change.
[#264](https://github.com/pulumi/pulumi-terraform-bridge/pull/264)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ require (
github.com/mitchellh/mapstructure v1.1.2
github.com/mitchellh/reflectwalk v1.0.1
github.com/pkg/errors v0.9.1
github.com/pulumi/pulumi/pkg/v2 v2.10.0
github.com/pulumi/pulumi/sdk/v2 v2.10.0
github.com/pulumi/pulumi/pkg/v2 v2.10.2-0.20200916204740-92a7d717a4d1
github.com/pulumi/pulumi/sdk/v2 v2.10.2-0.20200916204740-92a7d717a4d1
github.com/spf13/afero v1.2.2
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,11 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/pulumi/pulumi/pkg/v2 v2.10.0 h1:GTUffKvweAzcCZ2Ok44MFY62nT4FY/u+eX8bWlzDs2A=
github.com/pulumi/pulumi/pkg/v2 v2.10.0/go.mod h1:zQWe2D4tYJDeXNzSclqNmP8/SMSKOh8k22AbWg3+mVc=
github.com/pulumi/pulumi/pkg/v2 v2.10.2-0.20200916204740-92a7d717a4d1 h1:6MkruuwuH0SStrTbanQDj002KvmQiiJho8idovsMUgA=
github.com/pulumi/pulumi/pkg/v2 v2.10.2-0.20200916204740-92a7d717a4d1/go.mod h1:zQWe2D4tYJDeXNzSclqNmP8/SMSKOh8k22AbWg3+mVc=
github.com/pulumi/pulumi/sdk/v2 v2.2.1/go.mod h1:QNbWpL4gvf3X0lUFT7TXA2Jo1ff/Ti2l97AyFGYwvW4=
github.com/pulumi/pulumi/sdk/v2 v2.10.0 h1:+BPDjZYGl3AI2hLkLCig1+q7hvo/TAVBLGlzPb0r0kk=
github.com/pulumi/pulumi/sdk/v2 v2.10.0/go.mod h1:x84WPiFiuE+G4kJ5jUYkOxmnQJlWoJaHNeEYdqnCKA4=
github.com/pulumi/pulumi/sdk/v2 v2.10.2-0.20200916204740-92a7d717a4d1 h1:OuuZs684M+C63XqvNjjK6BHn1+tw2/CYzcPNRwH3mNE=
github.com/pulumi/pulumi/sdk/v2 v2.10.2-0.20200916204740-92a7d717a4d1/go.mod h1:EED7KCDOohYIewUppsav5KHTFTmfYGqUFib1uRvYdWQ=
github.com/pulumi/terraform-plugin-sdk/v2 v2.0.0-20200910230100-328eb4ff41df h1:kXSvfAz43o0D0gfxUqVCOP3NrfnGbptJBshVsqZlBqA=
github.com/pulumi/terraform-plugin-sdk/v2 v2.0.0-20200910230100-328eb4ff41df/go.mod h1:pVZLnLuSe/yv0XqTHFPb8xRGWPwgANT77jHeHqjXS5o=
github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM=
Expand Down
48 changes: 24 additions & 24 deletions pkg/tfbridge/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ const (
//
//nolint: lll
type ProviderInfo struct {
P shim.Provider // the TF provider/schema.
Name string // the TF provider name (e.g. terraform-provider-XXXX).
ResourcePrefix string // the prefix on resources the provider exposes, if different to `Name`.
GitHubOrg string // the GitHub org of the provider. Defaults to `terraform-providers`.
Description string // an optional descriptive overview of the package (a default supplied).
Keywords []string // an optional list of keywords to help discovery of this package.
License string // the license, if any, the resulting package has (default is none).
LogoURL string // an optional URL to the logo of the package
Homepage string // the URL to the project homepage.
Repository string // the URL to the project source code repository.
Version string // the version of the provider package.
Config map[string]*SchemaInfo // a map of TF name to config schema overrides.
ExtraConfig map[string]*ConfigInfo // a list of Pulumi-only configuration variables.
Resources map[string]*ResourceInfo // a map of TF name to Pulumi name; standard mangling occurs if no entry.
DataSources map[string]*DataSourceInfo // a map of TF name to Pulumi resource info.
ExtraTypes map[string]pschema.ObjectTypeSpec // a map of Pulumi token to schema type for overlaid types.
PluginDownloadURL string // an optional URL to download the provider binary from.
JavaScript *JavaScriptInfo // optional overlay information for augmented JavaScript code-generation.
Python *PythonInfo // optional overlay information for augmented Python code-generation.
Golang *GolangInfo // optional overlay information for augmented Golang code-generation.
CSharp *CSharpInfo // optional overlay information for augmented C# code-generation.
TFProviderVersion string // the version of the TF provider on which this was based
TFProviderLicense *TFProviderLicense // license that the TF provider is distributed under. Default `MPL 2.0`.
TFProviderModuleVersion string // the Go module version of the provider. Default is unversioned e.g. v1
P shim.Provider // the TF provider/schema.
Name string // the TF provider name (e.g. terraform-provider-XXXX).
ResourcePrefix string // the prefix on resources the provider exposes, if different to `Name`.
GitHubOrg string // the GitHub org of the provider. Defaults to `terraform-providers`.
Description string // an optional descriptive overview of the package (a default supplied).
Keywords []string // an optional list of keywords to help discovery of this package.
License string // the license, if any, the resulting package has (default is none).
LogoURL string // an optional URL to the logo of the package
Homepage string // the URL to the project homepage.
Repository string // the URL to the project source code repository.
Version string // the version of the provider package.
Config map[string]*SchemaInfo // a map of TF name to config schema overrides.
ExtraConfig map[string]*ConfigInfo // a list of Pulumi-only configuration variables.
Resources map[string]*ResourceInfo // a map of TF name to Pulumi name; standard mangling occurs if no entry.
DataSources map[string]*DataSourceInfo // a map of TF name to Pulumi resource info.
ExtraTypes map[string]pschema.ComplexTypeSpec // a map of Pulumi token to schema type for overlaid types.
PluginDownloadURL string // an optional URL to download the provider binary from.
JavaScript *JavaScriptInfo // optional overlay information for augmented JavaScript code-generation.
Python *PythonInfo // optional overlay information for augmented Python code-generation.
Golang *GolangInfo // optional overlay information for augmented Golang code-generation.
CSharp *CSharpInfo // optional overlay information for augmented C# code-generation.
TFProviderVersion string // the version of the TF provider on which this was based
TFProviderLicense *TFProviderLicense // license that the TF provider is distributed under. Default `MPL 2.0`.
TFProviderModuleVersion string // the Go module version of the provider. Default is unversioned e.g. v1

PreConfigureCallback PreConfigureCallback // a provider-specific callback to invoke prior to TF Configure
}
Expand Down
13 changes: 9 additions & 4 deletions pkg/tfgen/generate_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (g *schemaGenerator) genPackageSpec(pack *pkg) (pschema.PackageSpec, error)
PluginDownloadURL: g.info.PluginDownloadURL,
Resources: map[string]pschema.ResourceSpec{},
Functions: map[string]pschema.FunctionSpec{},
Types: map[string]pschema.ObjectTypeSpec{},
Types: map[string]pschema.ComplexTypeSpec{},
Language: map[string]json.RawMessage{},

Meta: &pschema.MetadataSpec{
Expand All @@ -219,7 +219,9 @@ func (g *schemaGenerator) genPackageSpec(pack *pkg) (pschema.PackageSpec, error)
// Generate nested types.
for _, t := range gatherSchemaNestedTypesForModule(mod) {
tok, ts := g.genObjectType(mod.name, t)
spec.Types[tok] = ts
spec.Types[tok] = pschema.ComplexTypeSpec{
ObjectTypeSpec: ts,
}
}

// Enumerate each module member, in the order presented to us, and do the right thing.
Expand All @@ -243,7 +245,9 @@ func (g *schemaGenerator) genPackageSpec(pack *pkg) (pschema.PackageSpec, error)
if pack.provider != nil {
for _, t := range gatherSchemaNestedTypesForMember(pack.provider) {
tok, ts := g.genObjectType("index", t)
spec.Types[tok] = ts
spec.Types[tok] = pschema.ComplexTypeSpec{
ObjectTypeSpec: ts,
}
}
spec.Provider = g.genResourceType("index", pack.provider)
}
Expand Down Expand Up @@ -668,7 +672,8 @@ func (g *generator) convertExamplesInSchema(spec pschema.PackageSpec) pschema.Pa
spec.Config.Variables[name] = g.convertExamplesInPropertySpec(variable)
}
for token, object := range spec.Types {
spec.Types[token] = g.convertExamplesInObjectSpec(object)
object.ObjectTypeSpec = g.convertExamplesInObjectSpec(object.ObjectTypeSpec)
spec.Types[token] = object
}
spec.Provider = g.convertExamplesInResourceSpec(spec.Provider)
for token, resource := range spec.Resources {
Expand Down

0 comments on commit 914bf01

Please sign in to comment.