Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
docs: add docs for quality gates
Browse files Browse the repository at this point in the history
  • Loading branch information
reinoudk committed Aug 8, 2022
1 parent cc28dc3 commit a7e27a3
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 4 deletions.
52 changes: 52 additions & 0 deletions docs/data-sources/quality_gate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sonarcloud_quality_gate Data Source - terraform-provider-sonarcloud"
subcategory: ""
description: |-
This Data Source retrieves a single Quality Gate for the configured Organization.
---

# sonarcloud_quality_gate (Data Source)

This Data Source retrieves a single Quality Gate for the configured Organization.

## Example Usage

```terraform
data "sonarcloud_quality_gate" "awesome" {
name = "my_awesome_quality_gate"
}
```

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

### Required

- `name` (String) Name of the Quality Gate

### Optional

- `conditions` (Attributes List) The conditions of this quality gate. (see [below for nested schema](#nestedatt--conditions))

### Read-Only

- `gate_id` (Number) Id created by SonarCloud
- `id` (String) Id for Terraform backend
- `is_built_in` (Boolean) Is this Quality gate built in?
- `is_default` (Boolean) Is this the default Quality gate for this project?

<a id="nestedatt--conditions"></a>
### Nested Schema for `conditions`

Optional:

- `op` (String) Operation on which the metric is evaluated must be either: LT, GT

Read-Only:

- `error` (String) The value on which the condition errors.
- `id` (Number) ID of the Condition.
- `metric` (String) The metric on which the condition is based. Must be one of: https://docs.sonarqube.org/latest/user-guide/metric-definitions/


55 changes: 55 additions & 0 deletions docs/data-sources/quality_gates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sonarcloud_quality_gates Data Source - terraform-provider-sonarcloud"
subcategory: ""
description: |-
This data source retrieves all Quality Gates for the configured organization.
---

# sonarcloud_quality_gates (Data Source)

This data source retrieves all Quality Gates for the configured organization.

## Example Usage

```terraform
data "sonarcloud_quality_gates" "all" {}
```

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

### Read-Only

- `id` (String) The index of the Quality Gate
- `quality_gates` (Attributes List) A quality gate (see [below for nested schema](#nestedatt--quality_gates))

<a id="nestedatt--quality_gates"></a>
### Nested Schema for `quality_gates`

Optional:

- `conditions` (Attributes List) The conditions of this quality gate. (see [below for nested schema](#nestedatt--quality_gates--conditions))

Read-Only:

- `gate_id` (Number) Id created by SonarCloud
- `id` (String) Id for Terraform backend
- `is_built_in` (Boolean) Is this Quality gate built in?
- `is_default` (Boolean) Is this the default Quality gate for this project?
- `name` (String) Name of the Quality Gate

<a id="nestedatt--quality_gates--conditions"></a>
### Nested Schema for `quality_gates.conditions`

Optional:

- `op` (String) Operation on which the metric is evaluated must be either: LT, GT

Read-Only:

- `error` (String) The value on which the condition errors.
- `id` (Number) ID of the Condition.
- `metric` (String) The metric on which the condition is based. Must be one of: https://docs.sonarqube.org/latest/user-guide/metric-definitions/


71 changes: 71 additions & 0 deletions docs/resources/quality_gate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sonarcloud_quality_gate Resource - terraform-provider-sonarcloud"
subcategory: ""
description: |-
This resource manages a Quality Gate
---

# sonarcloud_quality_gate (Resource)

This resource manages a Quality Gate

## Example Usage

```terraform
resource "sonarcloud_quality_gate" "awesome" {
name = "My Awesome Quality Gate"
is_default = true
conditions = [
// Less than 100% coverage
{
metric = "coverage"
error = 100
Op = "LT"
},
// Less than 100% coverage on new code
{
metric = "new_coverage"
error = 100
Op = "LT"
}
]
}
```

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

### Required

- `name` (String) Name of the Quality Gate.

### Optional

- `conditions` (Attributes Set) The conditions of this quality gate. (see [below for nested schema](#nestedatt--conditions))
- `is_default` (Boolean) Defines whether the quality gate is the defualt gate for an organization. **WARNING**: Must be assigned to one quality gate per organization at all times

### Read-Only

- `gate_id` (Number) Id computed by SonarCloud servers
- `id` (String) Implicit Terraform ID
- `is_built_in` (Boolean) Defines whether the quality gate is built in.

<a id="nestedatt--conditions"></a>
### Nested Schema for `conditions`

Required:

- `error` (String) The value on which the condition errors.
- `metric` (String) The metric on which the condition is based. Must be one of: https://docs.sonarqube.org/latest/user-guide/metric-definitions/

Optional:

- `op` (String) Operation on which the metric is evaluated must be either: LT, GT

Read-Only:

- `id` (Number) Index/ID of the Condition.


40 changes: 40 additions & 0 deletions docs/resources/quality_gate_selection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "sonarcloud_quality_gate_selection Resource - terraform-provider-sonarcloud"
subcategory: ""
description: |-
This resource selects a quality gate for one or more projects
---

# sonarcloud_quality_gate_selection (Resource)

This resource selects a quality gate for one or more projects

## Example Usage

```terraform
data "sonarcloud_quality_gate" "awesome_qg" {
name = "my_awesome_quality_gate"
}
data "sonarcloud_projects" "all" {}
resource "sonarcloud_quality_gate_selection" "example_quality_gate_selection" {
gate_id = data.sonarcloud_quality_gate.awesome_qg.gate_id
project_keys = [for project in data.sonarcloud_projects.all : project.key if project.name == "My Awesome Project"]
}
```

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

### Required

- `gate_id` (String) The ID of the quality gate that is selected for the project(s).
- `project_keys` (Set of String) The Keys of the projects which have been selected on the referenced quality gate

### Read-Only

- `id` (String) The implicit ID of the resource


6 changes: 3 additions & 3 deletions examples/resources/sonarcloud_quality_gate/resource.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "sonarcloud_quality_gate" "awesome" {
name = "My Awesome Quality Gate"
isDefault = true
name = "My Awesome Quality Gate"
is_default = true
conditions = [
// Less than 100% coverage
{
Expand All @@ -16,4 +16,4 @@ resource "sonarcloud_quality_gate" "awesome" {
}
]

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ data "sonarcloud_quality_gate" "awesome_qg" {
data "sonarcloud_projects" "all" {}

resource "sonarcloud_quality_gate_selection" "example_quality_gate_selection" {
gate_id = data.sonarcloud_quality_gate.awesome_qg.gate_id
gate_id = data.sonarcloud_quality_gate.awesome_qg.gate_id
project_keys = [for project in data.sonarcloud_projects.all : project.key if project.name == "My Awesome Project"]
}

0 comments on commit a7e27a3

Please sign in to comment.