Skip to content

Commit

Permalink
Merge pull request #7 from enthought/add-repository-resource
Browse files Browse the repository at this point in the history
Add repository resource and data source
  • Loading branch information
ddebeau authored Aug 26, 2024
2 parents 0640af2 + 4c314da commit 0f83332
Show file tree
Hide file tree
Showing 14 changed files with 972 additions and 60 deletions.
112 changes: 112 additions & 0 deletions code_generator/provider_code_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,83 @@
}
]
}
},
{
"name": "repository",
"schema": {
"attributes": [
{
"name": "description",
"string": {
"computed_optional_required": "computed_optional",
"default" : {
"static": ""
},
"description": "Markdown description"
}
},
{
"name": "name",
"string": {
"computed_optional_required": "required",
"description": "Repository name",
"plan_modifiers": [
{
"custom": {
"imports": [
{
"path": "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
}
],
"schema_definition": "stringplanmodifier.RequiresReplace()"
}
}
]
}
},
{
"name": "namespace",
"string": {
"computed_optional_required": "required",
"description": "Repository namespace. Should be an organization name or username",
"plan_modifiers": [
{
"custom": {
"imports": [
{
"path": "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
}
],
"schema_definition": "stringplanmodifier.RequiresReplace()"
}
}
]
}
},
{
"name": "visibility",
"string": {
"computed_optional_required": "computed_optional",
"default" : {
"static": "private"
},
"description": "Repository visibility. Should be private or public. Defaults to private.",
"validators": [
{
"custom": {
"imports": [
{
"path": "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
}
],
"schema_definition": "stringvalidator.OneOf([]string{\"private\", \"public\"}...)"
}
}
]
}
}
]
}
}
],
"datasources": [
Expand All @@ -204,6 +281,41 @@
}
]
}
},
{
"name": "repository",
"schema": {
"attributes": [
{
"name": "description",
"string": {
"computed_optional_required": "computed",
"description": "Markdown description"
}
},
{
"name": "name",
"string": {
"computed_optional_required": "required",
"description": "Repository name"
}
},
{
"name": "namespace",
"string": {
"computed_optional_required": "required",
"description": "Repository namespace. Should be an organization name or username"
}
},
{
"name": "visibility",
"string": {
"computed_optional_required": "computed",
"description": "Repository visibility. Should be private or public."
}
}
]
}
}
],
"version": "0.1"
Expand Down
37 changes: 37 additions & 0 deletions docs/data-sources/repository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "quay_repository Data Source - quay"
subcategory: ""
description: |-
---

# quay_repository (Data Source)



## Example Usage

```terraform
data "quay_organization" "main" {
name = "main"
}
data "quay_repository" "test" {
name = "test"
namespace = data.quay_organization.main.name
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Repository name
- `namespace` (String) Repository namespace. Should be an organization name or username

### Read-Only

- `description` (String) Markdown description
- `visibility` (String) Repository visibility. Should be private or public.
49 changes: 49 additions & 0 deletions docs/resources/repository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "quay_repository Resource - quay"
subcategory: ""
description: |-
---

# quay_repository (Resource)



## Example Usage

```terraform
resource "quay_organization" "main" {
name = "main"
email = "[email protected]"
}
resource "quay_repository" "test" {
name = "test"
namespace = quay_organization.main.name
visibility = "private"
description = "test"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Repository name
- `namespace` (String) Repository namespace. Should be an organization name or username

### Optional

- `description` (String) Markdown description
- `visibility` (String) Repository visibility. Should be private or public. Defaults to private.

## Import

Import is supported using the following syntax:

```shell
# An organization can be imported using its name.
terraform import quay_repository.test main/test
```
8 changes: 8 additions & 0 deletions examples/data-sources/quay_repository/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
data "quay_organization" "main" {
name = "main"
}

data "quay_repository" "test" {
name = "test"
namespace = data.quay_organization.main.name
}
2 changes: 2 additions & 0 deletions examples/resources/quay_repository/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# An organization can be imported using its name.
terraform import quay_repository.test main/test
11 changes: 11 additions & 0 deletions examples/resources/quay_repository/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "quay_organization" "main" {
name = "main"
email = "[email protected]"
}

resource "quay_repository" "test" {
name = "test"
namespace = quay_organization.main.name
visibility = "private"
description = "test"
}
44 changes: 44 additions & 0 deletions internal/datasource_repository/repository_data_source_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (p *quayProvider) Metadata(_ context.Context, _ provider.MetadataRequest, r
func (p *quayProvider) DataSources(_ context.Context) []func() datasource.DataSource {
return []func() datasource.DataSource{
NewOrganizationDataSource,
NewRepositoryDataSource,
}
}

Expand All @@ -159,5 +160,6 @@ func (p *quayProvider) Resources(_ context.Context) []func() resource.Resource {
NewOrganizationResource,
NewOrganizationTeamResource,
NewOrganizationRobotResource,
NewRepositoryResource,
}
}
Loading

0 comments on commit 0f83332

Please sign in to comment.