From 9a741afb10048f2cbdca9924493c5891d3d668aa Mon Sep 17 00:00:00 2001 From: "Fischer David (DIN)" Date: Thu, 30 May 2024 13:57:20 +0200 Subject: [PATCH] Transmute to Aria provider --- .copywrite.hcl | 21 ------------ .github/{CODEOWNERS => CODEOWNERS_disabled} | 0 .github/CODE_OF_CONDUCT.md | 4 +-- CHANGELOG.md | 8 +++-- LICENSE | 2 +- README.md | 16 ++++----- docs/data-sources/example.md | 10 ++---- docs/functions/example.md | 26 -------------- docs/index.md | 10 ++---- docs/resources/example.md | 10 ++---- examples/README.md | 9 ----- .../scaffolding_example/data-source.tf | 3 -- examples/provider/provider.tf | 3 -- .../resources/scaffolding_example/resource.tf | 3 -- go.mod | 2 +- internal/provider/example_data_source_test.go | 4 +-- internal/provider/example_function_test.go | 6 ++-- internal/provider/example_resource_test.go | 12 +++---- internal/provider/provider.go | 34 +++++++++---------- internal/provider/provider_test.go | 4 +-- main.go | 8 ++--- tools/tools.go | 2 +- 22 files changed, 57 insertions(+), 140 deletions(-) delete mode 100644 .copywrite.hcl rename .github/{CODEOWNERS => CODEOWNERS_disabled} (100%) delete mode 100644 docs/functions/example.md delete mode 100644 examples/README.md delete mode 100644 examples/data-sources/scaffolding_example/data-source.tf delete mode 100644 examples/provider/provider.tf delete mode 100644 examples/resources/scaffolding_example/resource.tf diff --git a/.copywrite.hcl b/.copywrite.hcl deleted file mode 100644 index bdf3892..0000000 --- a/.copywrite.hcl +++ /dev/null @@ -1,21 +0,0 @@ -# NOTE: This file is for HashiCorp specific licensing automation and can be deleted after creating a new repo with this template. -schema_version = 1 - -project { - license = "MPL-2.0" - copyright_year = 2021 - - header_ignore = [ - # examples used within documentation (prose) - "examples/**", - - # GitHub issue template configuration - ".github/ISSUE_TEMPLATE/*.yml", - - # golangci-lint tooling configuration - ".golangci.yml", - - # GoReleaser tooling configuration - ".goreleaser.yml", - ] -} diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS_disabled similarity index 100% rename from .github/CODEOWNERS rename to .github/CODEOWNERS_disabled diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md index 0c8b092..c71f612 100644 --- a/.github/CODE_OF_CONDUCT.md +++ b/.github/CODE_OF_CONDUCT.md @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index b76e247..17e45c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/LICENSE b/LICENSE index 15eba9d..d2dae9e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2021 HashiCorp, Inc. +Copyright (c) 2024 State of Geneva (Switzerland) Mozilla Public License Version 2.0 ================================== diff --git a/README.md b/README.md index 9759acd..b6ab58c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docs/data-sources/example.md b/docs/data-sources/example.md index b19c8a0..d7aa13b 100644 --- a/docs/data-sources/example.md +++ b/docs/data-sources/example.md @@ -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 diff --git a/docs/functions/example.md b/docs/functions/example.md deleted file mode 100644 index c65087d..0000000 --- a/docs/functions/example.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "example function - scaffolding" -subcategory: "" -description: |- - Example function ---- - -# function: example - -Echoes given argument as result - - - -## Signature - - -```text -example(input string) string -``` - -## Arguments - - -1. `input` (String) String to echo - diff --git a/docs/index.md b/docs/index.md index 7458d6d..bfd2bf5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 diff --git a/docs/resources/example.md b/docs/resources/example.md index 5f3d5ca..aef02af 100644 --- a/docs/resources/example.md +++ b/docs/resources/example.md @@ -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 diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index 026c42c..0000000 --- a/examples/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Examples - -This directory contains examples that are mostly used for documentation, but can also be run/tested manually via the Terraform CLI. - -The document generation tool looks for files in the following locations by default. All other *.tf files besides the ones mentioned below are ignored by the documentation tool. This is useful for creating examples that can run and/or ar testable even if some parts are not relevant for the documentation. - -* **provider/provider.tf** example file for the provider index page -* **data-sources/`full data source name`/data-source.tf** example file for the named data source page -* **resources/`full resource name`/resource.tf** example file for the named data source page diff --git a/examples/data-sources/scaffolding_example/data-source.tf b/examples/data-sources/scaffolding_example/data-source.tf deleted file mode 100644 index a852489..0000000 --- a/examples/data-sources/scaffolding_example/data-source.tf +++ /dev/null @@ -1,3 +0,0 @@ -data "scaffolding_example" "example" { - configurable_attribute = "some-value" -} diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf deleted file mode 100644 index 942db45..0000000 --- a/examples/provider/provider.tf +++ /dev/null @@ -1,3 +0,0 @@ -provider "scaffolding" { - # example configuration here -} diff --git a/examples/resources/scaffolding_example/resource.tf b/examples/resources/scaffolding_example/resource.tf deleted file mode 100644 index 9ae3f57..0000000 --- a/examples/resources/scaffolding_example/resource.tf +++ /dev/null @@ -1,3 +0,0 @@ -resource "scaffolding_example" "example" { - configurable_attribute = "some-value" -} diff --git a/go.mod b/go.mod index 06ed51c..c7bb879 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/hashicorp/terraform-provider-scaffolding-framework +module github.com/davidfischer-ch/terraform-provider-aria go 1.21 diff --git a/internal/provider/example_data_source_test.go b/internal/provider/example_data_source_test.go index 6f9aa7d..b08afaa 100644 --- a/internal/provider/example_data_source_test.go +++ b/internal/provider/example_data_source_test.go @@ -18,7 +18,7 @@ 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"), ), }, }, @@ -26,7 +26,7 @@ func TestAccExampleDataSource(t *testing.T) { } const testAccExampleDataSourceConfig = ` -data "scaffolding_example" "test" { +data "aria_example" "test" { configurable_attribute = "example" } ` diff --git a/internal/provider/example_function_test.go b/internal/provider/example_function_test.go index f7b5bdd..1e83744 100644 --- a/internal/provider/example_function_test.go +++ b/internal/provider/example_function_test.go @@ -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( @@ -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 @@ -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( diff --git a/internal/provider/example_resource_test.go b/internal/provider/example_resource_test.go index c5464d0..2193169 100644 --- a/internal/provider/example_resource_test.go +++ b/internal/provider/example_resource_test.go @@ -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 @@ -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 @@ -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) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 2471df6..bc28312 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright (c) State of Geneva (Switzerland) // SPDX-License-Identifier: MPL-2.0 package provider @@ -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{ @@ -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)...) @@ -66,19 +66,19 @@ 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, } @@ -86,7 +86,7 @@ func (p *ScaffoldingProvider) Functions(ctx context.Context) []func() function.F func New(version string) func() provider.Provider { return func() provider.Provider { - return &ScaffoldingProvider{ + return &AriaProvider{ version: version, } } diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index ef6599b..32b0bb4 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright (c) State of Geneva (Switzerland) // SPDX-License-Identifier: MPL-2.0 package provider @@ -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) { diff --git a/main.go b/main.go index a95e85c..5556c4b 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright (c) State of Geneva (Switzerland) // SPDX-License-Identifier: MPL-2.0 package main @@ -9,7 +9,7 @@ import ( "log" "github.com/hashicorp/terraform-plugin-framework/providerserver" - "github.com/hashicorp/terraform-provider-scaffolding-framework/internal/provider" + "github.com/davidfischer-ch/terraform-provider-aria/internal/provider" ) // Run "go generate" to format example terraform files and generate the docs for the registry/website @@ -20,7 +20,7 @@ import ( // Run the docs generation tool, check its repository for more information on how it works and how docs // can be customized. -//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate -provider-name scaffolding +//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate -provider-name aria var ( // these will be set by the goreleaser configuration @@ -41,7 +41,7 @@ func main() { // TODO: Update this string with the published name of your provider. // Also update the tfplugindocs generate command to either remove the // -provider-name flag or set its value to the updated provider name. - Address: "registry.terraform.io/hashicorp/scaffolding", + Address: "registry.terraform.io/GenevaState/aria", Debug: debug, } diff --git a/tools/tools.go b/tools/tools.go index 867d3a2..9f08f40 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -1,4 +1,4 @@ -// Copyright (c) HashiCorp, Inc. +// Copyright (c) State of Geneva (Switzerland) // SPDX-License-Identifier: MPL-2.0 //go:build tools