Skip to content

Commit

Permalink
Transmute to Aria provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Fischer David (DIN) committed May 30, 2024
1 parent 37b9fa0 commit 9a741af
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 140 deletions.
21 changes: 0 additions & 21 deletions .copywrite.hcl

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Code of Conduct

HashiCorp Community Guidelines apply to you when interacting with the community here on GitHub and contributing code.
State of Geneva's Community Guidelines apply to you when interacting with the community here on GitHub and contributing code.

Please read the full text at https://www.hashicorp.com/community-guidelines
TODO
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.0 (Unreleased)
# Release v0.1.0 (Unreleased)

FEATURES:
## Major compatibility breaks
## Minor compatibilty breaks
## Migrations
## Features
## Fix and enhancements
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021 HashiCorp, Inc.
Copyright (c) 2024 State of Geneva (Switzerland)

Mozilla Public License Version 2.0
==================================
Expand Down
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Terraform Provider Scaffolding (Terraform Plugin Framework)
# Terraform Provider Aria (Terraform Plugin Framework)

_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 is the [Terraform](https://www.terraform.io) provider for VMWare's Aria Automation Platform.

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:
We'll [publish it on the Terraform Registry](https://developer.hashicorp.com/terraform/registry/providers/publishing) so that others can use it.

- A resource and a data source (`internal/provider/`),
- Examples (`examples/`) and generated documentation (`docs/`),
- Miscellaneous meta files.
It has been developped by the CSC Team from the IT department of the State of Geneva (Switzerland).

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 be aware that Broadcom is not responsible neither involved on this project.

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.
_This provider is built on the [Terraform Plugin Framework](https://github.com/hashicorp/terraform-plugin-framework). See [Which SDK Should I Use?](https://developer.hashicorp.com/terraform/plugin/framework-benefits) in the Terraform documentation for additional information._

## Requirements

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: "aria_example Data Source - terraform-provider-aria"
subcategory: ""
description: |-
Example data source
---

# scaffolding_example (Data Source)
# aria_example (Data Source)

Example data source

## Example Usage

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

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
26 changes: 0 additions & 26 deletions docs/functions/example.md

This file was deleted.

10 changes: 2 additions & 8 deletions docs/index.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 Provider"
page_title: "aria Provider"
subcategory: ""
description: |-
---

# scaffolding Provider
# aria Provider



## Example Usage

```terraform
provider "scaffolding" {
# example configuration here
}
```

<!-- schema generated by tfplugindocs -->
## Schema
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: "aria_example Resource - terraform-provider-aria"
subcategory: ""
description: |-
Example resource
---

# scaffolding_example (Resource)
# aria_example (Resource)

Example resource

## Example Usage

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

<!-- schema generated by tfplugindocs -->
## Schema
Expand Down
9 changes: 0 additions & 9 deletions examples/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions examples/data-sources/scaffolding_example/data-source.tf

This file was deleted.

3 changes: 0 additions & 3 deletions examples/provider/provider.tf

This file was deleted.

3 changes: 0 additions & 3 deletions examples/resources/scaffolding_example/resource.tf

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/hashicorp/terraform-provider-scaffolding-framework
module github.com/davidfischer-ch/terraform-provider-aria

go 1.21

Expand Down
4 changes: 2 additions & 2 deletions internal/provider/example_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ func TestAccExampleDataSource(t *testing.T) {
{
Config: testAccExampleDataSourceConfig,
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("data.scaffolding_example.test", "id", "example-id"),
resource.TestCheckResourceAttr("data.aria_example.test", "id", "example-id"),
),
},
},
})
}

const testAccExampleDataSourceConfig = `
data "scaffolding_example" "test" {
data "aria_example" "test" {
configurable_attribute = "example"
}
`
6 changes: 3 additions & 3 deletions internal/provider/example_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestExampleFunction_Known(t *testing.T) {
{
Config: `
output "test" {
value = provider::scaffolding::example("testvalue")
value = provider::aria::example("testvalue")
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
Expand All @@ -42,7 +42,7 @@ func TestExampleFunction_Null(t *testing.T) {
{
Config: `
output "test" {
value = provider::scaffolding::example(null)
value = provider::aria::example(null)
}
`,
// The parameter does not enable AllowNullValue
Expand All @@ -66,7 +66,7 @@ func TestExampleFunction_Unknown(t *testing.T) {
}
output "test" {
value = provider::scaffolding::example(terraform_data.test.output)
value = provider::aria::example(terraform_data.test.output)
}
`,
Check: resource.ComposeAggregateTestCheckFunc(
Expand Down
12 changes: 6 additions & 6 deletions internal/provider/example_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,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("aria_example.test", "configurable_attribute", "one"),
resource.TestCheckResourceAttr("aria_example.test", "defaulted", "example value when not configured"),
resource.TestCheckResourceAttr("aria_example.test", "id", "example-id"),
),
},
// ImportState testing
{
ResourceName: "scaffolding_example.test",
ResourceName: "aria_example.test",
ImportState: true,
ImportStateVerify: true,
// This is not normally necessary, but is here because this
Expand All @@ -39,7 +39,7 @@ func TestAccExampleResource(t *testing.T) {
{
Config: testAccExampleResourceConfig("two"),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("scaffolding_example.test", "configurable_attribute", "two"),
resource.TestCheckResourceAttr("aria_example.test", "configurable_attribute", "two"),
),
},
// Delete testing automatically occurs in TestCase
Expand All @@ -49,7 +49,7 @@ func TestAccExampleResource(t *testing.T) {

func testAccExampleResourceConfig(configurableAttribute string) string {
return fmt.Sprintf(`
resource "scaffolding_example" "test" {
resource "aria_example" "test" {
configurable_attribute = %[1]q
}
`, configurableAttribute)
Expand Down
34 changes: 17 additions & 17 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) HashiCorp, Inc.
// Copyright (c) State of Geneva (Switzerland)
// SPDX-License-Identifier: MPL-2.0

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

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

// ScaffoldingProvider defines the provider implementation.
type ScaffoldingProvider struct {
// AriaProvider defines the provider implementation.
type AriaProvider 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 {
// AriaProviderModel describes the provider data model.
type AriaProviderModel struct {
Endpoint types.String `tfsdk:"endpoint"`
}

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

func (p *ScaffoldingProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) {
func (p *AriaProvider) 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 +48,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 *AriaProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
var data AriaProviderModel

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

Expand All @@ -66,27 +66,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 *AriaProvider) Resources(ctx context.Context) []func() resource.Resource {
return []func() resource.Resource{
NewExampleResource,
}
}

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

func (p *ScaffoldingProvider) Functions(ctx context.Context) []func() function.Function {
func (p *AriaProvider) 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 &AriaProvider{
version: version,
}
}
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/provider_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) HashiCorp, Inc.
// Copyright (c) State of Geneva (Switzerland)
// SPDX-License-Identifier: MPL-2.0

package provider
Expand All @@ -15,7 +15,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")()),
"aria": providerserver.NewProtocol6WithError(New("test")()),
}

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

0 comments on commit 9a741af

Please sign in to comment.