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

Fix issues with removing git_repository from a project #134

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 2 commits into from
Oct 16, 2023
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
13 changes: 8 additions & 5 deletions vercel/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
Expand Down Expand Up @@ -96,9 +97,10 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ
Description: "When a commit is pushed to the Git repository that is connected with your Project, its SHA will determine if a new Build has to be issued. If the SHA was deployed before, no new Build will be issued. You can customize this behavior with a command that exits with code 1 (new Build needed) or code 0.",
},
"serverless_function_region": schema.StringAttribute{
Optional: true,
Computed: true,
Description: "The region on Vercel's network to which your Serverless Functions are deployed. It should be close to any data source your Serverless Function might depend on. A new Deployment is required for your changes to take effect. Please see [Vercel's documentation](https://vercel.com/docs/concepts/edge-network/regions) for a full list of regions.",
Optional: true,
Computed: true,
Description: "The region on Vercel's network to which your Serverless Functions are deployed. It should be close to any data source your Serverless Function might depend on. A new Deployment is required for your changes to take effect. Please see [Vercel's documentation](https://vercel.com/docs/concepts/edge-network/regions) for a full list of regions.",
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
Validators: []validator.String{
validateServerlessFunctionRegion(),
},
Expand Down Expand Up @@ -145,8 +147,9 @@ At this time you cannot use a Vercel Project resource with in-line ` + "`environ
},
},
"git_repository": schema.SingleNestedAttribute{
Description: "The Git Repository that will be connected to the project. When this is defined, any pushes to the specified connected Git Repository will be automatically deployed. This requires the corresponding Vercel for [Github](https://vercel.com/docs/concepts/git/vercel-for-github), [Gitlab](https://vercel.com/docs/concepts/git/vercel-for-gitlab) or [Bitbucket](https://vercel.com/docs/concepts/git/vercel-for-bitbucket) plugins to be installed.",
Optional: true,
Description: "The Git Repository that will be connected to the project. When this is defined, any pushes to the specified connected Git Repository will be automatically deployed. This requires the corresponding Vercel for [Github](https://vercel.com/docs/concepts/git/vercel-for-github), [Gitlab](https://vercel.com/docs/concepts/git/vercel-for-gitlab) or [Bitbucket](https://vercel.com/docs/concepts/git/vercel-for-bitbucket) plugins to be installed.",
Optional: true,
PlanModifiers: []planmodifier.Object{objectplanmodifier.RequiresReplace(), objectplanmodifier.UseStateForUnknown()},
Attributes: map[string]schema.Attribute{
"type": schema.StringAttribute{
Description: "The git provider of the repository. Must be either `github`, `gitlab`, or `bitbucket`.",
Expand Down
24 changes: 24 additions & 0 deletions vercel/resource_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ func TestAcc_ProjectWithGitRepository(t *testing.T) {
}),
),
},
{
Config: testAccProjectConfigWithGitRepoRemoved(projectSuffix, teamIDConfig()),
Check: resource.ComposeAggregateTestCheckFunc(
testAccProjectExists("vercel_project.test_git", testTeam()),
resource.TestCheckNoResourceAttr("vercel_project.test_git", "git_repository"),
),
},
},
})
}
Expand Down Expand Up @@ -436,6 +443,23 @@ resource "vercel_project" "test_git" {
`, projectSuffix, teamID, testGithubRepo())
}

func testAccProjectConfigWithGitRepoRemoved(projectSuffix, teamID string) string {
return fmt.Sprintf(`
resource "vercel_project" "test_git" {
name = "test-acc-two-%s"
%s
public_source = false
environment = [
{
key = "foo"
value = "bar2"
target = ["preview"]
}
]
}
`, projectSuffix, teamID)
}

func projectConfigWithoutEnv(projectSuffix, teamID string) string {
return fmt.Sprintf(`
resource "vercel_project" "test" {
Expand Down