Skip to content

Commit 888492e

Browse files
Terraform Team AutomationNagendraNigade
authored andcommitted
Bug Fix - fix list repositories failure
1 parent 7d0bca0 commit 888492e

File tree

2 files changed

+167
-12
lines changed

2 files changed

+167
-12
lines changed

internal/integrationtest/devops_repository_test.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ var (
5757
}
5858

5959
DevopsRepositoryResourceDependencies = acctest.GenerateResourceFromRepresentationMap("oci_devops_project", "test_project", acctest.Required, acctest.Create, DevopsProjectRepresentation) +
60-
acctest.GenerateResourceFromRepresentationMap("oci_devops_connection", "test_connection", acctest.Required, acctest.Create, DevopsConnectionRepresentation) +
6160
DefinedTagsDependencies +
6261
acctest.GenerateResourceFromRepresentationMap("oci_ons_notification_topic", "test_notification_topic", acctest.Required, acctest.Create, OnsNotificationTopicRepresentation)
6362
)
@@ -72,22 +71,19 @@ func TestDevopsRepositoryResource_basic(t *testing.T) {
7271
compartmentId := utils.GetEnvSettingWithBlankDefault("compartment_ocid")
7372
compartmentIdVariableStr := fmt.Sprintf("variable \"compartment_id\" { default = \"%s\" }\n", compartmentId)
7473

75-
githubAccessTokenVaultId := utils.GetEnvSettingWithBlankDefault("github_access_token_vault_id")
76-
githubAccessTokenVaultIdStr := fmt.Sprintf("variable \"github_access_token_vault_id\" { default = \"%s\" }\n", githubAccessTokenVaultId)
77-
7874
resourceName := "oci_devops_repository.test_repository"
7975
datasourceName := "data.oci_devops_repositories.test_repositories"
8076
singularDatasourceName := "data.oci_devops_repository.test_repository"
8177

8278
var resId, resId2 string
8379
// Save TF content to Create resource with optional properties. This has to be exactly the same as the config part in the "create with optionals" step in the test.
84-
acctest.SaveConfigContent(config+compartmentIdVariableStr+githubAccessTokenVaultIdStr+DevopsRepositoryResourceDependencies+
80+
acctest.SaveConfigContent(config+compartmentIdVariableStr+DevopsRepositoryResourceDependencies+
8581
acctest.GenerateResourceFromRepresentationMap("oci_devops_repository", "test_repository", acctest.Optional, acctest.Create, DevopsRepositoryRepresentation), "devops", "repository", t)
8682

8783
acctest.ResourceTest(t, testAccCheckDevopsRepositoryDestroy, []resource.TestStep{
8884
// verify Create
8985
{
90-
Config: config + compartmentIdVariableStr + githubAccessTokenVaultIdStr + DevopsRepositoryResourceDependencies +
86+
Config: config + compartmentIdVariableStr + DevopsRepositoryResourceDependencies +
9187
acctest.GenerateResourceFromRepresentationMap("oci_devops_repository", "test_repository", acctest.Required, acctest.Create, DevopsRepositoryRepresentation),
9288
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
9389
resource.TestCheckResourceAttr(resourceName, "name", "name"),
@@ -103,11 +99,11 @@ func TestDevopsRepositoryResource_basic(t *testing.T) {
10399

104100
// delete before next Create
105101
{
106-
Config: config + compartmentIdVariableStr + githubAccessTokenVaultIdStr + DevopsRepositoryResourceDependencies,
102+
Config: config + compartmentIdVariableStr + DevopsRepositoryResourceDependencies,
107103
},
108104
//verify Create with optionals
109105
{
110-
Config: config + compartmentIdVariableStr + githubAccessTokenVaultIdStr + DevopsRepositoryResourceDependencies +
106+
Config: config + compartmentIdVariableStr + DevopsRepositoryResourceDependencies +
111107
acctest.GenerateResourceFromRepresentationMap("oci_devops_repository", "test_repository", acctest.Optional, acctest.Create, DevopsRepositoryRepresentation),
112108
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
113109
resource.TestCheckResourceAttrSet(resourceName, "compartment_id"),
@@ -133,7 +129,7 @@ func TestDevopsRepositoryResource_basic(t *testing.T) {
133129

134130
// verify updates to updatable parameters
135131
{
136-
Config: config + compartmentIdVariableStr + githubAccessTokenVaultIdStr + DevopsRepositoryResourceDependencies +
132+
Config: config + compartmentIdVariableStr + DevopsRepositoryResourceDependencies +
137133
acctest.GenerateResourceFromRepresentationMap("oci_devops_repository", "test_repository", acctest.Optional, acctest.Update, DevopsRepositoryRepresentation),
138134
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
139135
resource.TestCheckResourceAttrSet(resourceName, "compartment_id"),
@@ -158,7 +154,7 @@ func TestDevopsRepositoryResource_basic(t *testing.T) {
158154
{
159155
Config: config +
160156
acctest.GenerateDataSourceFromRepresentationMap("oci_devops_repositories", "test_repositories", acctest.Optional, acctest.Update, DevopsDevopsRepositoryDataSourceRepresentation) +
161-
compartmentIdVariableStr + githubAccessTokenVaultIdStr + DevopsRepositoryResourceDependencies +
157+
compartmentIdVariableStr + DevopsRepositoryResourceDependencies +
162158
acctest.GenerateResourceFromRepresentationMap("oci_devops_repository", "test_repository", acctest.Optional, acctest.Update, DevopsRepositoryRepresentation),
163159
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
164160
resource.TestCheckResourceAttr(datasourceName, "repository_collection.#", "1"),
@@ -169,7 +165,7 @@ func TestDevopsRepositoryResource_basic(t *testing.T) {
169165
{
170166
Config: config +
171167
acctest.GenerateDataSourceFromRepresentationMap("oci_devops_repository", "test_repository", acctest.Required, acctest.Create, DevopsDevopsRepositorySingularDataSourceRepresentation) +
172-
compartmentIdVariableStr + githubAccessTokenVaultIdStr + DevopsRepositoryResourceConfig,
168+
compartmentIdVariableStr + DevopsRepositoryResourceConfig,
173169
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
174170
resource.TestCheckResourceAttrSet(singularDatasourceName, "repository_id"),
175171
resource.TestCheckResourceAttrSet(singularDatasourceName, "branch_count"),

internal/service/devops/devops_repositories_data_source.go

Lines changed: 160 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,166 @@ func DevopsRepositoriesDataSource() *schema.Resource {
4747
"items": {
4848
Type: schema.TypeList,
4949
Computed: true,
50-
Elem: tfresource.GetDataSourceItemSchema(DevopsRepositoryResource()),
50+
Elem: &schema.Resource{
51+
52+
Schema: map[string]*schema.Schema{
53+
// Required
54+
"id": {
55+
Type: schema.TypeString,
56+
Required: true,
57+
},
58+
59+
"name": {
60+
Type: schema.TypeString,
61+
Required: true,
62+
},
63+
"project_id": {
64+
Type: schema.TypeString,
65+
Required: true,
66+
ForceNew: true,
67+
},
68+
"repository_type": {
69+
Type: schema.TypeString,
70+
Required: true,
71+
},
72+
73+
// Optional
74+
"default_branch": {
75+
Type: schema.TypeString,
76+
Optional: true,
77+
Computed: true,
78+
},
79+
"defined_tags": {
80+
Type: schema.TypeMap,
81+
Optional: true,
82+
Computed: true,
83+
DiffSuppressFunc: tfresource.DefinedTagsDiffSuppressFunction,
84+
Elem: schema.TypeString,
85+
},
86+
"description": {
87+
Type: schema.TypeString,
88+
Optional: true,
89+
Computed: true,
90+
},
91+
"freeform_tags": {
92+
Type: schema.TypeMap,
93+
Optional: true,
94+
Computed: true,
95+
Elem: schema.TypeString,
96+
},
97+
"mirror_repository_config": {
98+
Type: schema.TypeList,
99+
Optional: true,
100+
Computed: true,
101+
MaxItems: 1,
102+
MinItems: 1,
103+
Elem: &schema.Resource{
104+
Schema: map[string]*schema.Schema{
105+
// Optional
106+
"connector_id": {
107+
Type: schema.TypeString,
108+
Optional: true,
109+
Computed: true,
110+
},
111+
"repository_url": {
112+
Type: schema.TypeString,
113+
Optional: true,
114+
Computed: true,
115+
},
116+
"trigger_schedule": {
117+
Type: schema.TypeList,
118+
Optional: true,
119+
Computed: true,
120+
MaxItems: 1,
121+
MinItems: 1,
122+
Elem: &schema.Resource{
123+
Schema: map[string]*schema.Schema{
124+
// Required
125+
"schedule_type": {
126+
Type: schema.TypeString,
127+
Required: true,
128+
},
129+
130+
// Optional
131+
"custom_schedule": {
132+
Type: schema.TypeString,
133+
Optional: true,
134+
Computed: true,
135+
},
136+
137+
// Computed
138+
},
139+
},
140+
},
141+
142+
// Computed
143+
},
144+
},
145+
},
146+
147+
// Computed
148+
"branch_count": {
149+
Type: schema.TypeInt,
150+
Computed: true,
151+
},
152+
"commit_count": {
153+
Type: schema.TypeInt,
154+
Computed: true,
155+
},
156+
"compartment_id": {
157+
Type: schema.TypeString,
158+
Computed: true,
159+
},
160+
"http_url": {
161+
Type: schema.TypeString,
162+
Computed: true,
163+
},
164+
"lifecycle_details": {
165+
Type: schema.TypeString,
166+
Computed: true,
167+
},
168+
"namespace": {
169+
Type: schema.TypeString,
170+
Computed: true,
171+
},
172+
"project_name": {
173+
Type: schema.TypeString,
174+
Computed: true,
175+
},
176+
"size_in_bytes": {
177+
Type: schema.TypeString,
178+
Computed: true,
179+
},
180+
"ssh_url": {
181+
Type: schema.TypeString,
182+
Computed: true,
183+
},
184+
"state": {
185+
Type: schema.TypeString,
186+
Computed: true,
187+
},
188+
"system_tags": {
189+
Type: schema.TypeMap,
190+
Computed: true,
191+
Elem: schema.TypeString,
192+
},
193+
"time_created": {
194+
Type: schema.TypeString,
195+
Computed: true,
196+
},
197+
"time_updated": {
198+
Type: schema.TypeString,
199+
Computed: true,
200+
},
201+
"trigger_build_events": {
202+
Type: schema.TypeList,
203+
Computed: true,
204+
Elem: &schema.Schema{
205+
Type: schema.TypeString,
206+
},
207+
},
208+
},
209+
},
51210
},
52211
},
53212
},

0 commit comments

Comments
 (0)