From a7e27a319a6706d029fb57cd55dc387999945010 Mon Sep 17 00:00:00 2001 From: Reinoud Kruithof <2184455+reinoudk@users.noreply.github.com> Date: Mon, 8 Aug 2022 14:28:11 +0200 Subject: [PATCH] docs: add docs for quality gates --- docs/data-sources/quality_gate.md | 52 ++++++++++++++ docs/data-sources/quality_gates.md | 55 ++++++++++++++ docs/resources/quality_gate.md | 71 +++++++++++++++++++ docs/resources/quality_gate_selection.md | 40 +++++++++++ .../sonarcloud_quality_gate/resource.tf | 6 +- .../resource.tf | 2 +- 6 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 docs/data-sources/quality_gate.md create mode 100644 docs/data-sources/quality_gates.md create mode 100644 docs/resources/quality_gate.md create mode 100644 docs/resources/quality_gate_selection.md diff --git a/docs/data-sources/quality_gate.md b/docs/data-sources/quality_gate.md new file mode 100644 index 0000000..edf9adf --- /dev/null +++ b/docs/data-sources/quality_gate.md @@ -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 + +### 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? + + +### 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/ + + diff --git a/docs/data-sources/quality_gates.md b/docs/data-sources/quality_gates.md new file mode 100644 index 0000000..5a561f0 --- /dev/null +++ b/docs/data-sources/quality_gates.md @@ -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 + +### 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)) + + +### 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 + + +### 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/ + + diff --git a/docs/resources/quality_gate.md b/docs/resources/quality_gate.md new file mode 100644 index 0000000..501a572 --- /dev/null +++ b/docs/resources/quality_gate.md @@ -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 + +### 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. + + +### 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. + + diff --git a/docs/resources/quality_gate_selection.md b/docs/resources/quality_gate_selection.md new file mode 100644 index 0000000..deda5b5 --- /dev/null +++ b/docs/resources/quality_gate_selection.md @@ -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 + +### 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 + + diff --git a/examples/resources/sonarcloud_quality_gate/resource.tf b/examples/resources/sonarcloud_quality_gate/resource.tf index 32199c8..85a0bdb 100644 --- a/examples/resources/sonarcloud_quality_gate/resource.tf +++ b/examples/resources/sonarcloud_quality_gate/resource.tf @@ -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 { @@ -16,4 +16,4 @@ resource "sonarcloud_quality_gate" "awesome" { } ] -} \ No newline at end of file +} diff --git a/examples/resources/sonarcloud_quality_gate_selection/resource.tf b/examples/resources/sonarcloud_quality_gate_selection/resource.tf index eccea47..486d2b6 100644 --- a/examples/resources/sonarcloud_quality_gate_selection/resource.tf +++ b/examples/resources/sonarcloud_quality_gate_selection/resource.tf @@ -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"] } \ No newline at end of file