Skip to content

Commit

Permalink
New registry address
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjohansson committed Sep 25, 2024
1 parent 6bdd17f commit b40a6db
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 14 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Terraform Provider Scaffolding (Terraform Plugin Framework)

## Testing localhost

```shell
$ go install .
$ cat ~/.terraformrc
provider_installation {

dev_overrides {
"registry.terraform.io/springernature/ee-platform" = "/Users/simonjohansson/go/bin/"
}

# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}

$ cd examples/provider-install-verification
$ terraform init && terraform plan
```

_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:
Expand Down
2 changes: 1 addition & 1 deletion docs/data-sources/teams.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Teams data source

### Read-Only

- `teams` (Attributes List) (see [below for nested schema](#nestedatt--teams))
- `teams` (Attributes Map) (see [below for nested schema](#nestedatt--teams))

<a id="nestedatt--teams"></a>
### Nested Schema for `teams`
Expand Down
43 changes: 43 additions & 0 deletions examples/provider-install-verification/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions examples/provider-install-verification/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
ee-platform = {
source = "hashicorp.com/edu/ee-platform"
source = "springernature/ee-platform"
}
}
}
Expand All @@ -11,5 +11,11 @@ provider "ee-platform" {}
data "ee-platform_teams" "teams" {}

output "all_teams" {
value = data.ee-platform_teams.teams
value = data.ee-platform_teams.teams.teams
}

resource "local_file" "foo" {
for_each = data.ee-platform_teams.teams.teams
filename = "/tmp/test/${each.key}"
content = each.value.name
}
10 changes: 5 additions & 5 deletions internal/provider/teams_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (d *teamsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
resp.Schema = schema.Schema{
MarkdownDescription: "Teams data source",
Attributes: map[string]schema.Attribute{
"teams": schema.ListNestedAttribute{
"teams": schema.MapNestedAttribute{
Computed: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
Expand All @@ -60,13 +60,13 @@ func (d *teamsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
// Read refreshes the Terraform state with the latest data.
func (d *teamsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
state := teamsDataSourceModel{
Teams: []teamsModel{
{
Teams: map[string]teamsModel{
"team1": {
ID: types.StringValue("team1"),
Name: types.StringValue("Team 1"),
CfOrg: types.StringValue("cforg1"),
},
{
"team2": {
ID: types.StringValue("team2"),
Name: types.StringValue("Team 2"),
},
Expand All @@ -83,7 +83,7 @@ func (d *teamsDataSource) Read(ctx context.Context, req datasource.ReadRequest,

// coffeesDataSourceModel maps the data source schema data.
type teamsDataSourceModel struct {
Teams []teamsModel `tfsdk:"teams"`
Teams map[string]teamsModel `tfsdk:"teams"`
}

// teamsModel maps coffees schema data.
Expand Down
7 changes: 1 addition & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ func main() {
flag.Parse()

opts := providerserver.ServeOpts{
// NOTE: This is not a typical Terraform Registry provider address,
// such as registry.terraform.io/hashicorp/hashicups. This specific
// provider address is used in these tutorials in conjunction with a
// specific Terraform CLI configuration for manual development testing
// of this provider.
Address: "hashicorp.com/edu/ee-platform",
Address: "registry.terraform.io/springernature/ee-platform",
Debug: debug,
}

Expand Down

0 comments on commit b40a6db

Please sign in to comment.