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

build-config/project: updating the name field / making step Optional & Computed #82

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion teamcity/resource_build_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func resourceBuildConfig() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"is_template": {
Type: schema.TypeBool,
Expand Down Expand Up @@ -103,6 +102,7 @@ func resourceBuildConfig() *schema.Resource {
"step": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"step_id": {
Expand Down Expand Up @@ -308,6 +308,10 @@ func resourceBuildConfigUpdate(d *schema.ResourceData, meta interface{}) error {
return err
}

if d.HasChange("name") {
dt.Name = d.Get("name").(string)
}

var changed bool
if d.HasChange("sys_params") || d.HasChange("config_params") || d.HasChange("env_params") {
log.Printf("[DEBUG] resourceBuildConfigUpdate: change detected for params")
Expand Down
8 changes: 5 additions & 3 deletions teamcity/resource_build_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package teamcity_test
import (
"errors"
"fmt"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
"regexp"
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"

api "github.com/cvbarros/go-teamcity/teamcity"
)

Expand Down Expand Up @@ -195,6 +196,7 @@ func TestAccBuildConfig_UpdateBasic(t *testing.T) {
Config: TestAccBuildConfigBasicUpdated,
Check: resource.ComposeTestCheckFunc(
testAccCheckBuildConfigExists(resName, &bc),
resource.TestCheckResourceAttr(resName, "name", "build config updated"),
resource.TestCheckResourceAttr(resName, "description", "build config test desc updated"),
),
},
Expand Down Expand Up @@ -861,7 +863,7 @@ resource "teamcity_project" "build_config_project_test" {
}

resource "teamcity_build_config" "build_configuration_test" {
name = "build config test"
name = "build config updated"
project_id = "${teamcity_project.build_config_project_test.id}"
description = "build config test desc updated"
settings {
Expand Down
5 changes: 4 additions & 1 deletion teamcity/resource_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ func resourceProject() *schema.Resource {
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"description": {
Type: schema.TypeString,
Expand Down Expand Up @@ -85,6 +84,10 @@ func resourceProjectUpdate(d *schema.ResourceData, meta interface{}) error {
return err
}

if d.HasChange("name") {
dt.Name = d.Get("name").(string)
}

if v, ok := d.GetOk("description"); ok {
dt.Description = v.(string)
}
Expand Down
7 changes: 4 additions & 3 deletions teamcity/resource_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestAccTeamcityProject_Update(t *testing.T) {
Providers: testAccProviders,
CheckDestroy: testAccCheckTeamcityProjectDestroy,
Steps: []resource.TestStep{
resource.TestStep{
{
Config: testAccTeamcityProjectFull,
Check: resource.ComposeTestCheckFunc(
testAccCheckTeamcityProjectExists(resName, &p),
Expand All @@ -113,10 +113,11 @@ func TestAccTeamcityProject_Update(t *testing.T) {
testAccCheckProjectParameter(&p, api.ParameterTypes.System, "param6", "sys_value2"),
),
},
resource.TestStep{
{
Config: testAccTeamcityProjectFullUpdated,
Check: resource.ComposeTestCheckFunc(
testAccCheckTeamcityProjectExists(resName, &p),
resource.TestCheckResourceAttr(resName, "description", "updated project"),
Copy link
Owner

Choose a reason for hiding this comment

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

Would this attr check be name or description?

resource.TestCheckResourceAttr(resName, "description", "Test Project Updated"),
resource.TestCheckResourceAttr(resName, "config_params.param1", "config_value1"),
resource.TestCheckResourceAttr(resName, "config_params.param2", "config_value2"),
Expand Down Expand Up @@ -240,7 +241,7 @@ resource "teamcity_project" "testproj" {

const testAccTeamcityProjectFullUpdated = `
resource "teamcity_project" "testproj" {
name = "test_project"
name = "updated project"
description = "Test Project Updated"

config_params = {
Expand Down