From dbcaef9568b5421c69684d4bcf7718a617318d6d Mon Sep 17 00:00:00 2001 From: Douglas Harcourt Parsons Date: Wed, 23 Oct 2024 13:18:44 +0100 Subject: [PATCH 1/5] Add comment field to all env vars. Closes #208 --- client/dns_record.go | 4 ++-- client/environment_variable.go | 6 ++++-- client/project.go | 5 +++-- client/shared_environment_variable.go | 11 ++++++---- ...data_source_shared_environment_variable.go | 11 ++++------ vercel/resource_project.go | 14 +++++++++++++ .../resource_project_environment_variable.go | 12 +++++++++++ ...ource_project_environment_variable_test.go | 18 ++++++++-------- vercel/resource_project_test.go | 8 +++++-- .../resource_shared_environment_variable.go | 16 ++++++++++++-- ...source_shared_environment_variable_test.go | 21 +++++++++++++++++++ 11 files changed, 96 insertions(+), 30 deletions(-) diff --git a/client/dns_record.go b/client/dns_record.go index b572d808..310b73fe 100644 --- a/client/dns_record.go +++ b/client/dns_record.go @@ -115,8 +115,8 @@ func (c *Client) ListDNSRecords(ctx context.Context, domain, teamID string) (r [ url: url, body: "", }, &dr) - for _, record := range dr.Records { - record.TeamID = c.teamID(teamID) + for i := 0; i < len(dr.Records); i++ { + dr.Records[i].TeamID = c.teamID(teamID) } return dr.Records, err } diff --git a/client/environment_variable.go b/client/environment_variable.go index c71f8029..ff641529 100644 --- a/client/environment_variable.go +++ b/client/environment_variable.go @@ -15,6 +15,7 @@ type EnvironmentVariableRequest struct { Target []string `json:"target"` GitBranch *string `json:"gitBranch,omitempty"` Type string `json:"type"` + Comment string `json:"comment"` } type CreateEnvironmentVariableRequest struct { @@ -78,6 +79,7 @@ type UpdateEnvironmentVariableRequest struct { Target []string `json:"target"` GitBranch *string `json:"gitBranch,omitempty"` Type string `json:"type"` + Comment string `json:"comment"` ProjectID string `json:"-"` TeamID string `json:"-"` EnvID string `json:"-"` @@ -141,8 +143,8 @@ func (c *Client) GetEnvironmentVariables(ctx context.Context, projectID, teamID url: url, body: "", }, &envResponse) - for _, env := range envResponse.Env { - env.TeamID = c.teamID(teamID) + for i := 0; i < len(envResponse.Env); i++ { + envResponse.Env[i].TeamID = c.teamID(teamID) } return envResponse.Env, err } diff --git a/client/project.go b/client/project.go index cf40dde0..88b415d4 100644 --- a/client/project.go +++ b/client/project.go @@ -29,6 +29,7 @@ type EnvironmentVariable struct { Type string `json:"type"` ID string `json:"id,omitempty"` TeamID string `json:"-"` + Comment string `json:"comment"` } type DeploymentExpiration struct { @@ -257,8 +258,8 @@ func (c *Client) ListProjects(ctx context.Context, teamID string) (r []ProjectRe url: url, body: "", }, &pr) - for _, p := range pr.Projects { - p.TeamID = c.teamID(teamID) + for i := 0; i < len(pr.Projects); i++ { + pr.Projects[i].TeamID = c.teamID(teamID) } return pr.Projects, err } diff --git a/client/shared_environment_variable.go b/client/shared_environment_variable.go index 069b9a6c..49c1c132 100644 --- a/client/shared_environment_variable.go +++ b/client/shared_environment_variable.go @@ -15,11 +15,13 @@ type SharedEnvironmentVariableResponse struct { Type string `json:"type"` Target []string `json:"target"` ProjectIDs []string `json:"projectId"` + Comment string `json:"comment"` } type SharedEnvVarRequest struct { - Key string `json:"key"` - Value string `json:"value"` + Key string `json:"key"` + Value string `json:"value"` + Comment string `json:"comment"` } type SharedEnvironmentVariableRequest struct { @@ -126,8 +128,8 @@ func (c *Client) ListSharedEnvironmentVariables(ctx context.Context, teamID stri url: url, body: "", }, &res) - for _, v := range res.Data { - v.TeamID = c.teamID(teamID) + for i := 0; i < len(res.Data); i++ { + res.Data[i].TeamID = c.teamID(teamID) } return res.Data, err } @@ -137,6 +139,7 @@ type UpdateSharedEnvironmentVariableRequest struct { Type string `json:"type"` ProjectIDs []string `json:"projectId"` Target []string `json:"target"` + Comment string `json:"comment"` TeamID string `json:"-"` EnvID string `json:"-"` } diff --git a/vercel/data_source_shared_environment_variable.go b/vercel/data_source_shared_environment_variable.go index 44979e5e..966d24fa 100644 --- a/vercel/data_source_shared_environment_variable.go +++ b/vercel/data_source_shared_environment_variable.go @@ -131,6 +131,10 @@ For more detailed information, please see the [Vercel documentation](https://ver Description: "Whether the Environment Variable is sensitive or not.", Computed: true, }, + "comment": schema.StringAttribute{ + Description: "A comment explaining what the environment variable is for.", + Computed: true, + }, }, } } @@ -225,13 +229,6 @@ func (d *sharedEnvironmentVariableDataSource) Read(ctx context.Context, req data } result := convertResponseToSharedEnvironmentVariable(out, types.StringNull()) - if err != nil { - resp.Diagnostics.AddError( - "Error converting shared environment variable response to model", - "Could not read shared environment variable, unexpected error: "+err.Error(), - ) - return - } tflog.Info(ctx, "read shared environment variable", map[string]interface{}{ "team_id": result.TeamID.ValueString(), "project_id": result.ID.ValueString(), diff --git a/vercel/resource_project.go b/vercel/resource_project.go index 7573deac..bb928dc6 100644 --- a/vercel/resource_project.go +++ b/vercel/resource_project.go @@ -151,6 +151,14 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ Optional: true, Computed: true, }, + "comment": schema.StringAttribute{ + Description: "A comment explaining what the environment variable is for.", + Optional: true, + Computed: true, + Validators: []validator.String{ + stringLengthBetween(0, 1000), + }, + }, }, }, }, @@ -633,6 +641,7 @@ func parseEnvironment(vars []EnvironmentItem) []client.EnvironmentVariable { GitBranch: e.GitBranch.ValueStringPointer(), Type: envVariableType, ID: e.ID.ValueString(), + Comment: e.Comment.ValueString(), }) } return out @@ -722,6 +731,7 @@ type EnvironmentItem struct { Value types.String `tfsdk:"value"` ID types.String `tfsdk:"id"` Sensitive types.Bool `tfsdk:"sensitive"` + Comment types.String `tfsdk:"comment"` } func (e *EnvironmentItem) toEnvironmentVariableRequest() client.EnvironmentVariableRequest { @@ -744,6 +754,7 @@ func (e *EnvironmentItem) toEnvironmentVariableRequest() client.EnvironmentVaria Target: target, GitBranch: e.GitBranch.ValueStringPointer(), Type: envVariableType, + Comment: e.Comment.ValueString(), } } @@ -996,6 +1007,7 @@ var envVariableElemType = types.ObjectType{ "git_branch": types.StringType, "id": types.StringType, "sensitive": types.BoolType, + "comment": types.StringType, }, } @@ -1185,6 +1197,7 @@ func convertResponseToProject(ctx context.Context, response client.ProjectRespon "git_branch": types.StringType, "id": types.StringType, "sensitive": types.BoolType, + "comment": types.StringType, }, map[string]attr.Value{ "key": types.StringValue(e.Key), @@ -1193,6 +1206,7 @@ func convertResponseToProject(ctx context.Context, response client.ProjectRespon "git_branch": types.StringPointerValue(e.GitBranch), "id": types.StringValue(e.ID), "sensitive": types.BoolValue(e.Type == "sensitive"), + "comment": types.StringValue(e.Comment), }, )) } diff --git a/vercel/resource_project_environment_variable.go b/vercel/resource_project_environment_variable.go index c1a5e8a6..f23b34f0 100644 --- a/vercel/resource_project_environment_variable.go +++ b/vercel/resource_project_environment_variable.go @@ -114,6 +114,14 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ Validators: []validator.Bool{}, PlanModifiers: []planmodifier.Bool{boolplanmodifier.RequiresReplace()}, }, + "comment": schema.StringAttribute{ + Description: "A comment explaining what the environment variable is for.", + Optional: true, + Computed: true, + Validators: []validator.String{ + stringLengthBetween(0, 1000), + }, + }, }, } } @@ -128,6 +136,7 @@ type ProjectEnvironmentVariable struct { ProjectID types.String `tfsdk:"project_id"` ID types.String `tfsdk:"id"` Sensitive types.Bool `tfsdk:"sensitive"` + Comment types.String `tfsdk:"comment"` } func (r *projectEnvironmentVariableResource) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -193,6 +202,7 @@ func (e *ProjectEnvironmentVariable) toCreateEnvironmentVariableRequest() client Target: target, GitBranch: e.GitBranch.ValueStringPointer(), Type: envVariableType, + Comment: e.Comment.ValueString(), }, ProjectID: e.ProjectID.ValueString(), TeamID: e.TeamID.ValueString(), @@ -221,6 +231,7 @@ func (e *ProjectEnvironmentVariable) toUpdateEnvironmentVariableRequest() client ProjectID: e.ProjectID.ValueString(), TeamID: e.TeamID.ValueString(), EnvID: e.ID.ValueString(), + Comment: e.Comment.ValueString(), } } @@ -247,6 +258,7 @@ func convertResponseToProjectEnvironmentVariable(response client.EnvironmentVari ProjectID: projectID, ID: types.StringValue(response.ID), Sensitive: types.BoolValue(response.Type == "sensitive"), + Comment: types.StringValue(response.Comment), } } diff --git a/vercel/resource_project_environment_variable_test.go b/vercel/resource_project_environment_variable_test.go index c6c08379..ad836641 100644 --- a/vercel/resource_project_environment_variable_test.go +++ b/vercel/resource_project_environment_variable_test.go @@ -66,6 +66,7 @@ func TestAcc_ProjectEnvironmentVariables(t *testing.T) { resource.TestCheckResourceAttr("vercel_project_environment_variable.example", "key", "foo"), resource.TestCheckResourceAttr("vercel_project_environment_variable.example", "value", "bar"), resource.TestCheckTypeSetElemAttr("vercel_project_environment_variable.example", "target.*", "production"), + resource.TestCheckResourceAttr("vercel_project_environment_variable.example", "comment", "this is with a comment"), testAccProjectEnvironmentVariableExists("vercel_project_environment_variable.example_git_branch", testTeam()), resource.TestCheckResourceAttr("vercel_project_environment_variable.example_git_branch", "key", "foo"), @@ -79,13 +80,11 @@ func TestAcc_ProjectEnvironmentVariables(t *testing.T) { resource.TestCheckTypeSetElemAttr("vercel_project_environment_variable.example_sensitive", "target.*", "production"), resource.TestCheckResourceAttr("vercel_project_environment_variable.example_sensitive", "sensitive", "true"), - /* - testAccProjectEnvironmentVariableExists("vercel_project_environment_variable.example_not_sensitive", testTeam()), - resource.TestCheckResourceAttr("vercel_project_environment_variable.example_not_sensitive", "key", "foo_not_sensitive"), - resource.TestCheckResourceAttr("vercel_project_environment_variable.example_not_sensitive", "value", "bar-not-sensitive"), - resource.TestCheckTypeSetElemAttr("vercel_project_environment_variable.example_not_sensitive", "target.*", "production"), - resource.TestCheckResourceAttr("vercel_project_environment_variable.example_not_sensitive", "sensitive", "false"), - */ + testAccProjectEnvironmentVariableExists("vercel_project_environment_variable.example_not_sensitive", testTeam()), + resource.TestCheckResourceAttr("vercel_project_environment_variable.example_not_sensitive", "key", "foo_not_sensitive"), + resource.TestCheckResourceAttr("vercel_project_environment_variable.example_not_sensitive", "value", "bar-not-sensitive"), + resource.TestCheckTypeSetElemAttr("vercel_project_environment_variable.example_not_sensitive", "target.*", "production"), + resource.TestCheckResourceAttr("vercel_project_environment_variable.example_not_sensitive", "sensitive", "false"), ), }, { @@ -96,6 +95,7 @@ func TestAcc_ProjectEnvironmentVariables(t *testing.T) { resource.TestCheckResourceAttr("vercel_project_environment_variable.example", "value", "bar-new"), resource.TestCheckTypeSetElemAttr("vercel_project_environment_variable.example", "target.*", "production"), resource.TestCheckTypeSetElemAttr("vercel_project_environment_variable.example", "target.*", "preview"), + resource.TestCheckResourceAttr("vercel_project_environment_variable.example", "comment", "this is an updated comment"), testAccProjectEnvironmentVariableExists("vercel_project_environment_variable.example_git_branch", testTeam()), resource.TestCheckResourceAttr("vercel_project_environment_variable.example_git_branch", "key", "foo"), @@ -168,6 +168,7 @@ resource "vercel_project_environment_variable" "example" { key = "foo" value = "bar" target = ["production"] + comment = "this is with a comment" } resource "vercel_project_environment_variable" "example_git_branch" { @@ -188,7 +189,6 @@ resource "vercel_project_environment_variable" "example_sensitive" { sensitive = true } -/* resource "vercel_project_environment_variable" "example_not_sensitive" { project_id = vercel_project.example.id %[3]s @@ -197,7 +197,6 @@ resource "vercel_project_environment_variable" "example_not_sensitive" { target = ["production"] sensitive = false } -*/ `, projectName, testGithubRepo(), teamIDConfig()) } @@ -219,6 +218,7 @@ resource "vercel_project_environment_variable" "example" { key = "foo" value = "bar-new" target = ["production", "preview"] + comment = "this is an updated comment" } resource "vercel_project_environment_variable" "example_git_branch" { diff --git a/vercel/resource_project_test.go b/vercel/resource_project_test.go index 1d1efcf3..23883ca0 100644 --- a/vercel/resource_project_test.go +++ b/vercel/resource_project_test.go @@ -209,6 +209,7 @@ func TestAcc_ProjectWithGitRepository(t *testing.T) { "key": "foo", "value": "bar", "git_branch": "staging", + "comment": "some comment", }), ), }, @@ -217,8 +218,9 @@ func TestAcc_ProjectWithGitRepository(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccProjectExists("vercel_project.test_git", testTeam()), resource.TestCheckTypeSetElemNestedAttrs("vercel_project.test_git", "environment.*", map[string]string{ - "key": "foo", - "value": "bar2", + "key": "foo", + "value": "bar2", + "comment": "some updated comment", }), ), }, @@ -644,6 +646,7 @@ resource "vercel_project" "test_git" { value = "bar" target = ["preview"] git_branch = "staging" + comment = "some comment" } ] } @@ -676,6 +679,7 @@ resource "vercel_project" "test_git" { key = "foo" value = "bar2" target = ["preview"] + comment = "some updated comment" } ] } diff --git a/vercel/resource_shared_environment_variable.go b/vercel/resource_shared_environment_variable.go index 0dfa2e55..448864d8 100644 --- a/vercel/resource_shared_environment_variable.go +++ b/vercel/resource_shared_environment_variable.go @@ -151,6 +151,14 @@ For more detailed information, please see the [Vercel documentation](https://ver Computed: true, PlanModifiers: []planmodifier.Bool{boolplanmodifier.RequiresReplace()}, }, + "comment": schema.StringAttribute{ + Description: "A comment explaining what the environment variable is for.", + Optional: true, + Computed: true, + Validators: []validator.String{ + stringLengthBetween(0, 1000), + }, + }, }, } } @@ -164,6 +172,7 @@ type SharedEnvironmentVariable struct { ProjectIDs types.Set `tfsdk:"project_ids"` ID types.String `tfsdk:"id"` Sensitive types.Bool `tfsdk:"sensitive"` + Comment types.String `tfsdk:"comment"` } func (e *SharedEnvironmentVariable) toCreateSharedEnvironmentVariableRequest(ctx context.Context, diags diag.Diagnostics) (req client.CreateSharedEnvironmentVariableRequest, ok bool) { @@ -196,8 +205,9 @@ func (e *SharedEnvironmentVariable) toCreateSharedEnvironmentVariableRequest(ctx ProjectIDs: projectIDs, EnvironmentVariables: []client.SharedEnvVarRequest{ { - Key: e.Key.ValueString(), - Value: e.Value.ValueString(), + Key: e.Key.ValueString(), + Value: e.Value.ValueString(), + Comment: e.Comment.ValueString(), }, }, }, @@ -233,6 +243,7 @@ func (e *SharedEnvironmentVariable) toUpdateSharedEnvironmentVariableRequest(ctx TeamID: e.TeamID.ValueString(), EnvID: e.ID.ValueString(), ProjectIDs: projectIDs, + Comment: e.Comment.ValueString(), }, true } @@ -263,6 +274,7 @@ func convertResponseToSharedEnvironmentVariable(response client.SharedEnvironmen TeamID: toTeamID(response.TeamID), ID: types.StringValue(response.ID), Sensitive: types.BoolValue(response.Type == "sensitive"), + Comment: types.StringValue(response.Comment), } } diff --git a/vercel/resource_shared_environment_variable_test.go b/vercel/resource_shared_environment_variable_test.go index 0856bb29..c2a4ddff 100644 --- a/vercel/resource_shared_environment_variable_test.go +++ b/vercel/resource_shared_environment_variable_test.go @@ -41,11 +41,20 @@ func TestAcc_SharedEnvironmentVariables(t *testing.T) { testAccSharedEnvironmentVariableExists("vercel_shared_environment_variable.example", testTeam()), resource.TestCheckResourceAttr("vercel_shared_environment_variable.example", "key", fmt.Sprintf("test_acc_foo_%s", nameSuffix)), resource.TestCheckResourceAttr("vercel_shared_environment_variable.example", "value", "bar"), + resource.TestCheckResourceAttr("vercel_shared_environment_variable.example", "comment", "Test comment for example"), resource.TestCheckTypeSetElemAttr("vercel_shared_environment_variable.example", "target.*", "production"), + testAccSharedEnvironmentVariableExists("vercel_shared_environment_variable.sensitive_example", testTeam()), resource.TestCheckResourceAttr("vercel_shared_environment_variable.sensitive_example", "key", fmt.Sprintf("test_acc_foo_sensitive_%s", nameSuffix)), resource.TestCheckResourceAttr("vercel_shared_environment_variable.sensitive_example", "value", "bar"), + resource.TestCheckResourceAttr("vercel_shared_environment_variable.sensitive_example", "comment", "Test comment for sensitive example"), resource.TestCheckTypeSetElemAttr("vercel_shared_environment_variable.sensitive_example", "target.*", "production"), + + testAccSharedEnvironmentVariableExists("vercel_shared_environment_variable.no_comment_example", testTeam()), + resource.TestCheckResourceAttr("vercel_shared_environment_variable.no_comment_example", "key", fmt.Sprintf("test_acc_foo_no_comment_%s", nameSuffix)), + resource.TestCheckResourceAttr("vercel_shared_environment_variable.no_comment_example", "value", "baz"), + resource.TestCheckResourceAttr("vercel_shared_environment_variable.no_comment_example", "comment", ""), + resource.TestCheckTypeSetElemAttr("vercel_shared_environment_variable.no_comment_example", "target.*", "production"), ), }, { @@ -105,6 +114,7 @@ resource "vercel_shared_environment_variable" "example" { project_ids = [ vercel_project.example.id ] + comment = "Test comment for example" } resource "vercel_shared_environment_variable" "sensitive_example" { @@ -116,6 +126,17 @@ resource "vercel_shared_environment_variable" "sensitive_example" { project_ids = [ vercel_project.example.id ] + comment = "Test comment for sensitive example" +} + +resource "vercel_shared_environment_variable" "no_comment_example" { + %[2]s + key = "test_acc_foo_no_comment_%[1]s" + value = "baz" + target = ["production"] + project_ids = [ + vercel_project.example.id + ] } `, projectName, teamIDConfig()) } From 837b79527eb76c5b68f1fdccccdbccb9066ba0cc Mon Sep 17 00:00:00 2001 From: Douglas Harcourt Parsons Date: Wed, 23 Oct 2024 13:21:03 +0100 Subject: [PATCH 2/5] Generate docs --- docs/data-sources/shared_environment_variable.md | 1 + docs/resources/project.md | 1 + docs/resources/project_environment_variable.md | 1 + docs/resources/shared_environment_variable.md | 1 + 4 files changed, 4 insertions(+) diff --git a/docs/data-sources/shared_environment_variable.md b/docs/data-sources/shared_environment_variable.md index acb1a82a..ede35006 100644 --- a/docs/data-sources/shared_environment_variable.md +++ b/docs/data-sources/shared_environment_variable.md @@ -45,6 +45,7 @@ data "vercel_shared_environment_variable" "example_by_key_and_target" { ### Read-Only +- `comment` (String) A comment explaining what the environment variable is for. - `project_ids` (Set of String) The ID of the Vercel project. - `sensitive` (Boolean) Whether the Environment Variable is sensitive or not. - `value` (String, Sensitive) The value of the Environment Variable. diff --git a/docs/resources/project.md b/docs/resources/project.md index b7943bcd..255951dd 100644 --- a/docs/resources/project.md +++ b/docs/resources/project.md @@ -102,6 +102,7 @@ Required: Optional: +- `comment` (String) A comment explaining what the environment variable is for. - `git_branch` (String) The git branch of the Environment Variable. - `sensitive` (Boolean) Whether the Environment Variable is sensitive or not. (May be affected by a [team-wide environment variable policy](https://vercel.com/docs/projects/environment-variables/sensitive-environment-variables#environment-variables-policy)) diff --git a/docs/resources/project_environment_variable.md b/docs/resources/project_environment_variable.md index 65b546c3..b7251929 100644 --- a/docs/resources/project_environment_variable.md +++ b/docs/resources/project_environment_variable.md @@ -75,6 +75,7 @@ resource "vercel_project_environment_variable" "example_sensitive" { ### Optional +- `comment` (String) A comment explaining what the environment variable is for. - `git_branch` (String) The git branch of the Environment Variable. - `sensitive` (Boolean) Whether the Environment Variable is sensitive or not. (May be affected by a [team-wide environment variable policy](https://vercel.com/docs/projects/environment-variables/sensitive-environment-variables#environment-variables-policy)) - `team_id` (String) The ID of the Vercel team.Required when configuring a team resource if a default team has not been set in the provider. diff --git a/docs/resources/shared_environment_variable.md b/docs/resources/shared_environment_variable.md index b3424a8e..a8e6c203 100644 --- a/docs/resources/shared_environment_variable.md +++ b/docs/resources/shared_environment_variable.md @@ -52,6 +52,7 @@ resource "vercel_shared_environment_variable" "example" { ### Optional +- `comment` (String) A comment explaining what the environment variable is for. - `sensitive` (Boolean) Whether the Environment Variable is sensitive or not. (May be affected by a [team-wide environment variable policy](https://vercel.com/docs/projects/environment-variables/sensitive-environment-variables#environment-variables-policy)) - `team_id` (String) The ID of the Vercel team. Shared environment variables require a team. From 549ab623e36b3d31538707619a8c3712356a22e3 Mon Sep 17 00:00:00 2001 From: Douglas Harcourt Parsons Date: Wed, 23 Oct 2024 13:22:52 +0100 Subject: [PATCH 3/5] Update examples --- docs/resources/project_environment_variable.md | 13 ++++++++----- docs/resources/shared_environment_variable.md | 7 ++++--- .../resource.tf | 16 ++++++++++------ .../resource.tf | 7 ++++--- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/docs/resources/project_environment_variable.md b/docs/resources/project_environment_variable.md index b7251929..a30baacf 100644 --- a/docs/resources/project_environment_variable.md +++ b/docs/resources/project_environment_variable.md @@ -40,6 +40,7 @@ resource "vercel_project_environment_variable" "example" { key = "foo" value = "bar" target = ["production"] + comment = "a production secret" } # An environment variable that will be created @@ -50,16 +51,18 @@ resource "vercel_project_environment_variable" "example_git_branch" { value = "bar-staging" target = ["preview"] git_branch = "staging" + comment = "a staging secret" } # A sensitive environment variable that will be created # for this project for the "production" environment. resource "vercel_project_environment_variable" "example_sensitive" { - project_id = vercel_project.example.id - key = "foo" - value = "bar-production" - target = ["production"] - sensitive = true + project_id = vercel_project.example.id + key = "foo" + value = "bar-production" + target = ["production"] + sensitive = true + comment = "a sensitive production secret" } ``` diff --git a/docs/resources/shared_environment_variable.md b/docs/resources/shared_environment_variable.md index a8e6c203..a1157104 100644 --- a/docs/resources/shared_environment_variable.md +++ b/docs/resources/shared_environment_variable.md @@ -31,9 +31,10 @@ resource "vercel_project" "example" { # A shared environment variable that will be created # and associated with the "example" project. resource "vercel_shared_environment_variable" "example" { - key = "EXAMPLE" - value = "some_value" - target = ["production"] + key = "EXAMPLE" + value = "some_value" + target = ["production"] + comment = "an example shared variable" project_ids = [ vercel_project.example.id ] diff --git a/examples/resources/vercel_project_environment_variable/resource.tf b/examples/resources/vercel_project_environment_variable/resource.tf index a6e6a1c9..1ce692a6 100644 --- a/examples/resources/vercel_project_environment_variable/resource.tf +++ b/examples/resources/vercel_project_environment_variable/resource.tf @@ -14,6 +14,7 @@ resource "vercel_project_environment_variable" "example" { key = "foo" value = "bar" target = ["production"] + comment = "a production secret" } # An environment variable that will be created @@ -24,14 +25,17 @@ resource "vercel_project_environment_variable" "example_git_branch" { value = "bar-staging" target = ["preview"] git_branch = "staging" + comment = "a staging secret" } # A sensitive environment variable that will be created # for this project for the "production" environment. resource "vercel_project_environment_variable" "example_sensitive" { - project_id = vercel_project.example.id - key = "foo" - value = "bar-production" - target = ["production"] - sensitive = true -} \ No newline at end of file + project_id = vercel_project.example.id + key = "foo" + value = "bar-production" + target = ["production"] + sensitive = true + comment = "a sensitive production secret" +} + diff --git a/examples/resources/vercel_shared_environment_variable/resource.tf b/examples/resources/vercel_shared_environment_variable/resource.tf index 29c7fece..11e5a232 100644 --- a/examples/resources/vercel_shared_environment_variable/resource.tf +++ b/examples/resources/vercel_shared_environment_variable/resource.tf @@ -10,9 +10,10 @@ resource "vercel_project" "example" { # A shared environment variable that will be created # and associated with the "example" project. resource "vercel_shared_environment_variable" "example" { - key = "EXAMPLE" - value = "some_value" - target = ["production"] + key = "EXAMPLE" + value = "some_value" + target = ["production"] + comment = "an example shared variable" project_ids = [ vercel_project.example.id ] From 15f503649e2ef255ebab1371ba3593d977941fd4 Mon Sep 17 00:00:00 2001 From: Douglas Harcourt Parsons Date: Wed, 23 Oct 2024 14:37:11 +0100 Subject: [PATCH 4/5] Fix data source --- vercel/data_source_project.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vercel/data_source_project.go b/vercel/data_source_project.go index b76fdf68..62d010ca 100644 --- a/vercel/data_source_project.go +++ b/vercel/data_source_project.go @@ -123,6 +123,10 @@ For more detailed information, please see the [Vercel documentation](https://ver Description: "Whether the Environment Variable is sensitive or not. Note that the value will be `null` for sensitive environment variables.", Computed: true, }, + "comment": schema.StringAttribute{ + Description: "A comment explaining what the environment variable is for.", + Computed: true, + }, }, }, }, From 6c4bb3b6c0319fa5739dbd9587db34960d748a78 Mon Sep 17 00:00:00 2001 From: Douglas Harcourt Parsons Date: Wed, 23 Oct 2024 14:41:04 +0100 Subject: [PATCH 5/5] More docs --- docs/data-sources/project.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/data-sources/project.md b/docs/data-sources/project.md index 33e61425..c309374c 100644 --- a/docs/data-sources/project.md +++ b/docs/data-sources/project.md @@ -78,6 +78,7 @@ output "project_id" { Read-Only: +- `comment` (String) A comment explaining what the environment variable is for. - `git_branch` (String) The git branch of the environment variable. - `id` (String) The ID of the environment variable - `key` (String) The name of the environment variable.