Skip to content

Commit

Permalink
ref: rename scaffolding to openai
Browse files Browse the repository at this point in the history
  • Loading branch information
jianyuan committed May 21, 2024
1 parent 051d3be commit 476f17f
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 497 deletions.
21 changes: 0 additions & 21 deletions .copywrite.hcl

This file was deleted.

375 changes: 0 additions & 375 deletions LICENSE

This file was deleted.

18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
# Terraform Provider Scaffolding (Terraform Plugin Framework)
# Terraform Provider OpenAI

_This template repository is built on the [Terraform Plugin Framework](https://github.com/hashicorp/terraform-plugin-framework). The template repository built on the [Terraform Plugin SDK](https://github.com/hashicorp/terraform-plugin-sdk) can be found at [terraform-provider-scaffolding](https://github.com/hashicorp/terraform-provider-scaffolding). See [Which SDK Should I Use?](https://developer.hashicorp.com/terraform/plugin/framework-benefits) in the Terraform documentation for additional information._

This repository is a *template* for a [Terraform](https://www.terraform.io) provider. It is intended as a starting point for creating Terraform providers, containing:

- A resource and a data source (`internal/provider/`),
- Examples (`examples/`) and generated documentation (`docs/`),
- Miscellaneous meta files.

These files contain boilerplate code that you will need to edit to create your own Terraform provider. Tutorials for creating Terraform providers can be found on the [HashiCorp Developer](https://developer.hashicorp.com/terraform/tutorials/providers-plugin-framework) platform. _Terraform Plugin Framework specific guides are titled accordingly._

Please see the [GitHub template repository documentation](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) for how to create a new repository from this template on GitHub.

Once you've written your provider, you'll want to [publish it on the Terraform Registry](https://developer.hashicorp.com/terraform/registry/providers/publishing) so that others can use it.
Unofficial Terraform provider for OpenAI.

## Requirements

Expand Down Expand Up @@ -57,7 +45,7 @@ To generate or update documentation, run `go generate`.

In order to run the full suite of Acceptance tests, run `make testacc`.

*Note:* Acceptance tests create real resources, and often cost money to run.
_Note:_ Acceptance tests create real resources, and often cost money to run.

```shell
make testacc
Expand Down
10 changes: 2 additions & 8 deletions docs/data-sources/example.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "scaffolding_example Data Source - scaffolding"
page_title: "openai_example Data Source - terraform-provider-openai"
subcategory: ""
description: |-
Example data source
---

# scaffolding_example (Data Source)
# openai_example (Data Source)

Example data source

## Example Usage

```terraform
data "scaffolding_example" "example" {
configurable_attribute = "some-value"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
2 changes: 1 addition & 1 deletion docs/functions/example.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "example function - scaffolding"
page_title: "example function - terraform-provider-openai"
subcategory: ""
description: |-
Example function
Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "scaffolding Provider"
page_title: "openai Provider"
subcategory: ""
description: |-
---

# scaffolding Provider
# openai Provider



## Example Usage

```terraform
provider "scaffolding" {
provider "openai" {
# example configuration here
}
```
Expand Down
10 changes: 2 additions & 8 deletions docs/resources/example.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "scaffolding_example Resource - scaffolding"
page_title: "openai_example Resource - terraform-provider-openai"
subcategory: ""
description: |-
Example resource
---

# scaffolding_example (Resource)
# openai_example (Resource)

Example resource

## Example Usage

```terraform
resource "scaffolding_example" "example" {
configurable_attribute = "some-value"
}
```

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
2 changes: 1 addition & 1 deletion examples/data-sources/scaffolding_example/data-source.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
data "scaffolding_example" "example" {
data "openai_example" "example" {
configurable_attribute = "some-value"
}
2 changes: 1 addition & 1 deletion examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
provider "scaffolding" {
provider "openai" {
# example configuration here
}
2 changes: 1 addition & 1 deletion examples/resources/scaffolding_example/resource.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
resource "scaffolding_example" "example" {
resource "openai_example" "example" {
configurable_attribute = "some-value"
}
3 changes: 0 additions & 3 deletions internal/provider/example_data_source.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand Down
7 changes: 2 additions & 5 deletions internal/provider/example_data_source_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand All @@ -18,15 +15,15 @@ func TestAccExampleDataSource(t *testing.T) {
{
Config: testAccExampleDataSourceConfig,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.scaffolding_example.test", "id", "example-id"),
resource.TestCheckResourceAttr("data.openai_example.test", "id", "example-id"),
),
},
},
})
}

const testAccExampleDataSourceConfig = `
data "scaffolding_example" "test" {
data "openai_example" "test" {
configurable_attribute = "example"
}
`
3 changes: 0 additions & 3 deletions internal/provider/example_function.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand Down
9 changes: 3 additions & 6 deletions internal/provider/example_function_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand All @@ -22,7 +19,7 @@ func TestExampleFunction_Known(t *testing.T) {
{
Config: `
output "test" {
value = provider::scaffolding::example("testvalue")
value = provider::openai::example("testvalue")
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
Expand All @@ -43,7 +40,7 @@ func TestExampleFunction_Null(t *testing.T) {
{
Config: `
output "test" {
value = provider::scaffolding::example(null)
value = provider::openai::example(null)
}
`,
// The parameter does not enable AllowNullValue
Expand All @@ -67,7 +64,7 @@ func TestExampleFunction_Unknown(t *testing.T) {
}
output "test" {
value = provider::scaffolding::example(terraform_data.test.output)
value = provider::openai::example(terraform_data.test.output)
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
Expand Down
3 changes: 0 additions & 3 deletions internal/provider/example_resource.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand Down
15 changes: 6 additions & 9 deletions internal/provider/example_resource_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand All @@ -19,14 +16,14 @@ func TestAccExampleResource(t *testing.T) {
{
Config: testAccExampleResourceConfig("one"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("scaffolding_example.test", "configurable_attribute", "one"),
resource.TestCheckResourceAttr("scaffolding_example.test", "defaulted", "example value when not configured"),
resource.TestCheckResourceAttr("scaffolding_example.test", "id", "example-id"),
resource.TestCheckResourceAttr("openai_example.test", "configurable_attribute", "one"),
resource.TestCheckResourceAttr("openai_example.test", "defaulted", "example value when not configured"),
resource.TestCheckResourceAttr("openai_example.test", "id", "example-id"),
),
},
// ImportState testing
{
ResourceName: "scaffolding_example.test",
ResourceName: "openai_example.test",
ImportState: true,
ImportStateVerify: true,
// This is not normally necessary, but is here because this
Expand All @@ -39,7 +36,7 @@ func TestAccExampleResource(t *testing.T) {
{
Config: testAccExampleResourceConfig("two"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("scaffolding_example.test", "configurable_attribute", "two"),
resource.TestCheckResourceAttr("openai_example.test", "configurable_attribute", "two"),
),
},
// Delete testing automatically occurs in TestCase
Expand All @@ -49,7 +46,7 @@ func TestAccExampleResource(t *testing.T) {

func testAccExampleResourceConfig(configurableAttribute string) string {
return fmt.Sprintf(`
resource "scaffolding_example" "test" {
resource "openai_example" "test" {
configurable_attribute = %[1]q
}
`, configurableAttribute)
Expand Down
35 changes: 16 additions & 19 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand All @@ -15,29 +12,29 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
)

// Ensure ScaffoldingProvider satisfies various provider interfaces.
var _ provider.Provider = &ScaffoldingProvider{}
var _ provider.ProviderWithFunctions = &ScaffoldingProvider{}
// Ensure OpenAIProvider satisfies various provider interfaces.
var _ provider.Provider = &OpenAIProvider{}
var _ provider.ProviderWithFunctions = &OpenAIProvider{}

// ScaffoldingProvider defines the provider implementation.
type ScaffoldingProvider struct {
// OpenAIProvider defines the provider implementation.
type OpenAIProvider struct {
// version is set to the provider version on release, "dev" when the
// provider is built and ran locally, and "test" when running acceptance
// testing.
version string
}

// ScaffoldingProviderModel describes the provider data model.
type ScaffoldingProviderModel struct {
// OpenAIProviderModel describes the provider data model.
type OpenAIProviderModel struct {
Endpoint types.String `tfsdk:"endpoint"`
}

func (p *ScaffoldingProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) {
resp.TypeName = "scaffolding"
func (p *OpenAIProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) {
resp.TypeName = "openai"
resp.Version = p.version
}

func (p *ScaffoldingProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) {
func (p *OpenAIProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"endpoint": schema.StringAttribute{
Expand All @@ -48,8 +45,8 @@ func (p *ScaffoldingProvider) Schema(ctx context.Context, req provider.SchemaReq
}
}

func (p *ScaffoldingProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
var data ScaffoldingProviderModel
func (p *OpenAIProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
var data OpenAIProviderModel

resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)

Expand All @@ -66,27 +63,27 @@ func (p *ScaffoldingProvider) Configure(ctx context.Context, req provider.Config
resp.ResourceData = client
}

func (p *ScaffoldingProvider) Resources(ctx context.Context) []func() resource.Resource {
func (p *OpenAIProvider) Resources(ctx context.Context) []func() resource.Resource {
return []func() resource.Resource{
NewExampleResource,
}
}

func (p *ScaffoldingProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
func (p *OpenAIProvider) DataSources(ctx context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
NewExampleDataSource,
}
}

func (p *ScaffoldingProvider) Functions(ctx context.Context) []func() function.Function {
func (p *OpenAIProvider) Functions(ctx context.Context) []func() function.Function {
return []func() function.Function{
NewExampleFunction,
}
}

func New(version string) func() provider.Provider {
return func() provider.Provider {
return &ScaffoldingProvider{
return &OpenAIProvider{
version: version,
}
}
Expand Down
5 changes: 1 addition & 4 deletions internal/provider/provider_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package provider

import (
Expand All @@ -15,7 +12,7 @@ import (
// CLI command executed to create a provider server to which the CLI can
// reattach.
var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
"scaffolding": providerserver.NewProtocol6WithError(New("test")()),
"openai": providerserver.NewProtocol6WithError(New("test")()),
}

func testAccPreCheck(t *testing.T) {
Expand Down
Loading

0 comments on commit 476f17f

Please sign in to comment.