这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix issue updating sensitive project environment variables #155

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

Merged
merged 1 commit into from
Mar 8, 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
1 change: 0 additions & 1 deletion client/environment_variable_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
// UpdateEnvironmentVariableRequest defines the information that needs to be passed to Vercel in order to
// update an environment variable.
type UpdateEnvironmentVariableRequest struct {
Key string `json:"key"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key is required-replace, so should not be present in the update request.

Value string `json:"value"`
Target []string `json:"target"`
GitBranch *string `json:"gitBranch,omitempty"`
Expand Down
1 change: 0 additions & 1 deletion vercel/resource_project_environment_variable_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func (e *ProjectEnvironmentVariable) toUpdateEnvironmentVariableRequest() client
}

return client.UpdateEnvironmentVariableRequest{
Key: e.Key.ValueString(),
Value: e.Value.ValueString(),
Target: target,
GitBranch: toStrPointer(e.GitBranch),
Expand Down
4 changes: 2 additions & 2 deletions vercel/resource_project_environment_variable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestAcc_ProjectEnvironmentVariables(t *testing.T) {
resource.TestCheckResourceAttr("vercel_project_environment_variable.example_git_branch", "git_branch", "test"),

testAccProjectEnvironmentVariableExists("vercel_project_environment_variable.example_sensitive", testTeam()),
resource.TestCheckResourceAttr("vercel_project_environment_variable.example_sensitive", "key", "foo_sensitive_updated"),
resource.TestCheckResourceAttr("vercel_project_environment_variable.example_sensitive", "key", "foo_sensitive"),
resource.TestCheckResourceAttr("vercel_project_environment_variable.example_sensitive", "value", "bar-sensitive-updated"),
resource.TestCheckTypeSetElemAttr("vercel_project_environment_variable.example_sensitive", "target.*", "production"),
resource.TestCheckResourceAttr("vercel_project_environment_variable.example_sensitive", "sensitive", "true"),
Expand Down Expand Up @@ -214,7 +214,7 @@ resource "vercel_project_environment_variable" "example_git_branch" {
resource "vercel_project_environment_variable" "example_sensitive" {
project_id = vercel_project.example.id
%[3]s
key = "foo_sensitive_updated"
key = "foo_sensitive"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was faulty - updating the key forced a replacement, so it wasn't really testing that the other fields can be updated.

value = "bar-sensitive-updated"
target = ["production"]
sensitive = true
Expand Down