Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

various interface changes based on internal feedback #26

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"go.lintFlags": [
"--fast"
],
"go.lintTool": "golangci-lint"
"go.lintTool": "golangci-lint",
"files.insertFinalNewline": true
}
12 changes: 6 additions & 6 deletions docs/resources/environment_variable.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ description: |-
### Optional

- `scopes` (Set of String)
- `secret_value` (Attributes Set) (see [below for nested schema](#nestedatt--secret_value))
- `secret_values` (Attributes Set) (see [below for nested schema](#nestedatt--secret_values))
- `site_id` (String)
- `value` (Attributes Set) (see [below for nested schema](#nestedatt--value))
- `values` (Attributes Set) (see [below for nested schema](#nestedatt--values))

### Read-Only

- `last_updated` (String)

<a id="nestedatt--secret_value"></a>
### Nested Schema for `secret_value`
<a id="nestedatt--secret_values"></a>
### Nested Schema for `secret_values`

Required:

Expand All @@ -44,8 +44,8 @@ Optional:
- `context_parameter` (String)


<a id="nestedatt--value"></a>
### Nested Schema for `value`
<a id="nestedatt--values"></a>
### Nested Schema for `values`

Required:

Expand Down
5 changes: 5 additions & 0 deletions docs/resources/site_build_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ description: |-
### Required

- `build_command` (String)
- `production_branch` (String)
- `publish_directory` (String)
- `site_id` (String)

### Optional

- `base_directory` (String)
- `branch_deploy_all_branches` (Boolean)
- `branch_deploy_branches` (List of String)
- `build_image` (String)
- `deploy_previews` (Boolean)
- `functions_directory` (String)
- `functions_region` (String)
- `package_directory` (String)
- `pretty_urls` (Boolean)
- `stop_builds` (Boolean)
Expand Down
27 changes: 27 additions & 0 deletions docs/resources/site_collaboration_settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# generated by https:/hashicorp/terraform-plugin-docs
page_title: "netlify_site_collaboration_settings Resource - netlify"
subcategory: ""
description: |-

---

# netlify_site_collaboration_settings (Resource)





<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `netlify_drawer_in_branch_deploys` (Boolean)
- `netlify_drawer_in_deploy_previews` (Boolean)
- `netlify_heads_up_display` (Boolean)
- `site_id` (String)

### Read-Only

- `last_updated` (String)
39 changes: 0 additions & 39 deletions docs/resources/site_deploy_settings.md

This file was deleted.

31 changes: 31 additions & 0 deletions docs/resources/site_domain_settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
# generated by https:/hashicorp/terraform-plugin-docs
page_title: "netlify_site_domain_settings Resource - netlify"
subcategory: ""
description: |-

---

# netlify_site_domain_settings (Resource)





<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `site_id` (String)

### Optional

- `branch_deploy_custom_domain` (String)
- `custom_domain` (String)
- `deploy_preview_custom_domain` (String)
- `domain_aliases` (List of String)

### Read-Only

- `last_updated` (String)
1 change: 1 addition & 0 deletions examples/dns/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ resource "netlify_dns_record" "fish" {
priority = 10
}

# TODO: verify this returns all DNS records
data "netlify_dns_zone" "example" {
name = "example-tf-test-test.com"
depends_on = [
Expand Down
8 changes: 4 additions & 4 deletions examples/env_vars/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "netlify_environment_variable" "woof" {
account_id = data.netlify_account.current.id
site_id = data.netlify_site.platform_test.id
key = "WOOF"
value = [
values = [
{
value = "dogs are here",
context = "all",
Expand All @@ -35,7 +35,7 @@ resource "netlify_environment_variable" "meow" {
account_id = data.netlify_account.current.id
site_id = data.netlify_site.platform_test.id
key = "TEST_MEOW"
value = [
values = [
{
value = "roflmaocopter",
context = "all",
Expand All @@ -47,7 +47,7 @@ resource "netlify_environment_variable" "secret_meow" {
account_id = data.netlify_account.current.id
site_id = data.netlify_site.platform_test.id
key = "SECRET_TEST_MEOW"
secret_value = [
secret_values = [
{
value = "secret roflmaocopter",
context = "production",
Expand All @@ -62,7 +62,7 @@ resource "netlify_environment_variable" "secret_meow" {
resource "netlify_environment_variable" "global_meow" {
account_id = data.netlify_account.current.id
key = "TEST_MEOW"
value = [
values = [
{
value = "global roflmaocopter",
context = "all",
Expand Down
4 changes: 1 addition & 3 deletions examples/firewall_traffic_rules/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ terraform {
}

# `token` comes from NETLIFY_API_TOKEN, but can be specified with a Terraform variable
provider "netlify" {
token = "nfp_C92ECMDqhbZpjtbhGmzGT2GQnFJSA4zvcc22"
}
provider "netlify" {}

data "netlify_site" "test4" {
account_slug = "netlify-testing"
Expand Down
1 change: 1 addition & 0 deletions examples/site_data_sources/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ data "netlify_site" "platform_test" {
name = "platform-test-1"
}

# TODO: verify this returns all sites
data "netlify_sites" "all" {
account_slug = "netlify-testing"
}
Expand Down
19 changes: 13 additions & 6 deletions examples/site_settings/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,24 @@ data "netlify_site" "platform_test" {
}

resource "netlify_site_build_settings" "platform_test" {
site_id = data.netlify_site.platform_test.id
build_command = "npm run build"
publish_directory = "dist"
site_id = data.netlify_site.platform_test.id
build_command = "npm run build"
publish_directory = "dist"
production_branch = "main"
branch_deploy_branches = ["meow", "woof"]
}

resource "netlify_site_deploy_settings" "platform_test" {
resource "netlify_site_domain_settings" "platform_test" {
site_id = data.netlify_site.platform_test.id
production_branch = "main"
branch_deploy_branches = ["meow", "woof"]
custom_domain = "platform-test.example-tf-test-test.com"
domain_aliases = ["meow.example-tf-test-test.com"]
branch_deploy_custom_domain = "branch.example-tf-test-test.com"
deploy_preview_custom_domain = "dp.example-tf-test-test.com"
}

resource "netlify_site_collaboration_settings" "platform_test" {
site_id = data.netlify_site.platform_test.id
netlify_drawer_in_deploy_previews = true
netlify_drawer_in_branch_deploys = true
netlify_heads_up_display = true
}
18 changes: 0 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -110,38 +110,22 @@ github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek=
github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY=
github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/hc-install v0.6.4 h1:QLqlM56/+SIIGvGcfFiwMY3z5WGXT066suo/v9Km8e0=
github.com/hashicorp/hc-install v0.6.4/go.mod h1:05LWLy8TD842OtgcfBbOT0WMoInBMUSHjmDx10zuBIA=
github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk=
github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/terraform-exec v0.20.0 h1:DIZnPsqzPGuUnq6cH8jWcPunBfY+C+M8JyYF3vpnuEo=
github.com/hashicorp/terraform-exec v0.20.0/go.mod h1:ckKGkJWbsNqFKV1itgMnE0hY9IYf1HoiekpuN0eWoDw=
github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ=
github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg=
github.com/hashicorp/terraform-json v0.21.0 h1:9NQxbLNqPbEMze+S6+YluEdXgJmhQykRyRNd+zTI05U=
github.com/hashicorp/terraform-json v0.21.0/go.mod h1:qdeBs11ovMzo5puhrRibdD6d2Dq6TyE/28JiU4tIQxk=
github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec=
github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A=
github.com/hashicorp/terraform-plugin-docs v0.19.2 h1:YjdKa1vuqt9EnPYkkrv9HnGZz175HhSJ7Vsn8yZeWus=
github.com/hashicorp/terraform-plugin-docs v0.19.2/go.mod h1:gad2aP6uObFKhgNE8DR9nsEuEQnibp7il0jZYYOunWY=
github.com/hashicorp/terraform-plugin-docs v0.19.3 h1:xoxpeIuBfnoGxXY0dTajdj4GjEv6TihZdj0lHNXbKew=
github.com/hashicorp/terraform-plugin-docs v0.19.3/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA=
github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c=
github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA=
github.com/hashicorp/terraform-plugin-framework v1.8.0 h1:P07qy8RKLcoBkCrY2RHJer5AEvJnDuXomBgou6fD8kI=
github.com/hashicorp/terraform-plugin-framework v1.8.0/go.mod h1:/CpTukO88PcL/62noU7cuyaSJ4Rsim+A/pa+3rUVufY=
github.com/hashicorp/terraform-plugin-framework v1.9.0 h1:caLcDoxiRucNi2hk8+j3kJwkKfvHznubyFsJMWfZqKU=
github.com/hashicorp/terraform-plugin-framework v1.9.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM=
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc=
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg=
github.com/hashicorp/terraform-plugin-go v0.22.2 h1:5o8uveu6eZUf5J7xGPV0eY0TPXg3qpmwX9sce03Bxnc=
github.com/hashicorp/terraform-plugin-go v0.22.2/go.mod h1:drq8Snexp9HsbFZddvyLHN6LuWHHndSQg+gV+FPkcIM=
github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co=
github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ=
github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0=
Expand Down Expand Up @@ -293,8 +277,6 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
12 changes: 12 additions & 0 deletions internal/provider/dns_zone_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ func (r *dnsZoneResource) Create(ctx context.Context, req resource.CreateRequest
}
}

_, _, err = r.data.client.DNSZonesAPI.EnableDnsZoneIpv6(ctx, plan.ID.ValueString()).Execute()
if err != nil {
resp.Diagnostics.AddWarning(
"Error enabling IPv6 for Netlify DNS zone",
fmt.Sprintf(
"Could not enable IPv6 for Netlify DNS zone %q: %q",
plan.ID.ValueString(),
err.Error(),
),
)
}

resp.Diagnostics.Append(resp.State.Set(ctx, plan)...)
if resp.Diagnostics.HasError() {
return
Expand Down
32 changes: 16 additions & 16 deletions internal/provider/environment_variable_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ type environmentVariableResource struct {
}

type environmentVariableResourceModel struct {
AccountID types.String `tfsdk:"account_id"`
SiteID types.String `tfsdk:"site_id"`
LastUpdated types.String `tfsdk:"last_updated"`
Key types.String `tfsdk:"key"`
Scopes []types.String `tfsdk:"scopes"`
Value []environmentVariableValueModel `tfsdk:"value"`
SecretValue []environmentVariableValueModel `tfsdk:"secret_value"`
AccountID types.String `tfsdk:"account_id"`
SiteID types.String `tfsdk:"site_id"`
LastUpdated types.String `tfsdk:"last_updated"`
Key types.String `tfsdk:"key"`
Scopes []types.String `tfsdk:"scopes"`
Values []environmentVariableValueModel `tfsdk:"values"`
SecretValues []environmentVariableValueModel `tfsdk:"secret_values"`
}

type environmentVariableValueModel struct {
Expand Down Expand Up @@ -114,7 +114,7 @@ func (r *environmentVariableResource) Schema(_ context.Context, _ resource.Schem
types.StringValue("post-processing"),
})),
},
"value": schema.SetNestedAttribute{
"values": schema.SetNestedAttribute{
Optional: true,
NestedObject: schema.NestedAttributeObject{
Attributes: map[string]schema.Attribute{
Expand All @@ -140,7 +140,7 @@ func (r *environmentVariableResource) Schema(_ context.Context, _ resource.Schem
},
// TODO: validate that values don't overlap
},
"secret_value": schema.SetNestedAttribute{
"secret_values": schema.SetNestedAttribute{
Optional: true,
Validators: []validator.Set{
setvalidator.ExactlyOneOf(path.MatchRoot("value")),
Expand Down Expand Up @@ -189,11 +189,11 @@ func (r *environmentVariableResource) Create(ctx context.Context, req resource.C
}
var values []netlifyapi.EnvVarValue
var isSecret bool
if plan.SecretValue != nil && len(plan.SecretValue) > 0 {
values = serializeValues(plan.SecretValue)
if plan.SecretValues != nil && len(plan.SecretValues) > 0 {
values = serializeValues(plan.SecretValues)
isSecret = true
} else {
values = serializeValues(plan.Value)
values = serializeValues(plan.Values)
isSecret = false
}
createEnvVars := r.data.client.EnvironmentVariablesAPI.
Expand Down Expand Up @@ -263,7 +263,7 @@ func (r *environmentVariableResource) Read(ctx context.Context, req resource.Rea
state.Scopes[i] = types.StringValue(strings.ReplaceAll(strings.ReplaceAll(scope, " ", "-"), "_", "-"))
}
if !*envVar.IsSecret {
state.Value = parseValues(envVar.Values)
state.Values = parseValues(envVar.Values)
}

resp.Diagnostics.Append(resp.State.Set(ctx, &state)...)
Expand All @@ -285,11 +285,11 @@ func (r *environmentVariableResource) Update(ctx context.Context, req resource.U
}
var values []netlifyapi.EnvVarValue
var isSecret bool
if plan.SecretValue != nil && len(plan.SecretValue) > 0 {
values = serializeValues(plan.SecretValue)
if plan.SecretValues != nil && len(plan.SecretValues) > 0 {
values = serializeValues(plan.SecretValues)
isSecret = true
} else {
values = serializeValues(plan.Value)
values = serializeValues(plan.Values)
isSecret = false
}
updateEnvVar := r.data.client.EnvironmentVariablesAPI.
Expand Down
Loading