From 99c543a03cb73998a6a111450375706e5a0004f3 Mon Sep 17 00:00:00 2001 From: Pete Tomasik Date: Thu, 5 Dec 2024 06:36:43 -0500 Subject: [PATCH] SUP-2388 - Update docs with templates, import blocks (#588) * Create template file for resources * Use override template for organization_rule, regen doc * Update imports * Update templates * Regen docs --- docs/resources/cluster.md | 11 +- docs/resources/cluster_default_queue.md | 11 +- docs/resources/cluster_queue.md | 11 +- docs/resources/organization.md | 13 +- docs/resources/organization_banner.md | 12 +- docs/resources/organization_rule.md | 57 ++++---- docs/resources/pipeline.md | 11 +- docs/resources/pipeline_schedule.md | 11 +- docs/resources/pipeline_team.md | 11 +- docs/resources/pipeline_template.md | 11 +- docs/resources/team.md | 11 +- docs/resources/team_member.md | 11 +- docs/resources/test_suite.md | 30 ++++ docs/resources/test_suite_team.md | 11 +- .../resources/buildkite_cluster/import.tf | 4 + .../buildkite_cluster_default_queue/import.tf | 4 + .../buildkite_cluster_queue/import.tf | 4 + .../buildkite_organization/import.sh | 2 +- .../buildkite_organization/import.tf | 4 + .../buildkite_organization_banner/import.sh | 1 - .../buildkite_organization_banner/import.tf | 4 + .../buildkite_organization_rule/import.sh | 3 +- .../buildkite_organization_rule/import.tf | 4 + .../resources/buildkite_pipeline/import.tf | 4 + .../buildkite_pipeline_schedule/import.tf | 4 + .../buildkite_pipeline_team/import.tf | 4 + .../buildkite_pipeline_template/import.tf | 4 + examples/resources/buildkite_team/import.tf | 4 + .../resources/buildkite_team_member/import.tf | 4 + .../resources/buildkite_test_suite/import.sh | 16 +++ .../resources/buildkite_test_suite/import.tf | 4 + .../buildkite_test_suite_team/import.tf | 4 + templates/resources.md.tmpl | 29 ++++ templates/resources/organization.md.tmpl | 29 ++++ templates/resources/organization_rule.md | 129 ------------------ templates/resources/organization_rule.md.tmpl | 31 +++++ 36 files changed, 334 insertions(+), 184 deletions(-) create mode 100644 examples/resources/buildkite_cluster/import.tf create mode 100644 examples/resources/buildkite_cluster_default_queue/import.tf create mode 100644 examples/resources/buildkite_cluster_queue/import.tf create mode 100644 examples/resources/buildkite_organization/import.tf create mode 100644 examples/resources/buildkite_organization_banner/import.tf create mode 100644 examples/resources/buildkite_organization_rule/import.tf create mode 100644 examples/resources/buildkite_pipeline/import.tf create mode 100644 examples/resources/buildkite_pipeline_schedule/import.tf create mode 100644 examples/resources/buildkite_pipeline_team/import.tf create mode 100644 examples/resources/buildkite_pipeline_template/import.tf create mode 100644 examples/resources/buildkite_team/import.tf create mode 100644 examples/resources/buildkite_team_member/import.tf create mode 100644 examples/resources/buildkite_test_suite/import.sh create mode 100644 examples/resources/buildkite_test_suite/import.tf create mode 100644 examples/resources/buildkite_test_suite_team/import.tf create mode 100644 templates/resources.md.tmpl create mode 100644 templates/resources/organization.md.tmpl delete mode 100644 templates/resources/organization_rule.md create mode 100644 templates/resources/organization_rule.md.tmpl diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 04bd92c9..8f5da2fb 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -60,8 +60,7 @@ emoji itself, such as 🚀. ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a cluster resource using the GraphQL ID # @@ -80,3 +79,11 @@ Import is supported using the following syntax: # } terraform import buildkite_cluster.primary Q2x1c3Rlci0tLTI3ZmFmZjA4LTA3OWEtNDk5ZC1hMmIwLTIzNmY3NWFkMWZjYg== ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_cluster.primary + id = "Q2x1c3Rlci0tLTI3ZmFmZjA4LTA3OWEtNDk5ZC1hMmIwLTIzNmY3NWFkMWZjYg==" +} +``` diff --git a/docs/resources/cluster_default_queue.md b/docs/resources/cluster_default_queue.md index 2d9c427f..3e918767 100644 --- a/docs/resources/cluster_default_queue.md +++ b/docs/resources/cluster_default_queue.md @@ -50,8 +50,7 @@ resource "buildkite_cluster_default_queue" "primary" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a clusters default queue resource using the GraphQL ID of the cluster itself # @@ -70,3 +69,11 @@ Import is supported using the following syntax: # } terraform import buildkite_cluster_default_queue.primary Q2x1c3Rlci0tLTI3ZmFmZjA4LTA3OWEtNDk5ZC1hMmIwLTIzNmY3NWFkMWZjYg== ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_cluster_default_queue.primary + id = "Q2x1c3Rlci0tLTI3ZmFmZjA4LTA3OWEtNDk5ZC1hMmIwLTIzNmY3NWFkMWZjYg==" +} +``` diff --git a/docs/resources/cluster_queue.md b/docs/resources/cluster_queue.md index c35922cd..fc0862f7 100644 --- a/docs/resources/cluster_queue.md +++ b/docs/resources/cluster_queue.md @@ -57,8 +57,7 @@ resource "buildkite_cluster_queue" "default" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a cluster queue resource using the GraphQL ID along with its respective cluster UUID # @@ -79,3 +78,11 @@ Import is supported using the following syntax: # } terraform import buildkite_cluster_queue.test Q2x1c3RlclF1ZXVlLS0tYjJiOGRhNTEtOWY5My00Y2MyLTkyMjktMGRiNzg3ZDQzOTAz,35498aaf-ad05-4fa5-9a07-91bf6cacd2bd ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_cluster_queue.test + id = "Q2x1c3RlclF1ZXVlLS0tYjJiOGRhNTEtOWY5My00Y2MyLTkyMjktMGRiNzg3ZDQzOTAz,35498aaf-ad05-4fa5-9a07-91bf6cacd2bd" +} +``` diff --git a/docs/resources/organization.md b/docs/resources/organization.md index 72fcb96b..3f76c210 100644 --- a/docs/resources/organization.md +++ b/docs/resources/organization.md @@ -40,9 +40,16 @@ resource "buildkite_organization" "settings" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `organization-slug`. For example: ```shell # import the organization settings via the organization slug -terraform import buildkite_organization.settings +terraform import buildkite_organization.settings my-buildkite-organization +``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `organization-slug`. For example: +```terraform +import { + to = buildkite_organization.settings + id = "my-buildkite-organization" +} ``` diff --git a/docs/resources/organization_banner.md b/docs/resources/organization_banner.md index 649d08dd..0d4c3d9e 100644 --- a/docs/resources/organization_banner.md +++ b/docs/resources/organization_banner.md @@ -35,8 +35,7 @@ resource "buildkite_organization_banner" "banner" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import an organization banner resource using the banner's GraphQL ID # @@ -52,6 +51,13 @@ Import is supported using the following syntax: # } # } # } - terraform import buildkite_organization_banner.banner T3JnYW5pemF0aW9uQmFubmVyLS0tNjZlMmE5YzktM2IzMy00OGE5LTk1NjItMzY2YzMwNzYzN2Uz ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_organization_banner.banner + id = "T3JnYW5pemF0aW9uQmFubmVyLS0tNjZlMmE5YzktM2IzMy00OGE5LTk1NjItMzY2YzMwNzYzN2Uz" +} +``` diff --git a/docs/resources/organization_rule.md b/docs/resources/organization_rule.md index d67e3ba4..bc851c63 100644 --- a/docs/resources/organization_rule.md +++ b/docs/resources/organization_rule.md @@ -11,7 +11,7 @@ description: |- ~> Rules is a feature that is currently in development and enabled on an opt-in basis for early access. To have this enabled for your organization for utilizing this data source, please reach out to Buildkite's [Support Team](mailto:support%40buildkite.com). -An Organization Rule allows specifying explicit rules between two Buildkite resources and the desired effect/action. +An Organization Rule allows specifying explicit rules between two Buildkite resources and the desired effect/action. More information on organization rules can be found in the [documentation](https://buildkite.com/docs/pipelines/rules). @@ -20,38 +20,39 @@ More information on organization rules can be found in the [documentation](https ```terraform # Creates a TRIGGER_BUILD organization rule with required attributes resource "buildkite_organization_rule" "trigger_build_test_dev" { - type = "pipeline.trigger_build.pipeline" - value = jsonencode({ - source_pipeline = buildkite_pipeline.app_dev_deploy.uuid - target_pipeline = buildkite_pipeline.app_test_ci.uuid - }) + type = "pipeline.trigger_build.pipeline" + value = jsonencode({ + source_pipeline = buildkite_pipeline.app_dev_deploy.uuid + target_pipeline = buildkite_pipeline.app_test_ci.uuid + }) } # Creates a ARTIFACTS_READ organization rule with an optional description resource "buildkite_organization_rule" "artifacts_read_test_dev" { - type = "pipeline.artifacts_read.pipeline" - description = "A rule to allow artifact reads by app_test_ci to app_dev_deploy" - value = jsonencode({ - source_pipeline = buildkite_pipeline.app_test_ci.uuid - target_pipeline = buildkite_pipeline.app_dev_deploy.uuid - }) + type = "pipeline.artifacts_read.pipeline" + description = "A rule to allow artifact reads by app_test_ci to app_dev_deploy" + value = jsonencode({ + source_pipeline = buildkite_pipeline.app_test_ci.uuid + target_pipeline = buildkite_pipeline.app_dev_deploy.uuid + }) } # Creates a TRIGGER_BUILD organization rule with an optional description and conditions resource "buildkite_organization_rule" "trigger_build_test_dev_cond" { - type = "pipeline.trigger_build.pipeline" - description = "A rule to allow app_dev_deploy to trigger app_test_ci builds with conditions" - value = jsonencode({ - source_pipeline = buildkite_pipeline.app_dev_deploy.uuid - target_pipeline = buildkite_pipeline.app_test_ci.uuid - conditions = [ - "source.build.creator.teams includes 'deploy'", - "source.build.branch == 'main'" - ] - }) + type = "pipeline.trigger_build.pipeline" + description = "A rule to allow app_dev_deploy to trigger app_test_ci builds with conditions" + value = jsonencode({ + source_pipeline = buildkite_pipeline.app_dev_deploy.uuid + target_pipeline = buildkite_pipeline.app_test_ci.uuid + conditions = [ + "source.build.creator.teams includes 'deploy'", + "source.build.branch == 'main'" + ] + }) } ``` + ## Schema ### Required @@ -76,8 +77,7 @@ resource "buildkite_organization_rule" "trigger_build_test_dev_cond" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import an organization rule resource using the rules GraphQL ID # @@ -124,6 +124,13 @@ Import is supported using the following syntax: # } # } # } - terraform import buildkite_organization_rule.artifact_read UnVsZS0tLTAxOTE5NmU2LWNiNjctNzZiZi1iYzAyLTVhYzFiNzhhMWMyOA== ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_organization_rule.artifact_read + id = "UnVsZS0tLTAxOTE5NmU2LWNiNjctNzZiZi1iYzAyLTVhYzFiNzhhMWMyOA==" +} +``` diff --git a/docs/resources/pipeline.md b/docs/resources/pipeline.md index f6556b42..69fbf620 100644 --- a/docs/resources/pipeline.md +++ b/docs/resources/pipeline.md @@ -132,10 +132,17 @@ Optional: ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a pipeline resource using the pipelines GraphQL ID # GraphQL ID for a pipeline can be found on its settings page terraform import buildkite_pipeline.pipeline UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ= ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_pipeline.pipeline + id = "UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ=" +} +``` diff --git a/docs/resources/pipeline_schedule.md b/docs/resources/pipeline_schedule.md index 32eaec8a..689174e7 100644 --- a/docs/resources/pipeline_schedule.md +++ b/docs/resources/pipeline_schedule.md @@ -55,8 +55,7 @@ resource "buildkite_pipeline_schedule" "nightly" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a pipeline schedule resource using the schedules GraphQL ID # @@ -81,3 +80,11 @@ Import is supported using the following syntax: # } terraform import buildkite_pipeline_schedule.test UGlwZWxpgm5Tf2hhZHVsZ35tLWRk4DdmN7c4LTA5M2ItNDM9YS0gMWE0LTAwZDUgYTAxYvRf49== ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_pipeline_schedule.test + id = "UGlwZWxpgm5Tf2hhZHVsZ35tLWRk4DdmN7c4LTA5M2ItNDM9YS0gMWE0LTAwZDUgYTAxYvRf49==" +} +``` diff --git a/docs/resources/pipeline_team.md b/docs/resources/pipeline_team.md index 0012345f..410fe05f 100644 --- a/docs/resources/pipeline_team.md +++ b/docs/resources/pipeline_team.md @@ -49,8 +49,7 @@ resource "buildkite_pipeline_team" "pipeline_team" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a pipeline team resource using the GraphQL ID # @@ -68,3 +67,11 @@ Import is supported using the following syntax: # } terraform import buildkite_pipeline_team.guests VGVhbS0tLWU1YjQyMDQyLTUzN2QtNDZjNi04MjY0LTliZjFkMzkyYjZkNQ== ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_pipeline_team.guests + id = "VGVhbS0tLWU1YjQyMDQyLTUzN2QtNDZjNi04MjY0LTliZjFkMzkyYjZkNQ==" +} +``` diff --git a/docs/resources/pipeline_template.md b/docs/resources/pipeline_template.md index ece3a8fe..f3440200 100644 --- a/docs/resources/pipeline_template.md +++ b/docs/resources/pipeline_template.md @@ -49,8 +49,7 @@ resource "buildkite_pipeline_template" "template_full" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a pipeline template resource using the templates GraphQL ID # @@ -69,3 +68,11 @@ Import is supported using the following syntax: # } terraform import buildkite_pipeline_template.template UGlwZWxpbmVUZW1wbGF0ZS0tLWU0YWQ3YjdjLTljZDYtNGM0MS1hYWE0LTY2ZmI3ODY0MTMwNw== ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_pipeline_template.template + id = "UGlwZWxpbmVUZW1wbGF0ZS0tLWU0YWQ3YjdjLTljZDYtNGM0MS1hYWE0LTY2ZmI3ODY0MTMwNw==" +} +``` diff --git a/docs/resources/team.md b/docs/resources/team.md index 8d28f850..4e7f1319 100644 --- a/docs/resources/team.md +++ b/docs/resources/team.md @@ -44,8 +44,7 @@ resource "buildkite_team" "everyone" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a team resource using the GraphQL ID # @@ -64,3 +63,11 @@ Import is supported using the following syntax: # } terraform import buildkite_team.everyone UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ= ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_team.everyone + id = "UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ=" +} +``` diff --git a/docs/resources/team_member.md b/docs/resources/team_member.md index 643e16d3..81c61fbb 100644 --- a/docs/resources/team_member.md +++ b/docs/resources/team_member.md @@ -43,8 +43,7 @@ resource "buildkite_team_member" "a_smith" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a team member resource using the GraphQL ID # @@ -68,3 +67,11 @@ Import is supported using the following syntax: # } terraform import buildkite_team_member.a_smith VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg== ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_team_member.a_smith + id = "VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg==" +} +``` diff --git a/docs/resources/test_suite.md b/docs/resources/test_suite.md index 42d6ae16..55c827b4 100644 --- a/docs/resources/test_suite.md +++ b/docs/resources/test_suite.md @@ -36,3 +36,33 @@ resource "buildkite_test_suite" "main" { - `id` (String) The GraphQL ID of the test suite. - `slug` (String) The generated slug of the test suite. - `uuid` (String) The UUID of the test suite. + +## Import + +Using `terraform import`, import resources using the `id`. For example: +```shell +# import a test suite resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getSuiteIds { +# organization(slug: "ORGANIZATION_SLUG") { +# suites(first: 1, search:"SUITE_SEARCH_TERM") { +# edges { +# node { +# id +# name +# } +# } +# } +# } +# } +terraform import buildkite_test_suite.acceptance VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi +``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_test_suite.acceptance + id = "VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi" +} +``` diff --git a/docs/resources/test_suite_team.md b/docs/resources/test_suite_team.md index 528c2f63..2dd2bccb 100644 --- a/docs/resources/test_suite_team.md +++ b/docs/resources/test_suite_team.md @@ -44,8 +44,7 @@ resource "buildkite_test_suite_team" "main_everyone" { ## Import -Import is supported using the following syntax: - +Using `terraform import`, import resources using the `id`. For example: ```shell # import a test suite team resource using the GraphQL ID # @@ -75,3 +74,11 @@ Import is supported using the following syntax: # } terraform import buildkite_test_suite_team.main_everyone VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi ``` + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +```terraform +import { + to = buildkite_test_suite_team.main_everyone + id = "VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi" +} +``` diff --git a/examples/resources/buildkite_cluster/import.tf b/examples/resources/buildkite_cluster/import.tf new file mode 100644 index 00000000..e1791cc5 --- /dev/null +++ b/examples/resources/buildkite_cluster/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_cluster.primary + id = "Q2x1c3Rlci0tLTI3ZmFmZjA4LTA3OWEtNDk5ZC1hMmIwLTIzNmY3NWFkMWZjYg==" +} diff --git a/examples/resources/buildkite_cluster_default_queue/import.tf b/examples/resources/buildkite_cluster_default_queue/import.tf new file mode 100644 index 00000000..fcc5e896 --- /dev/null +++ b/examples/resources/buildkite_cluster_default_queue/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_cluster_default_queue.primary + id = "Q2x1c3Rlci0tLTI3ZmFmZjA4LTA3OWEtNDk5ZC1hMmIwLTIzNmY3NWFkMWZjYg==" +} diff --git a/examples/resources/buildkite_cluster_queue/import.tf b/examples/resources/buildkite_cluster_queue/import.tf new file mode 100644 index 00000000..c9f95642 --- /dev/null +++ b/examples/resources/buildkite_cluster_queue/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_cluster_queue.test + id = "Q2x1c3RlclF1ZXVlLS0tYjJiOGRhNTEtOWY5My00Y2MyLTkyMjktMGRiNzg3ZDQzOTAz,35498aaf-ad05-4fa5-9a07-91bf6cacd2bd" +} diff --git a/examples/resources/buildkite_organization/import.sh b/examples/resources/buildkite_organization/import.sh index 019a27e1..8324c874 100644 --- a/examples/resources/buildkite_organization/import.sh +++ b/examples/resources/buildkite_organization/import.sh @@ -1,2 +1,2 @@ # import the organization settings via the organization slug -terraform import buildkite_organization.settings +terraform import buildkite_organization.settings my-buildkite-organization diff --git a/examples/resources/buildkite_organization/import.tf b/examples/resources/buildkite_organization/import.tf new file mode 100644 index 00000000..543ce0a4 --- /dev/null +++ b/examples/resources/buildkite_organization/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_organization.settings + id = "my-buildkite-organization" +} diff --git a/examples/resources/buildkite_organization_banner/import.sh b/examples/resources/buildkite_organization_banner/import.sh index 404d0d7f..6040aab8 100644 --- a/examples/resources/buildkite_organization_banner/import.sh +++ b/examples/resources/buildkite_organization_banner/import.sh @@ -12,5 +12,4 @@ # } # } # } - terraform import buildkite_organization_banner.banner T3JnYW5pemF0aW9uQmFubmVyLS0tNjZlMmE5YzktM2IzMy00OGE5LTk1NjItMzY2YzMwNzYzN2Uz diff --git a/examples/resources/buildkite_organization_banner/import.tf b/examples/resources/buildkite_organization_banner/import.tf new file mode 100644 index 00000000..9ef2ec26 --- /dev/null +++ b/examples/resources/buildkite_organization_banner/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_organization_banner.banner + id = "T3JnYW5pemF0aW9uQmFubmVyLS0tNjZlMmE5YzktM2IzMy00OGE5LTk1NjItMzY2YzMwNzYzN2Uz" +} diff --git a/examples/resources/buildkite_organization_rule/import.sh b/examples/resources/buildkite_organization_rule/import.sh index 43be3f3b..f1f657ea 100644 --- a/examples/resources/buildkite_organization_rule/import.sh +++ b/examples/resources/buildkite_organization_rule/import.sh @@ -43,5 +43,4 @@ # } # } # } - -terraform import buildkite_organization_rule.artifact_read UnVsZS0tLTAxOTE5NmU2LWNiNjctNzZiZi1iYzAyLTVhYzFiNzhhMWMyOA== \ No newline at end of file +terraform import buildkite_organization_rule.artifact_read UnVsZS0tLTAxOTE5NmU2LWNiNjctNzZiZi1iYzAyLTVhYzFiNzhhMWMyOA== diff --git a/examples/resources/buildkite_organization_rule/import.tf b/examples/resources/buildkite_organization_rule/import.tf new file mode 100644 index 00000000..bc7fb55e --- /dev/null +++ b/examples/resources/buildkite_organization_rule/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_organization_rule.artifact_read + id = "UnVsZS0tLTAxOTE5NmU2LWNiNjctNzZiZi1iYzAyLTVhYzFiNzhhMWMyOA==" +} diff --git a/examples/resources/buildkite_pipeline/import.tf b/examples/resources/buildkite_pipeline/import.tf new file mode 100644 index 00000000..9fb633fe --- /dev/null +++ b/examples/resources/buildkite_pipeline/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_pipeline.pipeline + id = "UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ=" +} diff --git a/examples/resources/buildkite_pipeline_schedule/import.tf b/examples/resources/buildkite_pipeline_schedule/import.tf new file mode 100644 index 00000000..6a705037 --- /dev/null +++ b/examples/resources/buildkite_pipeline_schedule/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_pipeline_schedule.test + id = "UGlwZWxpgm5Tf2hhZHVsZ35tLWRk4DdmN7c4LTA5M2ItNDM9YS0gMWE0LTAwZDUgYTAxYvRf49==" +} diff --git a/examples/resources/buildkite_pipeline_team/import.tf b/examples/resources/buildkite_pipeline_team/import.tf new file mode 100644 index 00000000..bc9e75bb --- /dev/null +++ b/examples/resources/buildkite_pipeline_team/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_pipeline_team.guests + id = "VGVhbS0tLWU1YjQyMDQyLTUzN2QtNDZjNi04MjY0LTliZjFkMzkyYjZkNQ==" +} diff --git a/examples/resources/buildkite_pipeline_template/import.tf b/examples/resources/buildkite_pipeline_template/import.tf new file mode 100644 index 00000000..2b215308 --- /dev/null +++ b/examples/resources/buildkite_pipeline_template/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_pipeline_template.template + id = "UGlwZWxpbmVUZW1wbGF0ZS0tLWU0YWQ3YjdjLTljZDYtNGM0MS1hYWE0LTY2ZmI3ODY0MTMwNw==" +} diff --git a/examples/resources/buildkite_team/import.tf b/examples/resources/buildkite_team/import.tf new file mode 100644 index 00000000..d8328bce --- /dev/null +++ b/examples/resources/buildkite_team/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_team.everyone + id = "UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ=" +} diff --git a/examples/resources/buildkite_team_member/import.tf b/examples/resources/buildkite_team_member/import.tf new file mode 100644 index 00000000..6b9c2f55 --- /dev/null +++ b/examples/resources/buildkite_team_member/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_team_member.a_smith + id = "VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg==" +} diff --git a/examples/resources/buildkite_test_suite/import.sh b/examples/resources/buildkite_test_suite/import.sh new file mode 100644 index 00000000..c207d50f --- /dev/null +++ b/examples/resources/buildkite_test_suite/import.sh @@ -0,0 +1,16 @@ +# import a test suite resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getSuiteIds { +# organization(slug: "ORGANIZATION_SLUG") { +# suites(first: 1, search:"SUITE_SEARCH_TERM") { +# edges { +# node { +# id +# name +# } +# } +# } +# } +# } +terraform import buildkite_test_suite.acceptance VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi diff --git a/examples/resources/buildkite_test_suite/import.tf b/examples/resources/buildkite_test_suite/import.tf new file mode 100644 index 00000000..50060e7e --- /dev/null +++ b/examples/resources/buildkite_test_suite/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_test_suite.acceptance + id = "VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi" +} diff --git a/examples/resources/buildkite_test_suite_team/import.tf b/examples/resources/buildkite_test_suite_team/import.tf new file mode 100644 index 00000000..be752e0e --- /dev/null +++ b/examples/resources/buildkite_test_suite_team/import.tf @@ -0,0 +1,4 @@ +import { + to = buildkite_test_suite_team.main_everyone + id = "VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi" +} diff --git a/templates/resources.md.tmpl b/templates/resources.md.tmpl new file mode 100644 index 00000000..01d80830 --- /dev/null +++ b/templates/resources.md.tmpl @@ -0,0 +1,29 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ if .HasExample -}} +## Example Usage + +{{tffile .ExampleFile }} +{{- end }} + +{{ .SchemaMarkdown | trimspace }} +{{- if .HasImport }} + +## Import + +Using `terraform import`, import resources using the `id`. For example: +{{codefile "shell" .ImportFile }} + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +{{ $tfImportBlock := print "examples/resources/" .Name "/import.tf" }}{{tffile $tfImportBlock }} +{{- end }} diff --git a/templates/resources/organization.md.tmpl b/templates/resources/organization.md.tmpl new file mode 100644 index 00000000..79e96df4 --- /dev/null +++ b/templates/resources/organization.md.tmpl @@ -0,0 +1,29 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ if .HasExample -}} +## Example Usage + +{{tffile .ExampleFile }} +{{- end }} + +{{ .SchemaMarkdown | trimspace }} +{{- if .HasImport }} + +## Import + +Using `terraform import`, import resources using the `organization-slug`. For example: +{{codefile "shell" .ImportFile }} + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `organization-slug`. For example: +{{ $tfImportBlock := print "examples/resources/" .Name "/import.tf" }}{{tffile $tfImportBlock }} +{{- end }} diff --git a/templates/resources/organization_rule.md b/templates/resources/organization_rule.md deleted file mode 100644 index d67e3ba4..00000000 --- a/templates/resources/organization_rule.md +++ /dev/null @@ -1,129 +0,0 @@ ---- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "buildkite_organization_rule Resource - terraform-provider-buildkite" -subcategory: "" -description: |- - An Organization Rule allows specifying explicit rules between two Buildkite resources and the desired effect/action. - More information on organization rules can be found in the documentation https://buildkite.com/docs/pipelines/rules. ---- - -# buildkite_organization_rule (Resource) - -~> Rules is a feature that is currently in development and enabled on an opt-in basis for early access. To have this enabled for your organization for utilizing this data source, please reach out to Buildkite's [Support Team](mailto:support%40buildkite.com). - -An Organization Rule allows specifying explicit rules between two Buildkite resources and the desired effect/action. - -More information on organization rules can be found in the [documentation](https://buildkite.com/docs/pipelines/rules). - -## Example Usage - -```terraform -# Creates a TRIGGER_BUILD organization rule with required attributes -resource "buildkite_organization_rule" "trigger_build_test_dev" { - type = "pipeline.trigger_build.pipeline" - value = jsonencode({ - source_pipeline = buildkite_pipeline.app_dev_deploy.uuid - target_pipeline = buildkite_pipeline.app_test_ci.uuid - }) -} - -# Creates a ARTIFACTS_READ organization rule with an optional description -resource "buildkite_organization_rule" "artifacts_read_test_dev" { - type = "pipeline.artifacts_read.pipeline" - description = "A rule to allow artifact reads by app_test_ci to app_dev_deploy" - value = jsonencode({ - source_pipeline = buildkite_pipeline.app_test_ci.uuid - target_pipeline = buildkite_pipeline.app_dev_deploy.uuid - }) -} - -# Creates a TRIGGER_BUILD organization rule with an optional description and conditions -resource "buildkite_organization_rule" "trigger_build_test_dev_cond" { - type = "pipeline.trigger_build.pipeline" - description = "A rule to allow app_dev_deploy to trigger app_test_ci builds with conditions" - value = jsonencode({ - source_pipeline = buildkite_pipeline.app_dev_deploy.uuid - target_pipeline = buildkite_pipeline.app_test_ci.uuid - conditions = [ - "source.build.creator.teams includes 'deploy'", - "source.build.branch == 'main'" - ] - }) -} -``` - -## Schema - -### Required - -- `type` (String) The type of organization rule. -- `value` (String) The JSON document that this organization rule implements. - -### Optional - -- `description` (String) The description of the organization rule. - -### Read-Only - -- `action` (String) The action defined between source and target resources. -- `effect` (String) Whether this organization rule allows or denies the action to take place between source and target resources. -- `id` (String) The GraphQL ID of the organization rule. -- `source_type` (String) The source resource type that this organization rule allows or denies to invoke its defined action. -- `source_uuid` (String) The UUID of the resource that this organization rule allows or denies invocating its defined action. -- `target_type` (String) The target resource type that this organization rule allows or denies the source to respective action. -- `target_uuid` (String) The UUID of the target resource that this organization rule allows or denies invocation its respective action. -- `uuid` (String) The UUID of the organization rule. - -## Import - -Import is supported using the following syntax: - -```shell -# import an organization rule resource using the rules GraphQL ID -# -# You can use this query to find the first 50 organiation rules (adjust for less or more): -# query getOrganizationRules { -# organization(slug: "ORGANIZATION_SLUG") { -# rules(first: 50) { -# edges{ -# node{ -# id -# sourceType -# targetType -# action -# } -# } -# } -# } -# } -# -# Depending on the speciific source/target, you're also able to filter on the source/target information -# query getOrganizationRules { -# organization(slug: "ORGANIZATION_SLUG") { -# rules(first: 50) { -# edges{ -# node{ -# id -# sourceType -# source { -# ... on Pipeline{ -# uuid -# name -# } -# } -# targetType -# target { -# ... on Pipeline{ -# uuid -# name -# } -# } -# action -# } -# } -# } -# } -# } - -terraform import buildkite_organization_rule.artifact_read UnVsZS0tLTAxOTE5NmU2LWNiNjctNzZiZi1iYzAyLTVhYzFiNzhhMWMyOA== -``` diff --git a/templates/resources/organization_rule.md.tmpl b/templates/resources/organization_rule.md.tmpl new file mode 100644 index 00000000..877e28eb --- /dev/null +++ b/templates/resources/organization_rule.md.tmpl @@ -0,0 +1,31 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "" +description: |- +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +--- + +# {{.Name}} ({{.Type}}) + +~> Rules is a feature that is currently in development and enabled on an opt-in basis for early access. To have this enabled for your organization for utilizing this data source, please reach out to Buildkite's [Support Team](mailto:support%40buildkite.com). + +{{ .Description | trimspace }} + +{{ if .HasExample -}} +## Example Usage + +{{tffile .ExampleFile }} +{{- end }} + +{{ .SchemaMarkdown | trimspace }} +{{- if .HasImport }} + +## Import + +Using `terraform import`, import resources using the `id`. For example: +{{codefile "shell" .ImportFile }} + +In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import instances using the `id`. For example: +{{ $tfImportBlock := print "examples/resources/" .Name "/import.tf" }}{{tffile $tfImportBlock }} +{{- end }}