Skip to content

Commit 0f83332

Browse files
authored
Merge pull request #7 from enthought/add-repository-resource
Add repository resource and data source
2 parents 0640af2 + 4c314da commit 0f83332

File tree

14 files changed

+972
-60
lines changed

14 files changed

+972
-60
lines changed

code_generator/provider_code_spec.json

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,83 @@
181181
}
182182
]
183183
}
184+
},
185+
{
186+
"name": "repository",
187+
"schema": {
188+
"attributes": [
189+
{
190+
"name": "description",
191+
"string": {
192+
"computed_optional_required": "computed_optional",
193+
"default" : {
194+
"static": ""
195+
},
196+
"description": "Markdown description"
197+
}
198+
},
199+
{
200+
"name": "name",
201+
"string": {
202+
"computed_optional_required": "required",
203+
"description": "Repository name",
204+
"plan_modifiers": [
205+
{
206+
"custom": {
207+
"imports": [
208+
{
209+
"path": "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
210+
}
211+
],
212+
"schema_definition": "stringplanmodifier.RequiresReplace()"
213+
}
214+
}
215+
]
216+
}
217+
},
218+
{
219+
"name": "namespace",
220+
"string": {
221+
"computed_optional_required": "required",
222+
"description": "Repository namespace. Should be an organization name or username",
223+
"plan_modifiers": [
224+
{
225+
"custom": {
226+
"imports": [
227+
{
228+
"path": "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
229+
}
230+
],
231+
"schema_definition": "stringplanmodifier.RequiresReplace()"
232+
}
233+
}
234+
]
235+
}
236+
},
237+
{
238+
"name": "visibility",
239+
"string": {
240+
"computed_optional_required": "computed_optional",
241+
"default" : {
242+
"static": "private"
243+
},
244+
"description": "Repository visibility. Should be private or public. Defaults to private.",
245+
"validators": [
246+
{
247+
"custom": {
248+
"imports": [
249+
{
250+
"path": "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
251+
}
252+
],
253+
"schema_definition": "stringvalidator.OneOf([]string{\"private\", \"public\"}...)"
254+
}
255+
}
256+
]
257+
}
258+
}
259+
]
260+
}
184261
}
185262
],
186263
"datasources": [
@@ -204,6 +281,41 @@
204281
}
205282
]
206283
}
284+
},
285+
{
286+
"name": "repository",
287+
"schema": {
288+
"attributes": [
289+
{
290+
"name": "description",
291+
"string": {
292+
"computed_optional_required": "computed",
293+
"description": "Markdown description"
294+
}
295+
},
296+
{
297+
"name": "name",
298+
"string": {
299+
"computed_optional_required": "required",
300+
"description": "Repository name"
301+
}
302+
},
303+
{
304+
"name": "namespace",
305+
"string": {
306+
"computed_optional_required": "required",
307+
"description": "Repository namespace. Should be an organization name or username"
308+
}
309+
},
310+
{
311+
"name": "visibility",
312+
"string": {
313+
"computed_optional_required": "computed",
314+
"description": "Repository visibility. Should be private or public."
315+
}
316+
}
317+
]
318+
}
207319
}
208320
],
209321
"version": "0.1"

docs/data-sources/repository.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "quay_repository Data Source - quay"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# quay_repository (Data Source)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
data "quay_organization" "main" {
17+
name = "main"
18+
}
19+
20+
data "quay_repository" "test" {
21+
name = "test"
22+
namespace = data.quay_organization.main.name
23+
}
24+
```
25+
26+
<!-- schema generated by tfplugindocs -->
27+
## Schema
28+
29+
### Required
30+
31+
- `name` (String) Repository name
32+
- `namespace` (String) Repository namespace. Should be an organization name or username
33+
34+
### Read-Only
35+
36+
- `description` (String) Markdown description
37+
- `visibility` (String) Repository visibility. Should be private or public.

docs/resources/repository.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "quay_repository Resource - quay"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# quay_repository (Resource)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
resource "quay_organization" "main" {
17+
name = "main"
18+
19+
}
20+
21+
resource "quay_repository" "test" {
22+
name = "test"
23+
namespace = quay_organization.main.name
24+
visibility = "private"
25+
description = "test"
26+
}
27+
```
28+
29+
<!-- schema generated by tfplugindocs -->
30+
## Schema
31+
32+
### Required
33+
34+
- `name` (String) Repository name
35+
- `namespace` (String) Repository namespace. Should be an organization name or username
36+
37+
### Optional
38+
39+
- `description` (String) Markdown description
40+
- `visibility` (String) Repository visibility. Should be private or public. Defaults to private.
41+
42+
## Import
43+
44+
Import is supported using the following syntax:
45+
46+
```shell
47+
# An organization can be imported using its name.
48+
terraform import quay_repository.test main/test
49+
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
data "quay_organization" "main" {
2+
name = "main"
3+
}
4+
5+
data "quay_repository" "test" {
6+
name = "test"
7+
namespace = data.quay_organization.main.name
8+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# An organization can be imported using its name.
2+
terraform import quay_repository.test main/test
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "quay_organization" "main" {
2+
name = "main"
3+
4+
}
5+
6+
resource "quay_repository" "test" {
7+
name = "test"
8+
namespace = quay_organization.main.name
9+
visibility = "private"
10+
description = "test"
11+
}

internal/datasource_repository/repository_data_source_gen.go

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/provider/provider.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func (p *quayProvider) Metadata(_ context.Context, _ provider.MetadataRequest, r
151151
func (p *quayProvider) DataSources(_ context.Context) []func() datasource.DataSource {
152152
return []func() datasource.DataSource{
153153
NewOrganizationDataSource,
154+
NewRepositoryDataSource,
154155
}
155156
}
156157

@@ -159,5 +160,6 @@ func (p *quayProvider) Resources(_ context.Context) []func() resource.Resource {
159160
NewOrganizationResource,
160161
NewOrganizationTeamResource,
161162
NewOrganizationRobotResource,
163+
NewRepositoryResource,
162164
}
163165
}

0 commit comments

Comments
 (0)