Skip to content

Commit b39308d

Browse files
authored
add deprecation messages to token and access token attributes in repo… (#123)
* add deprecation messages to token and access token attributes in repo association resources * fix approval channel test * deprecate repo with token test * unique blueprint display name
1 parent 5776911 commit b39308d

9 files changed

+49
-46
lines changed

docs/resources/gitlab_enterprise_repository_space_association.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ resource "torque_gitlab_enterprise_repository_space_association" "repository" {
5050

5151
### Optional
5252

53-
- `token` (String) Authentication Token to the project/repository. If omitted, existing credentials provided in the credential_name field will be used for authentication. If provided, a new credentials object will be created.
53+
- `token` (String, Deprecated) Authentication Token to the project/repository. If omitted, existing credentials provided in the credential_name field will be used for authentication. If provided, a new credentials object will be created.

docs/resources/repository_space_association.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ resource "torque_repository_space_association" "repository" {
4949

5050
### Optional
5151

52-
- `access_token` (String) Personal Access Token (PAT) to authenticate with to the repository. Credentials will be automatically created with the specified token, or use existing credentials instead.
52+
- `access_token` (String, Deprecated) Personal Access Token (PAT) to authenticate with to the repository. Credentials will be automatically created with the specified token, or use existing credentials instead.
5353
- `branch` (String) Repository branch to use for blueprints and automation assets
5454
- `credential_name` (String) The name of existing credentials to use.

internal/provider/resources/space_gitlab_enterprise_repository_resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ func (r *TorqueSpaceGitlabEnterpriseRepositoryResource) Schema(ctx context.Conte
7272
PlanModifiers: []planmodifier.String{
7373
stringplanmodifier.RequiresReplace(),
7474
},
75+
DeprecationMessage: "The token attribute is deprecated and will be removed in a future release. Use the torque_git_credentials resource to store the token and reference it in this resource using the credential_name attribute instead.",
7576
},
7677
"branch": schema.StringAttribute{
7778
Description: "Repository branch to use for blueprints and automation assets",

internal/provider/resources/space_repository_resource.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func (r *TorqueSpaceRepositoryResource) Schema(ctx context.Context, req resource
6969
PlanModifiers: []planmodifier.String{
7070
stringplanmodifier.RequiresReplace(),
7171
},
72+
DeprecationMessage: "The access_token attribute is deprecated and will be removed in a future release. Use the torque_git_credentials resource to store the token and reference it in this resource using the credential_name attribute instead.",
7273
Validators: []validator.String{
7374
// Validate only this attribute or other_attr is configured or neither.
7475
stringvalidator.ConflictsWith(path.Expressions{

internal/provider/tests/catalog_item_resource_test.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ const (
1919
blueprint_name = "ec2"
2020
repository_name = "TerraformProviderAcceptanceTests"
2121
new_blueprint_name = "rds"
22+
display_name = "display_name"
2223
)
2324

2425
func TestCatalogItemResource(t *testing.T) {
2526
spaceName := os.Getenv("TORQUE_SPACE")
2627
var unique_blueprint_name = blueprint_name + "_" + index
2728
var new_unique_blueprint_name = new_blueprint_name + "_" + index
28-
29+
var unique_display_name = display_name + "_" + index
2930
resource.Test(t, resource.TestCase{
3031
PreCheck: func() { testAccPreCheck(t) },
3132
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
@@ -78,16 +79,16 @@ func TestCatalogItemResource(t *testing.T) {
7879
{
7980
Config: providerConfig + fmt.Sprintf(`
8081
resource "torque_catalog_item" "catalog_item" {
81-
space_name = "%s"
82-
blueprint_name = "%s"
83-
repository_name = "%s"
84-
display_name ="display_name"
82+
space_name = "%s"
83+
blueprint_name = "%s"
84+
repository_name = "%s"
85+
display_name = "%s"
8586
default_duration = "PT3H"
86-
default_extend = "PT9H"
87-
max_duration = "P1DT6H"
88-
labels = ["k8s"]
87+
default_extend = "PT9H"
88+
max_duration = "P1DT6H"
89+
labels = ["k8s"]
8990
}
90-
`, spaceName, new_unique_blueprint_name, repository_name),
91+
`, spaceName, new_unique_blueprint_name, repository_name, unique_display_name),
9192
Check: resource.ComposeAggregateTestCheckFunc(
9293
resource.TestCheckResourceAttr("torque_catalog_item.catalog_item", "space_name", spaceName),
9394
resource.TestCheckResourceAttr("torque_catalog_item.catalog_item", "blueprint_name", new_unique_blueprint_name),

internal/provider/tests/git_repo_test.go

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package tests
55

66
import (
77
"fmt"
8-
"os"
98
"testing"
109

1110
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
@@ -50,34 +49,35 @@ func TestGitRepoWithCreds(t *testing.T) {
5049
})
5150
}
5251

53-
func TestGitRepoWithToken(t *testing.T) {
54-
access_token := os.Getenv("GITHUB_TOKEN")
55-
resource.Test(t, resource.TestCase{
56-
PreCheck: func() { testAccPreCheck(t) },
57-
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
58-
Steps: []resource.TestStep{
59-
// Create and Read testing
60-
{
61-
Config: providerConfig + fmt.Sprintf(`
62-
resource "torque_repository_space_association" "repository_with_token" {
63-
space_name = "%s"
64-
repository_url = "%s"
65-
access_token = "%s"
66-
repository_type = "%s"
67-
branch = "%s"
68-
repository_name = "%s"
69-
}
70-
`, fullSpaceName, repository_url, access_token, repository_type, branch, repo_name),
71-
Check: resource.ComposeAggregateTestCheckFunc(
72-
resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "space_name", fullSpaceName),
73-
resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "repository_name", repo_name),
74-
resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "branch", branch),
75-
resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "repository_url", repository_url),
76-
resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "repository_type", repository_type),
77-
),
78-
},
79-
// Update and Read testing
80-
// Delete testing automatically occurs in TestCase
81-
},
82-
})
83-
}
52+
// Deprecated
53+
// func TestGitRepoWithToken(t *testing.T) {
54+
// access_token := os.Getenv("GITHUB_TOKEN")
55+
// resource.Test(t, resource.TestCase{
56+
// PreCheck: func() { testAccPreCheck(t) },
57+
// ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
58+
// Steps: []resource.TestStep{
59+
// // Create and Read testing
60+
// {
61+
// Config: providerConfig + fmt.Sprintf(`
62+
// resource "torque_repository_space_association" "repository_with_token" {
63+
// space_name = "%s"
64+
// repository_url = "%s"
65+
// access_token = "%s"
66+
// repository_type = "%s"
67+
// branch = "%s"
68+
// repository_name = "%s"
69+
// }
70+
// `, fullSpaceName, repository_url, access_token, repository_type, branch, repo_name),
71+
// Check: resource.ComposeAggregateTestCheckFunc(
72+
// resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "space_name", fullSpaceName),
73+
// resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "repository_name", repo_name),
74+
// resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "branch", branch),
75+
// resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "repository_url", repository_url),
76+
// resource.TestCheckResourceAttr("torque_repository_space_association.repository_with_token", "repository_type", repository_type),
77+
// ),
78+
// },
79+
// // Update and Read testing
80+
// // Delete testing automatically occurs in TestCase
81+
// },
82+
// })
83+
// }

internal/provider/tests/torque_email_approval_channel_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
func TestTorqueEmailApprovalChannel(t *testing.T) {
1717
const (
18-
approval_channel = "approval_channel"
18+
approval_channel = "email_approval_channel"
1919
description = "description"
2020
new_description = "new_description"
2121
approver = "terraformtester@quali.com"

internal/provider/tests/torque_servicenow_approval_channel_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
func TestTorqueServiceNowApprovalChannel(t *testing.T) {
1717
const (
18-
approval_channel = "approval_channel"
18+
approval_channel = "snow_approval_channel"
1919
description = "description"
2020
new_description = "new_description"
2121
approver = "terraformtester@quali.com"

internal/provider/tests/torque_teams_approval_channel_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
func TestTorqueTeamsApprovalChannel(t *testing.T) {
1717
const (
18-
approval_channel = "approval_channel"
18+
approval_channel = "teams_approval_channel"
1919
description = "description"
2020
new_description = "new_description"
2121
approver = "terraformtester@quali.com"

0 commit comments

Comments
 (0)