diff --git a/docs/generating-a-provider.md b/docs/generating-a-provider.md index 85126a47..cd6ca35b 100644 --- a/docs/generating-a-provider.md +++ b/docs/generating-a-provider.md @@ -80,14 +80,14 @@ be quite similar for any other Terraform provider. ``` 6. Before generating all resources that the provider has, let's go step by step - and only start with generating `github_repository` and `github_branch` - resources. + and only start with generating CRDs for [github_repository] and + [github_branch] Terraform resources. To limit the resources to be generated, we need to provide an include list option with `tjconfig.WithIncludeList` in file `config/provider.go`: ```go - pc := tjconfig.NewProvider(resourceMap, resourcePrefix, modulePath, + pc := tjconfig.NewProviderWithSchema([]byte(providerSchema), resourcePrefix, modulePath, tjconfig.WithDefaultResourceFn(defaultResourceFn), tjconfig.WithIncludeList([]string{ "github_repository$", @@ -339,5 +339,7 @@ Now let's test our generated resources. [Terraform GitHub provider]: https://registry.terraform.io/providers/integrations/github/latest/docs [provider-jet-template]: https://github.com/crossplane-contrib/provider-jet-template [Terraform documentation for provider configuration]: https://registry.terraform.io/providers/integrations/github/latest/docs#argument-reference +[github_repository]: https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository +[github_branch]: https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch [this line in controller Dockerfile]: https://github.com/crossplane-contrib/provider-jet-template/blob/d9a793dd8a304f09bb2e9694c47c1bade1b6b057/cluster/images/provider-jet-template-controller/Dockerfile#L18-L25 [terraform-plugin-sdk]: https://github.com/hashicorp/terraform-plugin-sdk diff --git a/pkg/config/provider.go b/pkg/config/provider.go index d4cf42a5..d1ab5252 100644 --- a/pkg/config/provider.go +++ b/pkg/config/provider.go @@ -149,9 +149,9 @@ func WithDefaultResourceFn(f DefaultResourceFn) ProviderOption { // NewProviderWithSchema builds and returns a new Provider from provider // tfjson schema, that is generated using Terraform CLI with: // `terraform providers schema --json` -func NewProviderWithSchema(schema string, prefix string, modulePath string, opts ...ProviderOption) *Provider { +func NewProviderWithSchema(schema []byte, prefix string, modulePath string, opts ...ProviderOption) *Provider { ps := tfjson.ProviderSchemas{} - if err := ps.UnmarshalJSON([]byte(schema)); err != nil { + if err := ps.UnmarshalJSON(schema); err != nil { panic(err) } if len(ps.Schemas) != 1 {