From 57604eb203bfe84bd32465522b6c35d9ba714ec3 Mon Sep 17 00:00:00 2001 From: Jarryd Tilbrook Date: Wed, 13 Sep 2023 07:05:05 +0800 Subject: [PATCH] SUP-1293 Generate docs from code (#397) * Add github.com/hashicorp/terraform-plugin-docs * Add make target for docs * Add CI step to check docs are up to date * Change directory in docker compose * Update docs for provider * Update docs for cluster data source * Update docs for meta data source * Remove unused examples files * Update docs for organization data source * Update docs for pipeline data source * Update docs for team data source * Update agent token resource docs * Update docs for cluster resource * Update docs for cluster agent token resource * Update docs for cluster queue resource * Update docs for organization resource * Update pipeline resource docs * Add elastic ci stack guide * Update docs on pipeline schedule resource * Update pipeline_team resource docs * Update docs for team resource * Update docs for team member resource * Update docs for test suite resource * Update test suite team resource docs * Update changelog * Add import files for cluster/cluster queue * Add extra doc note to elastic stack guide * Update local terraform version in CI * Print terraform version in docs step * Change working dir for CI * Undo changes to docker/CI * Add v1.0 upgrade guide * Add comments to examples * Fix typo * Update elastic stack guide title --- CHANGELOG.md | 3 +- Makefile | 4 + buildkite/data_source_cluster.go | 10 +- buildkite/data_source_meta.go | 13 +- buildkite/data_source_organization.go | 13 +- buildkite/data_source_pipeline.go | 9 +- buildkite/data_source_team.go | 12 +- buildkite/provider.go | 25 +- buildkite/resource_agent_token.go | 19 +- buildkite/resource_cluster.go | 28 ++- buildkite/resource_cluster_agent_token.go | 18 +- buildkite/resource_cluster_queue.go | 15 +- buildkite/resource_organization.go | 15 +- buildkite/resource_pipeline.go | 169 +++++++++---- buildkite/resource_pipeline_schedule.go | 24 +- buildkite/resource_pipeline_team.go | 10 +- buildkite/resource_team.go | 23 +- buildkite/resource_team_member.go | 8 +- buildkite/resource_test_suite.go | 26 +- buildkite/resource_test_suite_team.go | 13 +- docs/data-sources/cluster.md | 46 ++-- docs/data-sources/meta.md | 38 +-- docs/data-sources/organization.md | 37 ++- docs/data-sources/pipeline.md | 42 ++-- docs/data-sources/team.md | 49 ++-- docs/guides/elastic-ci-stack.md | 35 +++ docs/guides/upgrade-v1.md | 152 ++++++++++++ docs/index.md | 65 ++--- docs/resources/agent_token.md | 38 +-- docs/resources/cluster.md | 99 +++++--- docs/resources/cluster_agent_token.md | 58 +++-- docs/resources/cluster_queue.md | 116 ++++----- docs/resources/organization.md | 43 +++- docs/resources/pipeline.md | 233 +++++++----------- docs/resources/pipeline_schedule.md | 110 +++++---- docs/resources/pipeline_team.md | 87 ++++--- docs/resources/team.md | 92 +++---- docs/resources/team_member.md | 99 ++++---- docs/resources/test_suite.md | 52 ++-- docs/resources/test_suite_team.md | 127 +++++----- .../buildkite_cluster/data-source.tf | 11 + .../buildkite_meta/data-source.tf | 13 + .../buildkite_pipeline/data-source.tf | 3 + .../buildkite_team/data-source.tf | 3 + examples/main.tf | 106 -------- examples/provider/provider.tf | 20 ++ .../buildkite_agent_token/resource.tf | 4 + .../resources/buildkite_cluster/import.sh | 16 ++ .../resources/buildkite_cluster/resource.tf | 19 ++ .../buildkite_cluster_agent_token/resource.tf | 24 ++ .../buildkite_cluster_queue/import.sh | 18 ++ .../buildkite_cluster_queue/resource.tf | 19 ++ .../buildkite_organization/import.sh | 2 + .../buildkite_organization/resource.tf | 4 + .../resources/buildkite_pipeline/import.sh | 3 + .../resources/buildkite_pipeline/resource.tf | 18 ++ .../buildkite_pipeline_schedule/import.sh | 22 ++ .../buildkite_pipeline_schedule/resource.tf | 13 + .../buildkite_pipeline_team/import.sh | 15 ++ .../buildkite_pipeline_team/resource.tf | 18 ++ examples/resources/buildkite_team/import.sh | 16 ++ examples/resources/buildkite_team/resource.tf | 6 + .../resources/buildkite_team_member/import.sh | 21 ++ .../buildkite_team_member/resource.tf | 12 + .../buildkite_test_suite/resource.tf | 6 + .../buildkite_test_suite_team/import.sh | 27 ++ .../buildkite_test_suite_team/resource.tf | 13 + examples/steps.yml | 3 - go.mod | 23 +- go.sum | 58 +++++ templates/guides/elastic-ci-stack.md | 35 +++ templates/guides/upgrade-v1.md | 152 ++++++++++++ 72 files changed, 1874 insertions(+), 924 deletions(-) create mode 100644 docs/guides/elastic-ci-stack.md create mode 100644 docs/guides/upgrade-v1.md create mode 100644 examples/data-sources/buildkite_cluster/data-source.tf create mode 100644 examples/data-sources/buildkite_meta/data-source.tf create mode 100644 examples/data-sources/buildkite_pipeline/data-source.tf create mode 100644 examples/data-sources/buildkite_team/data-source.tf delete mode 100644 examples/main.tf create mode 100644 examples/provider/provider.tf create mode 100644 examples/resources/buildkite_agent_token/resource.tf create mode 100644 examples/resources/buildkite_cluster/import.sh create mode 100644 examples/resources/buildkite_cluster/resource.tf create mode 100644 examples/resources/buildkite_cluster_agent_token/resource.tf create mode 100644 examples/resources/buildkite_cluster_queue/import.sh create mode 100644 examples/resources/buildkite_cluster_queue/resource.tf create mode 100644 examples/resources/buildkite_organization/import.sh create mode 100644 examples/resources/buildkite_organization/resource.tf create mode 100644 examples/resources/buildkite_pipeline/import.sh create mode 100644 examples/resources/buildkite_pipeline/resource.tf create mode 100644 examples/resources/buildkite_pipeline_schedule/import.sh create mode 100644 examples/resources/buildkite_pipeline_schedule/resource.tf create mode 100644 examples/resources/buildkite_pipeline_team/import.sh create mode 100644 examples/resources/buildkite_pipeline_team/resource.tf create mode 100644 examples/resources/buildkite_team/import.sh create mode 100644 examples/resources/buildkite_team/resource.tf create mode 100644 examples/resources/buildkite_team_member/import.sh create mode 100644 examples/resources/buildkite_team_member/resource.tf create mode 100644 examples/resources/buildkite_test_suite/resource.tf create mode 100644 examples/resources/buildkite_test_suite_team/import.sh create mode 100644 examples/resources/buildkite_test_suite_team/resource.tf delete mode 100644 examples/steps.yml create mode 100644 templates/guides/elastic-ci-stack.md create mode 100644 templates/guides/upgrade-v1.md diff --git a/CHANGELOG.md b/CHANGELOG.md index d04b2500..97edb9ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,10 @@ All notable changes to this project will be documented in this file. - retryContextError util resource switch [[PR #394](https://github.com/buildkite/terraform-provider-buildkite/pull/394)] @james2791 - Added `build_pull_request_ready_for_review` to pipeline resource docs/examples/tests [[PR #396](https://github.com/buildkite/terraform-provider-buildkite/pull/396)] @james2791 - SUP-1370 Update to protocol v6 [[PR #400](https://github.com/buildkite/terraform-provider-buildkite/pull/400)] @jradtilbrook +- SUP-1293 Generate docs from code [[PR #397](https://github.com/buildkite/terraform-provider-buildkite/pull/397)] @jradtilbrook The `team` block from the `buildkite_pipeline` resource has been removed. Please use the resource `buildkite_pipeline_team` to create and manage team configuration in a pipeline. - + ## [v0.27.0](https://github.com/buildkite/terraform-provider-buildkite/compare/v0.26.0...v0.27.0) - SUP-805: SUP-805: Team resource retries [[PR #360](https://github.com/buildkite/terraform-provider-buildkite/pull/360)] @james2791 diff --git a/Makefile b/Makefile index 92a53ffe..3124ae3f 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,10 @@ default: build build: go build -o terraform-provider-buildkite -ldflags="-s -w -X main.version=$(shell git describe --tag)" . +.PHONY: docs +docs: + go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs + fmt: go fmt ./... diff --git a/buildkite/data_source_cluster.go b/buildkite/data_source_cluster.go index 162dc4b7..45f4d66e 100644 --- a/buildkite/data_source_cluster.go +++ b/buildkite/data_source_cluster.go @@ -99,16 +99,18 @@ func (c *clusterDatasource) Read(ctx context.Context, req datasource.ReadRequest func (*clusterDatasource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "Look up a cluster by name.", + MarkdownDescription: "Use this data source to retrieve a cluster by name. You can find out more about clusters in the Buildkite [documentation](https://buildkite.com/docs/clusters/overview).", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the cluster.", }, "uuid": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the cluster", }, "name": schema.StringAttribute{ - MarkdownDescription: "The name of the Cluster to find.", + MarkdownDescription: "The name of the cluster to retrieve.", Required: true, }, "description": schema.StringAttribute{ diff --git a/buildkite/data_source_meta.go b/buildkite/data_source_meta.go index 1e96291f..5cafae40 100644 --- a/buildkite/data_source_meta.go +++ b/buildkite/data_source_meta.go @@ -4,6 +4,7 @@ import ( "context" "sort" + "github.com/MakeNowJust/heredoc" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -63,13 +64,19 @@ func (m *metaDatasource) Read(ctx context.Context, req datasource.ReadRequest, r func (*metaDatasource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "Find source IP addresses that Buildkite may use to send external requests to.", + MarkdownDescription: heredoc.Doc(` + Use this data source to look up the source IP addresses that Buildkite may use to send external requests, + including webhooks and API calls to source control systems (like GitHub Enterprise Server and BitBucket Server). + + More info in the Buildkite [documentation](https://buildkite.com/docs/apis/rest-api/meta). + `), Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "Fixed value: `https://api.buildkite.com/v2/meta`.", }, "webhook_ips": schema.ListAttribute{ - MarkdownDescription: "List of IPs in CIDR format", + MarkdownDescription: "List of IPs in CIDR format.", Computed: true, ElementType: types.StringType, }, diff --git a/buildkite/data_source_organization.go b/buildkite/data_source_organization.go index 7d97b793..1154ea87 100644 --- a/buildkite/data_source_organization.go +++ b/buildkite/data_source_organization.go @@ -68,17 +68,20 @@ func (o *organizationDatasource) Read(ctx context.Context, req datasource.ReadRe func (*organizationDatasource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "Look up organization settings.", + MarkdownDescription: "Use this data source to look up the organization settings.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the organization.", }, "uuid": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the organization.", }, "allowed_api_ip_addresses": schema.ListAttribute{ - Computed: true, - ElementType: types.StringType, + Computed: true, + ElementType: types.StringType, + MarkdownDescription: "List of IP addresses in CIDR format that are allowed to access the Buildkite API for this organization.", }, }, } diff --git a/buildkite/data_source_pipeline.go b/buildkite/data_source_pipeline.go index 610b2f85..d54478cb 100644 --- a/buildkite/data_source_pipeline.go +++ b/buildkite/data_source_pipeline.go @@ -5,6 +5,7 @@ import ( "fmt" "log" + "github.com/MakeNowJust/heredoc" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" "github.com/hashicorp/terraform-plugin-framework/types" @@ -42,9 +43,15 @@ func (*pipelineDatasource) Metadata(ctx context.Context, req datasource.Metadata func (*pipelineDatasource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ + MarkdownDescription: heredoc.Doc(` + Use this data source to look up properties on a specific pipeline. This is particularly useful for looking up the webhook URL for each pipeline. + + More info in the Buildkite [documentation](https://buildkite.com/docs/pipelines). + `), Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the pipeline.", }, "name": schema.StringAttribute{ Computed: true, diff --git a/buildkite/data_source_team.go b/buildkite/data_source_team.go index 647faefb..c58ed2f9 100644 --- a/buildkite/data_source_team.go +++ b/buildkite/data_source_team.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/MakeNowJust/heredoc" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/datasource/schema" @@ -46,10 +47,13 @@ func (t *teamDatasource) Metadata(ctx context.Context, req datasource.MetadataRe func (t *teamDatasource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "This datasource allows you to get a team from Buildkite.", + MarkdownDescription: heredoc.Doc(` + Use this data source to retrieve a team by slug or id. You can find out more about teams in the Buildkite + [documentation](https://buildkite.com/docs/pipelines/permissions). + `), Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - MarkdownDescription: "The ID of the team.", + MarkdownDescription: "The ID of the team to find. Use either ID or slug.", Optional: true, Computed: true, Validators: []validator.String{ @@ -64,7 +68,7 @@ func (t *teamDatasource) Schema(ctx context.Context, req datasource.SchemaReques Computed: true, }, "slug": schema.StringAttribute{ - MarkdownDescription: "The slug of the team.", + MarkdownDescription: "The slug of the team to find. Use either ID or slug.", Computed: true, Optional: true, }, @@ -73,7 +77,7 @@ func (t *teamDatasource) Schema(ctx context.Context, req datasource.SchemaReques Computed: true, }, "privacy": schema.StringAttribute{ - MarkdownDescription: "The privacy of the team.", + MarkdownDescription: "The privacy setting of the team.", Computed: true, }, "description": schema.StringAttribute{ diff --git a/buildkite/provider.go b/buildkite/provider.go index 3d8b289f..b62c27d9 100644 --- a/buildkite/provider.go +++ b/buildkite/provider.go @@ -143,27 +143,30 @@ func (tf *terraformProvider) Resources(context.Context) []func() resource.Resour func (*terraformProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ + MarkdownDescription: ` + This provider can be used to manage resources on [buildkite.com](https://buildkite.com). + `, Attributes: map[string]schema.Attribute{ SchemaKeyOrganization: schema.StringAttribute{ - Optional: true, - Description: "The Buildkite organization slug", + Optional: true, + MarkdownDescription: "The Buildkite organization slug. This can be found on the [settings](https://buildkite.com/organizations/~/settings) page. If not provided, the value is taken from the `BUILDKITE_ORGANIZATION_SLUG` environment variable.", }, SchemaKeyAPIToken: schema.StringAttribute{ - Optional: true, - Description: "API token with GraphQL access and `write_pipelines, read_pipelines` and `write_suites` REST API scopes", - Sensitive: true, + Optional: true, + MarkdownDescription: "API token with GraphQL access and `write_pipelines`, `read_pipelines` and `write_suites` REST API scopes. You can generate a token from [your settings page](https://buildkite.com/user/api-access-tokens/new?description=terraform&scopes[]=write_pipelines&scopes[]=write_suites&scopes[]=read_pipelines&scopes[]=graphql). If not provided, the value is taken from the `BUILDKITE_API_TOKEN` environment variable.", + Sensitive: true, }, SchemaKeyGraphqlURL: schema.StringAttribute{ - Optional: true, - Description: "Base URL for the GraphQL API to use", + Optional: true, + MarkdownDescription: "Base URL for the GraphQL API to use. If not provided, the value is taken from the `BUILDKITE_GRAPHQL_URL` environment variable.", }, SchemaKeyRestURL: schema.StringAttribute{ - Optional: true, - Description: "Base URL for the REST API to use", + Optional: true, + MarkdownDescription: "Base URL for the REST API to use. If not provided, the value is taken from the `BUILDKITE_REST_URL` environment variable.", }, "archive_pipeline_on_delete": schema.BoolAttribute{ - Optional: true, - Description: "Archive pipelines when destroying instead of completely deleting.", + Optional: true, + MarkdownDescription: "Enable this to archive pipelines when destroying the resource. This is opposed to completely deleting pipelines.", }, }, Blocks: map[string]schema.Block{ diff --git a/buildkite/resource_agent_token.go b/buildkite/resource_agent_token.go index c2aa2444..a0ed94e7 100644 --- a/buildkite/resource_agent_token.go +++ b/buildkite/resource_agent_token.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/MakeNowJust/heredoc" "github.com/hashicorp/terraform-plugin-framework/resource" resource_schema "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" @@ -180,25 +181,33 @@ func (at *AgentTokenResource) Read(ctx context.Context, req resource.ReadRequest func (AgentTokenResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = resource_schema.Schema{ + MarkdownDescription: heredoc.Doc(` + This resource allows you to create and manage non-clustered agent tokens. + You can find out more about clusters in the Buildkite [documentation](https://buildkite.com/docs/agent/v3/tokens). + `), Attributes: map[string]resource_schema.Attribute{ "description": resource_schema.StringAttribute{ - Optional: true, + Optional: true, + MarkdownDescription: "The description of the agent token. Used to help identify its use.", PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), }, }, "id": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the agent token.", }, "token": resource_schema.StringAttribute{ - Computed: true, - Sensitive: true, + Computed: true, + Sensitive: true, + MarkdownDescription: "The token value used by an agent to register with the API.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the agent token.", }, }, } diff --git a/buildkite/resource_cluster.go b/buildkite/resource_cluster.go index 522ac0d2..4578656d 100644 --- a/buildkite/resource_cluster.go +++ b/buildkite/resource_cluster.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/MakeNowJust/heredoc" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" resource_schema "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -44,17 +45,22 @@ func (c *clusterResource) Configure(ctx context.Context, req resource.ConfigureR func (c *clusterResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = resource_schema.Schema{ - MarkdownDescription: "A Cluster is a group of Agents that can be used to run your builds. " + - "Clusters are useful for grouping Agents by their capabilities, such as operating system, hardware, or location. ", + MarkdownDescription: heredoc.Doc(` + This resource allows you to create and manage a Buildkite Cluster to run your builds in. + Clusters are useful for grouping agents by there capabilities or permissions. + Find out more information in our [documentation](https://buildkite.com/docs/clusters/overview). + `), Attributes: map[string]resource_schema.Attribute{ "id": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the cluster.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the cluster.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -64,12 +70,18 @@ func (c *clusterResource) Schema(ctx context.Context, req resource.SchemaRequest Required: true, }, "description": resource_schema.StringAttribute{ - Optional: true, - MarkdownDescription: "A description for the Cluster. Consider something short but clear on the Cluster's function.", + Optional: true, + MarkdownDescription: heredoc.Doc(` + This is a description for the cluster, this may describe the usage for it, the region, or something else + which would help identify the Cluster's purpose. + `), }, "emoji": resource_schema.StringAttribute{ - Optional: true, - MarkdownDescription: "An emoji to represent the Cluster. Accepts the format :buildkite:.", + Optional: true, + MarkdownDescription: heredoc.Doc(` + An emoji to use with the Cluster, this can either be set using :buildkite: notation, or with the + emoji itself, such as 🚀. + `), }, "color": resource_schema.StringAttribute{ Optional: true, diff --git a/buildkite/resource_cluster_agent_token.go b/buildkite/resource_cluster_agent_token.go index ea7986e2..b01bc2dc 100644 --- a/buildkite/resource_cluster_agent_token.go +++ b/buildkite/resource_cluster_agent_token.go @@ -47,28 +47,32 @@ func (ct *ClusterAgentToken) Schema(_ context.Context, _ resource.SchemaRequest, MarkdownDescription: "A Cluster Agent Token is a token used to connect an agent to a cluster in Buildkite.", Attributes: map[string]resource_schema.Attribute{ "id": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the token.", }, "uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the token.", }, "description": resource_schema.StringAttribute{ Required: true, - MarkdownDescription: "A description about what this cluster agent token is used for", + MarkdownDescription: "A description about what this cluster agent token is used for.", }, "token": resource_schema.StringAttribute{ - Computed: true, - Sensitive: true, + Computed: true, + Sensitive: true, + MarkdownDescription: "The token value used by an agent to register with the API.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "cluster_id": resource_schema.StringAttribute{ Required: true, - MarkdownDescription: "The ID of the Cluster that this Cluster Agent Token belongs to.", + MarkdownDescription: "The GraphQL ID of the Cluster that this Cluster Agent Token belongs to.", }, "cluster_uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the Cluster that this token belongs to.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, diff --git a/buildkite/resource_cluster_queue.go b/buildkite/resource_cluster_queue.go index 302f03f6..44dabab5 100644 --- a/buildkite/resource_cluster_queue.go +++ b/buildkite/resource_cluster_queue.go @@ -49,34 +49,37 @@ func (ClusterQueueResource) Schema(ctx context.Context, req resource.SchemaReque MarkdownDescription: "A Cluster Queue is a queue belonging to a specific Cluster for its Agents to target builds on. ", Attributes: map[string]resource_schema.Attribute{ "id": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the cluster queue.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the cluster queue.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "cluster_uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the cluster this queue belongs to.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "cluster_id": resource_schema.StringAttribute{ Required: true, - MarkdownDescription: "The ID of the Cluster that this Cluster Queue belongs to.", + MarkdownDescription: "The ID of the cluster that this cluster queue belongs to.", }, "key": resource_schema.StringAttribute{ Required: true, - MarkdownDescription: "The key of the Cluster Queue.", + MarkdownDescription: "The key of the cluster queue.", }, "description": resource_schema.StringAttribute{ Optional: true, - MarkdownDescription: "A description for the Cluster Queue. ", + MarkdownDescription: "A description for the cluster queue. ", }, }, } diff --git a/buildkite/resource_organization.go b/buildkite/resource_organization.go index ea1ac188..d0567b70 100644 --- a/buildkite/resource_organization.go +++ b/buildkite/resource_organization.go @@ -6,6 +6,7 @@ import ( "log" "strings" + "github.com/MakeNowJust/heredoc" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" resource_schema "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -42,15 +43,22 @@ func (o *organizationResource) Configure(ctx context.Context, req resource.Confi func (*organizationResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = resource_schema.Schema{ + MarkdownDescription: heredoc.Doc(` + This resource allows you to manage the settings for an organization. + + The user of your API token must be an organization administrator to manage organization settings. + `), Attributes: map[string]resource_schema.Attribute{ "id": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the organization.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the organization.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -58,6 +66,9 @@ func (*organizationResource) Schema(ctx context.Context, req resource.SchemaRequ "allowed_api_ip_addresses": resource_schema.ListAttribute{ Optional: true, ElementType: types.StringType, + MarkdownDescription: "A list of IP addresses in CIDR format that are allowed to access the Buildkite API." + + "If not set, all IP addresses are allowed (the same as setting 0.0.0.0/0).\n\n" + + "-> The \"Allowed API IP Addresses\" feature must be enabled on your organization in order to manage the `allowed_api_ip_addresses` attribute.", }, }, } diff --git a/buildkite/resource_pipeline.go b/buildkite/resource_pipeline.go index 40df9180..c4d8c7fa 100644 --- a/buildkite/resource_pipeline.go +++ b/buildkite/resource_pipeline.go @@ -7,6 +7,7 @@ import ( "time" "unsafe" + "github.com/MakeNowJust/heredoc" "github.com/buildkite/terraform-provider-buildkite/internal/boolvalidation" "github.com/buildkite/terraform-provider-buildkite/internal/pipelinevalidation" custom_modifier "github.com/buildkite/terraform-provider-buildkite/internal/planmodifier" @@ -332,113 +333,137 @@ func (p *pipelineResource) Read(ctx context.Context, req resource.ReadRequest, r func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ + MarkdownDescription: heredoc.Doc(` + This resource allows you to create and manage pipelines for repositories. + + More information on pipelines can be found in the documentation](https://buildkite.com/docs/pipelines). + `), Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the pipeline.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "allow_rebuilds": schema.BoolAttribute{ - Optional: true, - Computed: true, - Default: booldefault.StaticBool(true), + Optional: true, + Computed: true, + Default: booldefault.StaticBool(true), + MarkdownDescription: "Whether rebuilds are allowed for this pipeline.", }, "cancel_intermediate_builds": schema.BoolAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Whether to cancel builds when a new commit is pushed to a matching branch.", PlanModifiers: []planmodifier.Bool{ boolplanmodifier.UseStateForUnknown(), }, }, "cancel_intermediate_builds_branch_filter": schema.StringAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Filter the `cancel_intermediate_builds` setting based on this branch condition.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "branch_configuration": schema.StringAttribute{ - Optional: true, + MarkdownDescription: "Configure the pipeline to only build on this branch conditional.", + Optional: true, }, "cluster_id": schema.StringAttribute{ - Optional: true, + MarkdownDescription: "Attach this pipeline to the given cluster GraphQL ID.", + Optional: true, }, "default_branch": schema.StringAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Default branch of the pipeline.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "default_timeout_in_minutes": schema.Int64Attribute{ - Computed: true, - Optional: true, - Default: nil, + Computed: true, + Optional: true, + Default: nil, + MarkdownDescription: "Set pipeline wide timeout for command steps.", PlanModifiers: []planmodifier.Int64{ int64planmodifier.UseStateForUnknown(), }, }, "maximum_timeout_in_minutes": schema.Int64Attribute{ - Computed: true, - Optional: true, - Default: nil, + Computed: true, + Optional: true, + Default: nil, + MarkdownDescription: "Set pipeline wide maximum timeout for command steps.", PlanModifiers: []planmodifier.Int64{ int64planmodifier.UseStateForUnknown(), }, }, "description": schema.StringAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Description for the pipeline. Can include emoji 🙌.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "name": schema.StringAttribute{ - Required: true, + Required: true, + MarkdownDescription: "Name to give the pipeline.", }, "repository": schema.StringAttribute{ - Required: true, + Required: true, + MarkdownDescription: "URL to the repository this pipeline is configured for.", }, "skip_intermediate_builds": schema.BoolAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Whether to skip queued builds if a new commit is pushed to a matching branch.", PlanModifiers: []planmodifier.Bool{ boolplanmodifier.UseStateForUnknown(), }, }, "skip_intermediate_builds_branch_filter": schema.StringAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Filter the `skip_intermediate_builds` setting based on this branch condition.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "slug": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The slug generated for the pipeline.", PlanModifiers: []planmodifier.String{ custom_modifier.UseStateIfUnchanged("name"), }, }, "steps": schema.StringAttribute{ - Optional: true, - Computed: true, - Default: stringdefault.StaticString(defaultSteps), + Optional: true, + Computed: true, + Default: stringdefault.StaticString(defaultSteps), + MarkdownDescription: "The YAML steps to configure for the pipeline. Defaults to `buildkite-agent pipeline upload`.", }, "tags": schema.SetAttribute{ - Optional: true, - Computed: true, - ElementType: types.StringType, - Default: setdefault.StaticValue(types.SetValueMust(types.StringType, []attr.Value{})), + Optional: true, + Computed: true, + ElementType: types.StringType, + Default: setdefault.StaticValue(types.SetValueMust(types.StringType, []attr.Value{})), + MarkdownDescription: "Tags to attribute to the pipeline. Useful for searching by in the UI.", }, "webhook_url": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The webhook URL used to trigger builds from VCS providers.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "badge_url": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The badge URL showing build state.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -446,6 +471,7 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, }, Blocks: map[string]schema.Block{ "provider_settings": schema.ListNestedBlock{ + MarkdownDescription: "Control settings depending on the VCS provider used in `repository`.", Validators: []validator.List{ listvalidator.SizeBetween(0, 1), }, @@ -454,6 +480,21 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "trigger_mode": schema.StringAttribute{ Computed: true, Optional: true, + MarkdownDescription: heredoc.Docf(` + What type of event to trigger builds on. Must be one of: + - %s + - %s + - %s + - %s + + -> %s is only valid if the pipeline uses a GitHub repository. + `, + "`code` will create builds when code is pushed to GitHub.", + "`deployment` will create builds when a deployment is created in GitHub.", + "`fork` will create builds when the GitHub repository is forked.", + "`none` will not create any builds based on GitHub activity.", + "`trigger_mode`", + ), Validators: []validator.String{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub), stringvalidator.OneOf("code", "deployment", "fork", "none"), @@ -462,6 +503,8 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "build_pull_requests": schema.BoolAttribute{ Optional: true, Computed: true, + MarkdownDescription: "Whether to create builds for commits that are part part of a pull request." + + "Only valid for Bitbucket or GitHub using a `trigger_mode = \"code\"`", Validators: []validator.Bool{ boolvalidator.Any( pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderBitbucket), @@ -473,15 +516,17 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, }, }, "pull_request_branch_filter_enabled": schema.BoolAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Filter pull request builds. Only valid if `build_pull_requests = true`.", Validators: []validator.Bool{ boolvalidation.WhenBool(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("build_pull_requests"), true), }, }, "pull_request_branch_filter_configuration": schema.StringAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Filter pull requests builds by the branch filter. Only valid if `pull_request_branch_filter_enabled = true`.", Validators: []validator.String{ stringvalidation.WhenBool(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("pull_request_branch_filter_enabled"), true), }, @@ -489,6 +534,8 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "skip_builds_for_existing_commits": schema.BoolAttribute{ Optional: true, Computed: true, + MarkdownDescription: "Whether to skip creating a new build if an existing build for the commit and branch already exists." + + "Only valid for GitHub repositories.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub), }, @@ -496,6 +543,8 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "skip_pull_request_builds_for_existing_commits": schema.BoolAttribute{ Optional: true, Computed: true, + MarkdownDescription: "Whether to skip creating a new build for a pull request if an existing build for the commit and branch already exists." + + "Only valid if `build_pull_requests = true`.", Validators: []validator.Bool{ boolvalidation.WhenBool(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("build_pull_requests"), true), }, @@ -503,6 +552,8 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "build_pull_request_ready_for_review": schema.BoolAttribute{ Computed: true, Optional: true, + MarkdownDescription: "Whether to create a build when a pull request changes to \"Ready for review\"." + + "Only valid for GitHub repositories that have `trigger_mode = \"code\"` and `build_pull_requests = true`.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub), boolvalidation.WhenString(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("trigger_mode"), "code"), @@ -512,6 +563,8 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "build_pull_request_labels_changed": schema.BoolAttribute{ Computed: true, Optional: true, + MarkdownDescription: "Whether to create builds for pull requests when labels are added or removed." + + "Only valid for GitHub repositories that have `trigger_mode = \"code\"` and `build_pull_requests = true`.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub), boolvalidation.WhenString(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("trigger_mode"), "code"), @@ -521,6 +574,8 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "build_pull_request_forks": schema.BoolAttribute{ Computed: true, Optional: true, + MarkdownDescription: "Whether to create builds for pull requests from third-party forks." + + "Only valid for GitHub repositories that have `trigger_mode = \"code\"` and `build_pull_requests = true`.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub), boolvalidation.WhenString(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("trigger_mode"), "code"), @@ -530,27 +585,33 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "prefix_pull_request_fork_branch_names": schema.BoolAttribute{ Computed: true, Optional: true, + MarkdownDescription: "Prefix branch names for third-party fork builds to ensure they don't trigger branch conditions." + + "For example, the master branch from some-user will become some-user:master." + + "Only valid when `build_pull_request_forks = true`.", Validators: []validator.Bool{ boolvalidation.WhenBool(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("build_pull_request_forks"), true), }, }, "build_branches": schema.BoolAttribute{ - Optional: true, - Computed: true, + Optional: true, + Computed: true, + MarkdownDescription: "Whether to create builds when branches are pushed. Only valid for GitHub and Bitbucket repositories.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub, pipelinevalidation.RepositoryProviderBitbucket), }, }, "build_tags": schema.BoolAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Whether to create builds when tags are pushed. Only valid for GitHub and Bitbucket repositories.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub, pipelinevalidation.RepositoryProviderBitbucket), }, }, "cancel_deleted_branch_builds": schema.BoolAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Automatically cancel running builds for a branch if the branch is deleted. Only valid for GitHub repositories when `trigger_mode = \"code\"`.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub), boolvalidation.WhenString(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("trigger_mode"), "code"), @@ -559,6 +620,8 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "filter_enabled": schema.BoolAttribute{ Computed: true, Optional: true, + MarkdownDescription: "Whether to filter builds to only run when the condition in `filter_condition` is true." + + "Only valid for GitHub repositories when `trigger_mode = \"code\"`.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub), boolvalidation.WhenString(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("trigger_mode"), "code"), @@ -567,6 +630,9 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "filter_condition": schema.StringAttribute{ Computed: true, Optional: true, + MarkdownDescription: "The condition to evaluate when deciding if a build should run." + + "More details available in [the documentation](https://buildkite.com/docs/pipelines/conditionals#conditionals-in-pipelines)." + + "Only valid if `filter_enabled = true`.", Validators: []validator.String{ stringvalidation.WhenBool(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("filter_enabled"), true), }, @@ -574,6 +640,8 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "publish_commit_status": schema.BoolAttribute{ Optional: true, Computed: true, + MarkdownDescription: "Whether to update the status of commits in Bitbucket or GitHub." + + "Only valid for Bitbucket, or GitHub repositories when `trigger_mode = \"code\"`.", Validators: []validator.Bool{ boolvalidator.Any( pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderBitbucket), @@ -587,14 +655,17 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "publish_blocked_as_pending": schema.BoolAttribute{ Computed: true, Optional: true, + MarkdownDescription: "The status to use for blocked builds. Pending can be used with [required status checks](https://help.github.com/en/articles/enabling-required-status-checks)" + + "to prevent merging pull requests with blocked builds. Only valid for GitHub repositories when `publish_commit_statue = true`.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub), boolvalidation.WhenBool(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("publish_commit_status"), true), }, }, "publish_commit_status_per_step": schema.BoolAttribute{ - Computed: true, - Optional: true, + Computed: true, + Optional: true, + MarkdownDescription: "Whether to create a separate status for each job in a build, allowing you to see the status of each job directly in Bitbucket or GitHub.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub, pipelinevalidation.RepositoryProviderBitbucket), boolvalidation.WhenBool(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("publish_commit_status"), true), @@ -603,6 +674,8 @@ func (*pipelineResource) Schema(ctx context.Context, req resource.SchemaRequest, "separate_pull_request_statuses": schema.BoolAttribute{ Computed: true, Optional: true, + MarkdownDescription: "Whether to create a separate status for pull request builds, allowing you to require a passing pull request" + + "build in your [required status checks](https://help.github.com/en/articles/enabling-required-status-checks) in GitHub.", Validators: []validator.Bool{ pipelinevalidation.WhenRepositoryProviderIs(pipelinevalidation.RepositoryProviderGitHub), boolvalidation.WhenBool(path.MatchRoot("provider_settings").AtAnyListIndex().AtName("publish_commit_status"), true), diff --git a/buildkite/resource_pipeline_schedule.go b/buildkite/resource_pipeline_schedule.go index fb576f4e..5e7498ee 100644 --- a/buildkite/resource_pipeline_schedule.go +++ b/buildkite/resource_pipeline_schedule.go @@ -6,6 +6,7 @@ import ( "fmt" "strings" + "github.com/MakeNowJust/heredoc" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" resource_schema "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -51,31 +52,38 @@ func (ps *pipelineSchedule) Configure(ctx context.Context, req resource.Configur func (ps *pipelineSchedule) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = resource_schema.Schema{ - MarkdownDescription: "A Pipeline Schedule is a schedule that triggers a pipeline to run at a specific time.", + MarkdownDescription: heredoc.Doc(` + A pipeline schedule is a schedule that triggers a pipeline to run at a specific time. + + You can find more information in the [documentation](https://buildkite.com/docs/pipelines/scheduled-builds). + `), Attributes: map[string]resource_schema.Attribute{ "id": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the schedule.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the schedule.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "pipeline_id": resource_schema.StringAttribute{ Required: true, - MarkdownDescription: "The ID of the pipeline that this schedule belongs to.", + MarkdownDescription: "The GraphQL ID of the pipeline that this schedule belongs to.", }, "label": resource_schema.StringAttribute{ Required: true, MarkdownDescription: "A label to describe the schedule.", }, "cronline": resource_schema.StringAttribute{ - Required: true, - MarkdownDescription: "The cronline that describes when the schedule should run.", + Required: true, + MarkdownDescription: "The cronline that describes when the schedule should run. See" + + "[here](https://buildkite.com/docs/pipelines/scheduled-builds#schedule-intervals) for supported syntax.", }, "branch": resource_schema.StringAttribute{ Required: true, @@ -89,12 +97,12 @@ func (ps *pipelineSchedule) Schema(ctx context.Context, req resource.SchemaReque }, "message": resource_schema.StringAttribute{ Optional: true, - MarkdownDescription: "The message that the schedule should run on.", + MarkdownDescription: "The message the builds show for builds created by this schedule.", }, "env": resource_schema.MapAttribute{ ElementType: types.StringType, Optional: true, - MarkdownDescription: "The environment variables that the schedule should run on.", + MarkdownDescription: "The environment variables that scheduled builds should use.", }, "enabled": resource_schema.BoolAttribute{ Optional: true, diff --git a/buildkite/resource_pipeline_team.go b/buildkite/resource_pipeline_team.go index fdc1c4e4..884a0c1c 100644 --- a/buildkite/resource_pipeline_team.go +++ b/buildkite/resource_pipeline_team.go @@ -45,16 +45,18 @@ func (tp *pipelineTeamResource) Configure(ctx context.Context, req resource.Conf func (pipelineTeamResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = resource_schema.Schema{ - MarkdownDescription: "A team pipeline resource sets a team's access for the pipeline.", + MarkdownDescription: "Manage team access to a pipeline.", Attributes: map[string]resource_schema.Attribute{ "id": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the pipeline-team relationship.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the pipeline-team relationship.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -69,7 +71,7 @@ func (pipelineTeamResource) Schema(ctx context.Context, req resource.SchemaReque }, "access_level": resource_schema.StringAttribute{ Required: true, - MarkdownDescription: "The access level for the team. Either READ_ONLY, BUILD_AND_READ or MANAGE_BUILD_AND_READ.", + MarkdownDescription: "The access level for the team. Either `READ_ONLY`, `BUILD_AND_READ` or `MANAGE_BUILD_AND_READ`.", Validators: []validator.String{ stringvalidator.OneOf(string(PipelineAccessLevelsReadOnly), string(PipelineAccessLevelsBuildAndRead), diff --git a/buildkite/resource_team.go b/buildkite/resource_team.go index 68774d73..2f95a9a3 100644 --- a/buildkite/resource_team.go +++ b/buildkite/resource_team.go @@ -69,47 +69,48 @@ func (t *teamResource) Schema(ctx context.Context, req resource.SchemaRequest, r "Clusters are useful for grouping Agents by their capabilities, such as operating system, hardware, or location. ", Attributes: map[string]resource_schema.Attribute{ "id": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the team.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, - MarkdownDescription: "The ID of the Team. This is a computed value and cannot be set.", }, "uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the team.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, - MarkdownDescription: "The UUID of the Team. This is a computed value and cannot be set.", }, "name": resource_schema.StringAttribute{ - MarkdownDescription: "The name of the Team.", + MarkdownDescription: "The name of the team.", Required: true, }, "description": resource_schema.StringAttribute{ Optional: true, - MarkdownDescription: "A description for the Team. This is displayed in the Buildkite UI.", + MarkdownDescription: "A description for the team. This is displayed in the Buildkite UI.", }, "privacy": resource_schema.StringAttribute{ Required: true, - MarkdownDescription: "The privacy setting for the Team. This can be either `VISIBLE` or `SECRET`.", + MarkdownDescription: "The privacy setting for the team. This can be either `VISIBLE` or `SECRET`.", Validators: []validator.String{ stringvalidator.OneOf("VISIBLE", "SECRET"), }, }, "default_team": resource_schema.BoolAttribute{ Required: true, - MarkdownDescription: "Whether this is the default Team for the Organization.", + MarkdownDescription: "Whether this is the default team for the organization.", }, "default_member_role": resource_schema.StringAttribute{ Required: true, - MarkdownDescription: "The default role for new members of the Team. This can be either `MEMBER` or `MAINTAINER`.", + MarkdownDescription: "The default role for new members of the team. This can be either `MEMBER` or `MAINTAINER`.", Validators: []validator.String{ stringvalidator.OneOf("MEMBER", "MAINTAINER"), }, }, "slug": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The generated slug for the team.", PlanModifiers: []planmodifier.String{ custom_modifier.UseStateIfUnchanged("name"), }, @@ -118,7 +119,7 @@ func (t *teamResource) Schema(ctx context.Context, req resource.SchemaRequest, r Optional: true, Computed: true, Default: booldefault.StaticBool(false), - MarkdownDescription: "Whether members of the Team can create Pipelines.", + MarkdownDescription: "Whether members of the team can create Pipelines.", }, }, } diff --git a/buildkite/resource_team_member.go b/buildkite/resource_team_member.go index dc01e728..5c5f4bad 100644 --- a/buildkite/resource_team_member.go +++ b/buildkite/resource_team_member.go @@ -49,13 +49,15 @@ func (teamMemberResource) Schema(ctx context.Context, req resource.SchemaRequest MarkdownDescription: "A team member resource allows for the management of team membership for existing organization users.", Attributes: map[string]resource_schema.Attribute{ "id": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the team membership.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "uuid": resource_schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the team membership.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -70,7 +72,7 @@ func (teamMemberResource) Schema(ctx context.Context, req resource.SchemaRequest }, "role": resource_schema.StringAttribute{ Required: true, - MarkdownDescription: "The role for the user. Either MEMBER or MAINTAINER.", + MarkdownDescription: "The role for the user. Either `MEMBER` or `MAINTAINER`.", Validators: []validator.String{ stringvalidator.OneOf("MEMBER", "MAINTAINER"), }, diff --git a/buildkite/resource_test_suite.go b/buildkite/resource_test_suite.go index d83a476d..900d5e6b 100644 --- a/buildkite/resource_test_suite.go +++ b/buildkite/resource_test_suite.go @@ -238,41 +238,49 @@ func (ts *testSuiteResource) Read(ctx context.Context, req resource.ReadRequest, func (ts *testSuiteResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "A test suite is a collection of tests. A run is to a suite what a build is to a Pipeline.", + MarkdownDescription: "A test suite is a collection of tests. A run is to a suite what a build is to a Pipeline." + + "Use this resource to manage [Test Suites](https://buildkite.com/docs/test-analytics) on Buildkite.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the test suite.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "uuid": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the test suite.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "team_owner_id": schema.StringAttribute{ - Required: true, + MarkdownDescription: "The GraphQL ID of the team to mark as the owner/admin of the test suite.", + Required: true, }, "slug": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The generated slug of the test suite.", PlanModifiers: []planmodifier.String{ custom_modifier.UseStateIfUnchanged("name"), }, }, "name": schema.StringAttribute{ - Required: true, + Required: true, + MarkdownDescription: "The name to give the test suite.", }, "api_token": schema.StringAttribute{ - Computed: true, - Sensitive: true, + Computed: true, + Sensitive: true, + MarkdownDescription: "The API token to use to send test run data to the API.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "default_branch": schema.StringAttribute{ - Required: true, + MarkdownDescription: "The default branch for the repository this test suite is for.", + Required: true, }, }, } diff --git a/buildkite/resource_test_suite_team.go b/buildkite/resource_test_suite_team.go index d111575f..4fbf97f6 100644 --- a/buildkite/resource_test_suite_team.go +++ b/buildkite/resource_test_suite_team.go @@ -46,16 +46,18 @@ func (tst *testSuiteTeamResource) Configure(ctx context.Context, req resource.Co func (tst *testSuiteTeamResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "A test suite team links a collection of tests (suite) to a particular team.", + MarkdownDescription: "Manage team access to a test suite.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The GraphQL ID of the test suite-team relationship.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "uuid": schema.StringAttribute{ - Computed: true, + Computed: true, + MarkdownDescription: "The UUID of the test suite-team relationship.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -65,16 +67,15 @@ func (tst *testSuiteTeamResource) Schema(ctx context.Context, req resource.Schem MarkdownDescription: "The GraphQL ID of the test suite.", }, "team_id": schema.StringAttribute{ - Required: true, MarkdownDescription: "The GraphQL ID of the team.", }, "access_level": schema.StringAttribute{ - Required: true, + Required: true, + MarkdownDescription: "The access level the team has on the test suite. Either `READ_ONLY` or `MANAGE_AND_READ`.", Validators: []validator.String{ stringvalidator.OneOf("MANAGE_AND_READ", "READ_ONLY"), }, - MarkdownDescription: " The access level the team has on the test suite. Either `READ_ONLY` or `MANAGE_AND_READ`", }, }, } diff --git a/docs/data-sources/cluster.md b/docs/data-sources/cluster.md index da62acf1..411982dc 100644 --- a/docs/data-sources/cluster.md +++ b/docs/data-sources/cluster.md @@ -1,34 +1,42 @@ -# Data Source: cluster +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_cluster Data Source - terraform-provider-buildkite" +subcategory: "" +description: |- + Use this data source to retrieve a cluster by name. You can find out more about clusters in the Buildkite documentation https://buildkite.com/docs/clusters/overview. +--- -Use this data source to look up properties on a cluster identified by its name. +# buildkite_cluster (Data Source) -Buildkite Documentation: https://buildkite.com/docs/clusters/overview +Use this data source to retrieve a cluster by name. You can find out more about clusters in the Buildkite [documentation](https://buildkite.com/docs/clusters/overview). ## Example Usage -You can find a cluster by name and use it to assign a pipeline to the cluster. -Also note that you can create the cluster using the Buildkite Terraform provider as well (including importing). - -```hcl +```terraform +# Find the "default" cluster data "buildkite_cluster" "default" { - name = "default" + name = "default" } -resource "buildkite_pipeline" "deploy" { - name = "deploy" - repository = "git@github.com:org/repo" +# Assign a pipeline to that cluster +resource "buildkite_pipeline" "terraform-provider-buildkite" { + name = "terraform-provider-buildkite" + repository = "git@github.com:buildkite/terraform-provider-buildkite.git" cluster_id = data.buildkite_cluster.default.id } ``` -## Argument Reference + +## Schema + +### Required -* `name` - (Required) The name of the cluster to lookup. +- `name` (String) The name of the cluster to retrieve. -## Attributes Reference +### Read-Only -* `id` - The GraphQL ID of the cluster. -* `uuid` - The UUID of the cluster. -* `description` - The description of the cluster. -* `emoji` - The emoji given the cluster. -* `color` - The color given the cluster. +- `color` (String) The color of the cluster. +- `description` (String) The description of the cluster. +- `emoji` (String) The emoji of the cluster. +- `id` (String) The GraphQL ID of the cluster. +- `uuid` (String) The UUID of the cluster diff --git a/docs/data-sources/meta.md b/docs/data-sources/meta.md index 5cf8bf62..dfab3c22 100644 --- a/docs/data-sources/meta.md +++ b/docs/data-sources/meta.md @@ -1,20 +1,26 @@ -# Data Source: meta +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_meta Data Source - terraform-provider-buildkite" +subcategory: "" +description: |- + Use this data source to look up the source IP addresses that Buildkite may use to send external requests, + including webhooks and API calls to source control systems (like GitHub Enterprise Server and BitBucket Server). + More info in the Buildkite documentation https://buildkite.com/docs/apis/rest-api/meta. +--- -Use this data source to look up the source IP addresses that Buildkite may use -to send external requests, including webhooks and API calls to source control -systems (like GitHub Enterprise Server and BitBucket Server). +# buildkite_meta (Data Source) -Buildkite Documentation: https://buildkite.com/docs/apis/rest-api/meta +Use this data source to look up the source IP addresses that Buildkite may use to send external requests, +including webhooks and API calls to source control systems (like GitHub Enterprise Server and BitBucket Server). -## Example Usage +More info in the Buildkite [documentation](https://buildkite.com/docs/apis/rest-api/meta). -This is intended to be used in other terraform projects to dynamically -set firewall and ingress rules to allow traffic from Buildkite. For -customers that use AWS, that might look like this: +## Example Usage -```hcl -data "buildkite_meta" "ips" { } +```terraform +data "buildkite_meta" "ips" {} +# Create an AWS security group allowing ingress from Buildkite resource "aws_security_group" "from_buildkite" { name = "from_buildkite" @@ -27,10 +33,10 @@ resource "aws_security_group" "from_buildkite" { } ``` -## Argument Reference - -None. + +## Schema -## Attributes Reference +### Read-Only -* `webhook_ips` - A list of strings, each one an IP address (x.x.x.x) or CIDR address (x.x.x.x/32) that Buildkite may use to send webhooks and other external requests. +- `id` (String) Fixed value: `https://api.buildkite.com/v2/meta`. +- `webhook_ips` (List of String) List of IPs in CIDR format. diff --git a/docs/data-sources/organization.md b/docs/data-sources/organization.md index ff883607..4f2b17d7 100644 --- a/docs/data-sources/organization.md +++ b/docs/data-sources/organization.md @@ -1,29 +1,22 @@ -# Data Source: organization +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_organization Data Source - terraform-provider-buildkite" +subcategory: "" +description: |- + Use this data source to look up the organization settings. +--- -Use this data source to look up the organization settings. It currently supports -allowed_api_ip_addresses. +# buildkite_organization (Data Source) -## Example Usage +Use this data source to look up the organization settings. -```hcl -data "buildkite_organization" "testkite" { } -resource "aws_security_group" "from_buildkite" { - name = "from_buildkite" - ingress { - from_port = "*" - to_port = "443" - protocol = "tcp" - cidr_blocks = data.buildkite_organization.allowed_api_ip_addresses - } -} -``` + +## Schema -## Argument Reference +### Read-Only -None. - -## Attributes Reference - -* `allowed_api_ip_addresses` - list of IP addresses in CIDR format that are allowed to access the Buildkite API. +- `allowed_api_ip_addresses` (List of String) List of IP addresses in CIDR format that are allowed to access the Buildkite API for this organization. +- `id` (String) The GraphQL ID of the organization. +- `uuid` (String) The UUID of the organization. diff --git a/docs/data-sources/pipeline.md b/docs/data-sources/pipeline.md index 6d1df0cb..874c86e4 100644 --- a/docs/data-sources/pipeline.md +++ b/docs/data-sources/pipeline.md @@ -1,26 +1,38 @@ -# Data Source: pipeline +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_pipeline Data Source - terraform-provider-buildkite" +subcategory: "" +description: |- + Use this data source to look up properties on a specific pipeline. This is particularly useful for looking up the webhook URL for each pipeline. + More info in the Buildkite documentation https://buildkite.com/docs/pipelines. +--- -Use this data source to look up properties on a specific pipeline. This is -particularly useful for looking up the webhook URL for each pipeline. +# buildkite_pipeline (Data Source) -Buildkite Documentation: https://buildkite.com/docs/pipelines +Use this data source to look up properties on a specific pipeline. This is particularly useful for looking up the webhook URL for each pipeline. + +More info in the Buildkite [documentation](https://buildkite.com/docs/pipelines). ## Example Usage -```hcl -data "buildkite_pipeline" "repo2" { - slug = "repo2" +```terraform +data "buildkite_pipeline" "pipeline" { + slug = "buildkite" } ``` -## Argument Reference + +## Schema + +### Required -* `slug` - (Required) The slug of the pipeline, available in the URL of the pipeline on buildkite.com +- `slug` (String) The slug of the pipeline. -## Attributes Reference +### Read-Only -* `description` - A description of the pipeline. -* `default_branch` - The default branch to prefill when new builds are created or triggered, usually main or master but can be anything. -* `name` - The name of the pipeline. -* `repository` - The git URL of the repository. -* `webhook_url` - The Buildkite webhook URL that triggers builds on this pipeline. +- `default_branch` (String) The default branch to prefill when new builds are created or triggered. +- `description` (String) The description of the pipeline. +- `id` (String) The GraphQL ID of the pipeline. +- `name` (String) The name of the pipeline. +- `repository` (String) The git URL of the repository. +- `webhook_url` (String) The Buildkite webhook URL that triggers builds on this pipeline. diff --git a/docs/data-sources/team.md b/docs/data-sources/team.md index 34f2d0d0..8cbf41bc 100644 --- a/docs/data-sources/team.md +++ b/docs/data-sources/team.md @@ -1,34 +1,39 @@ -# Data Source: team +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_team Data Source - terraform-provider-buildkite" +subcategory: "" +description: |- + Use this data source to retrieve a team by slug or id. You can find out more about teams in the Buildkite + documentation https://buildkite.com/docs/pipelines/permissions. +--- -Use this data source to look up properties of a team. This can be used to -validate that a team exists before setting the team slug on a pipeline. +# buildkite_team (Data Source) -Buildkite documentation: https://buildkite.com/docs/pipelines/permissions +Use this data source to retrieve a team by slug or id. You can find out more about teams in the Buildkite +[documentation](https://buildkite.com/docs/pipelines/permissions). ## Example Usage -```hcl -data "buildkite_team" "my_team_data" { - id = "" +```terraform +data "buildkite_team" "team" { + id = "Everyone" } ``` -## Argument Reference + +## Schema -One of: -* `id` - The GraphQL ID of the team, available in the Settings page for the team. -* `slug` - The slug of the team. Available in the URL of the team on buildkite.com; in the format - "" +### Optional -The `team` data-source supports **either** the use of `id` or `slug` for lookup of a team. +- `id` (String) The ID of the team to find. Use either ID or slug. +- `slug` (String) The slug of the team to find. Use either ID or slug. -## Attribute Reference +### Read-Only -* `id` - The GraphQL ID of the team -* `uuid` - The UUID of the team -* `name` - The name of the team -* `privacy` - Whether the team is visible to org members outside this team -* `description` - A description of the team -* `default_team` - Whether new org members will be automatically added to this team -* `default_member_role` - Default role to assign to a team member -* `members_can_create_pipelines` - Whether team members can create new pipelines and add them to the team +- `default_member_role` (String) The default member role of the team. +- `default_team` (Boolean) Whether the team is the default team. +- `description` (String) The description of the team. +- `members_can_create_pipelines` (Boolean) Whether members can create pipelines. +- `name` (String) The name of the team. +- `privacy` (String) The privacy setting of the team. +- `uuid` (String) The UUID of the team. diff --git a/docs/guides/elastic-ci-stack.md b/docs/guides/elastic-ci-stack.md new file mode 100644 index 00000000..9812706f --- /dev/null +++ b/docs/guides/elastic-ci-stack.md @@ -0,0 +1,35 @@ +--- +page_title: Usage with Elastic CI Stack for AWS +--- + +# Usage with the Elastic CI Stack for AWS + +There is not an official Terraform module for deploying Buildkite agents to AWS. However, there is a CloudFormation +stack available: https://github.com/buildkite/elastic-ci-stack-for-aws. + +If you want to manage all your infrastructure through Terraform, you can utilize the +[`aws`](https://registry.terraform.io/providers/hashicorp/aws/latest) provider to create a CloudFormation stack using +our template. An example is given below: + +For more information on the Elastic CI Stack for AWS, visit https://buildkite.com/docs/agent/v3/elastic-ci-aws/elastic-ci-stack-overview. + +```tf +resource "buildkite_agent_token" "elastic_stack" { + description = "Elastic stack" +} + +resource "aws_cloudformation_stack" "buildkite_agent_default" { + name = "buildkite-agent-default" + template_url = "https://s3.amazonaws.com/buildkite-aws-stack/master/aws-stack.yml" + capabilities = ["CAPABILITY_NAMED_IAM"] + parameters = { + AgentsPerInstance = 5 + AssociatePublicIpAddress = true + InstanceType = "i3.2xlarge" + MaxSize = 10 + MinSize = 0 + RootVolumeSize = 50 + BuildkiteAgentToken = buildkite_agent_token.elastic_stack.token + } +} +``` diff --git a/docs/guides/upgrade-v1.md b/docs/guides/upgrade-v1.md new file mode 100644 index 00000000..616e813d --- /dev/null +++ b/docs/guides/upgrade-v1.md @@ -0,0 +1,152 @@ +--- +page_title: Upgrading to v1.0 +--- + +# Upgrading to v1.0 + +The Buildkite Terraform provider 1.0 is considered stable and ready for production use. If you have been using the +provider prior to the 1.0 release, this guides you through upgrading. + +## New Features + +### Protocol version 6 +The provider has been upgraded to protocol v6. It is therefor only compatible with terraform CLI version 1.0 and later. + +### Cluster resources +You are now able to manage cluster resources with the provider. This includes `cluster`, `cluster_queue`, and +`cluster_agent_token`. + +### Test Analytics resources +You can now create test suites and assign teams access to them with `test_suite`, and `test_suite_team`. + +### Configurable API retry timeouts +API retries and timeouts have been implemented in the majority of resources. This adds reliability to the provider +around API latency and outages. + +By default, retries are set to 30 seconds. You can override this by operation type on the provider settings: + +```tf +provider "buildkite" { + organization = "buildkite" + timeouts = { + create = "90s" + delete = "10s" + } +} +``` + +### Archive pipeline on delete +Pipeline resources can now be archived instead of deleted when the resource is destroyed. This might be useful for users +who wish to keep the history around but disable the pipeline. This is configurable at the provider level: + +```tf +provider "buildkite" { + organization = "buildkite" + archive_pipeline_on_delete = true +} +``` + +## Changed Features + +### Pipeline resource `provider_settings` type change +The `provider_settings` attribute on the pipeline resource has been completely overhauled. It is now a nested attribute +(thanks to protocol v6) and has validation on inner attributes. + +Previously: + +```tf +resource "buildkite_pipeline" "pipeline" { + name = "deploy" + repository = "https://github.com/company/project.git" + provider_settings { + trigger_mode = "deployment" + } +} +``` + +Now, `provider_settings` is a nested attribute: + +```tf +resource "buildkite_pipeline" "pipeline" { + name = "deploy" + repository = "https://github.com/company/project.git" + provider_settings = { + trigger_mode = "deployment" + } +} +``` + +### Consistent IDs across resources +All resources now use their GraphQL IDs as the primary ID in the schema. + +## Removed Features + +- `team` attribute on pipeline resource has been removed. + +## Upgrade Guide + +### Pin provider version + +You should pin your provider installation to the 1.x releases. + +```tf +terraform { + required_providers { + buildkite = { + source = "buildkite/buildkite" + version = "~> 1.0" + } + } +} +``` + +### Migrate `pipeline.team` usage to `pipeline_team` resource + +The `team` attribute on the `pipeline` resource was removed in v1.0 in favour of a separate resource: +[`pipeline_team`](../resources/pipeline_team). + +You'll need to upgrade your provider to version `0.27.0` and switch over to the new resource prior to upgrading to v1.0. + +Before this change: + +```tf +resource "buildkite_team" "deploy" { + name = "deploy" + privacy = "VISIBLE" + default_team = true + default_member_role = "MEMBER" +} + +# only allow the deploy team to build the deploy pipeline +resource "buildkite_pipeline" "pipeline" { + name = "deploy" + repository = "https://github.com/company/project.git" + team { + slug = "deploy" + access_level = "BUILD_AND_READ" + } +} +``` + +After this change: + +```tf +resource "buildkite_team" "deploy" { + name = "deploy" + privacy = "VISIBLE" + default_team = true + default_member_role = "MEMBER" +} + +resource "buildkite_pipeline" "pipeline" { + name = "deploy" + repository = "https://github.com/company/project.git" +} + +# only allow the deploy team to build the deploy pipeline +resource "buildkite_pipeline_team" "deploy_pipeline" { + pipeline_id = buildkite_pipeline.pipeline.id + team_id = buildkite_team.deploy.id + access_level = "BUILD_AND_READ" +} +``` diff --git a/docs/index.md b/docs/index.md index 20a49ede..685e8935 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,49 +1,58 @@ -# Buildkite Provider +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite Provider" +subcategory: "" +description: |- + This provider can be used to manage resources on [buildkite.com](https://buildkite.com). +--- -This provider can be used to manage resources on [buildkite.com](https://buildkite.com) via Terraform. +# buildkite Provider -Two configuration values are required: - -- An API token, generated at https://buildkite.com/user/api-access-tokens. The - token must have the `write_pipelines`, `read_pipelines` and `write_suites` REST API scopes and also be enabled for GraphQL -- A Buildkite organization slug, available by signing into buildkite.com and - examining the URL: https://buildkite.com/ +This provider can be used to manage resources on [buildkite.com](https://buildkite.com). ## Example Usage -```hcl +```terraform terraform { required_providers { buildkite = { source = "buildkite/buildkite" - version = "0.27.0" + version = "~> 1.0" } } } +# Configure the Buildkite Provider provider "buildkite" { - api_token = "token" # can also be set from env: BUILDKITE_API_TOKEN - organization = "slug" # can also be set from env: BUILDKITE_ORGANIZATION_SLUG - timeouts { # override the default timeout of 30s for the create and update operations for all resources - create = "10s" - update = "15s" - } + organization = "buildkite" + # Use the `BUILDKITE_API_TOKEN` environment variable so the token is not committed + # api_token = "" +} + +# Add a pipeline +resource "buildkite_pipeline" "pipeline" { + # ... } ``` -## Argument Reference + +## Schema + +### Optional -- `api_token` - (Required) This is the Buildkite API Access Token. It must be provided but can also be sourced from the `BUILDKITE_API_TOKEN` environment variable. -- `organization` - (Required) This is the Buildkite organization slug. It must be provided, but can also be sourced from the `BUILDKITE_ORGANIZATION_SLUG` environment variable. The token requires GraphQL access and the `write_pipelines`, `read_pipelines` and `write_suites` REST API scopes. -- `graphql_url` - (Optional) This is the base URL to use for GraphQL requests. It defaults to "https://graphql.buildkite.com/v1", but can also be sourced from the `BUILDKITE_GRAPHQL_URL` environment variable. -- `rest_url` - (Optional) This is the the base URL to use for REST requests. It defaults to "https://api.buildkite.com", but can also be sourced from the `BUILDKITE_REST_URL` environment variable. -- `archive_pipeline_on_delete` - (Optional) Whether to archive pipelines when being destroyed instead of deleting them. This can be used a soft-delete approach to pipeline destruction. -- `timeouts` - (Optional. Default `30s`) A block of `create`, `read`, `update`, and `delete` durations. These are used by the provider per resource when running through the given CRUD operation. +- `api_token` (String, Sensitive) API token with GraphQL access and `write_pipelines`, `read_pipelines` and `write_suites` REST API scopes. You can generate a token from [your settings page](https://buildkite.com/user/api-access-tokens/new?description=terraform&scopes[]=write_pipelines&scopes[]=write_suites&scopes[]=read_pipelines&scopes[]=graphql). If not provided, the value is taken from the `BUILDKITE_API_TOKEN` environment variable. +- `archive_pipeline_on_delete` (Boolean) Enable this to archive pipelines when destroying the resource. This is opposed to completely deleting pipelines. +- `graphql_url` (String) Base URL for the GraphQL API to use. If not provided, the value is taken from the `BUILDKITE_GRAPHQL_URL` environment variable. +- `organization` (String) The Buildkite organization slug. This can be found on the [settings](https://buildkite.com/organizations/~/settings) page. If not provided, the value is taken from the `BUILDKITE_ORGANIZATION_SLUG` environment variable. +- `rest_url` (String) Base URL for the REST API to use. If not provided, the value is taken from the `BUILDKITE_REST_URL` environment variable. +- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -## Usage of `timeouts` and retries + +### Nested Schema for `timeouts` -All resources and datasources managed by this provider have a global timeout configuration. This timeout is used to limit when performing the CRUD operations on each resource. -It is configured globally for the provider but each resource uses the timeout separately. Ie. if you manage 3 pipelines in terraform and have set an update timeout of 15 seconds, each pipeline will be given 15 seconds to finish updating (not 15/3 (5) seconds to update). +Optional: -CRUD operations also have retries configured with an exponential back-off. The retry attempts are included in the timeout. Ie. with a timeout of 15 seconds, a pipeline create operation will retry as many times as it can within 15 seconds. -This helps to automatically retry operations when the API is experiencing high latency. +- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). +- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs. +- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled. +- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). diff --git a/docs/resources/agent_token.md b/docs/resources/agent_token.md index c9501f04..7fdb9a56 100644 --- a/docs/resources/agent_token.md +++ b/docs/resources/agent_token.md @@ -1,27 +1,35 @@ -# Resource: agent_token +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_agent_token Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + This resource allows you to create and manage non-clustered agent tokens. + You can find out more about clusters in the Buildkite documentation https://buildkite.com/docs/agent/v3/tokens. +--- -This resource allows you to create and manage agent tokens. +# buildkite_agent_token (Resource) -Buildkite Documentation: https://buildkite.com/docs/agent/v3/tokens +This resource allows you to create and manage non-clustered agent tokens. +You can find out more about clusters in the Buildkite [documentation](https://buildkite.com/docs/agent/v3/tokens). ## Example Usage -```hcl -provider "buildkite" {} - -resource "buildkite_agent_token" "fleet" { - description = "token used by build fleet" +```terraform +# create a default token +resource "buildkite_agent_token" "default" { + description = "Default token" } ``` -## Argument Reference + +## Schema -* `description` - (Optional) This is the description of the agent token. +### Optional --> Changing `description` will cause the resource to be destroyed and re-created. +- `description` (String) The description of the agent token. Used to help identify its use. -## Attribute Reference +### Read-Only -* `id` - The Graphql ID of the created agent token. -* `token` - The value of the created agent token. -* `uuid` - The UUID of the token. +- `id` (String) The GraphQL ID of the agent token. +- `token` (String, Sensitive) The token value used by an agent to register with the API. +- `uuid` (String) The UUID of the agent token. diff --git a/docs/resources/cluster.md b/docs/resources/cluster.md index 41e90b32..04bd92c9 100644 --- a/docs/resources/cluster.md +++ b/docs/resources/cluster.md @@ -1,53 +1,82 @@ -# Resource: cluster +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_cluster Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + This resource allows you to create and manage a Buildkite Cluster to run your builds in. + Clusters are useful for grouping agents by there capabilities or permissions. + Find out more information in our documentation https://buildkite.com/docs/clusters/overview. +--- -This resource allows you to create, manage and import Clusters. +# buildkite_cluster (Resource) -Buildkite documentation: https://buildkite.com/docs/clusters/overview +This resource allows you to create and manage a Buildkite Cluster to run your builds in. +Clusters are useful for grouping agents by there capabilities or permissions. +Find out more information in our [documentation](https://buildkite.com/docs/clusters/overview). ## Example Usage -```hcl -provider "buildkite" {} +```terraform +# create a cluster +resource "buildkite_cluster" "primary" { + name = "Primary cluster" + description = "Runs the monolith build and deploy" + emoji = "🚀" + color = "#bada55" +} + +# add a pipeline to the cluster +resource "buildkite_pipeline" "monolith" { + name = "Monolith" + repository = "https://github.com/..." + cluster_id = buildkite_cluster.primary.id +} -resource "buildkite_cluster" "linux" { - name = "linux_builds" +resource "buildkite_cluster_queue" "default" { + cluster_id = buildkite_cluster.primary.id + key = "default" } ``` -## Argument Reference + +## Schema + +### Required + +- `name` (String) The name of the Cluster. Can only contain numbers and letters, no spaces or special characters. -* `name` - (Required) This is the name of the cluster. -* `description` - (Optional) This is a description for the cluster, this may describe the usage for it, the region, or something else which would help identify the Cluster's purpose. -* `emoji` - (Optional) An emoji to use with the Cluster, this can either be set using `:buildkite:` notation, or with the emoji itself, such as 😎. -* `color` - (Optional) A color to associate with the Cluster. Perhaps a team related color, or one related to an environment. This is set using hex value, such as `#BADA55`. +### Optional -## Attribute Reference +- `color` (String) A color representation of the Cluster. Accepts hex codes, eg #BADA55. +- `description` (String) This is a description for the cluster, this may describe the usage for it, the region, or something else +which would help identify the Cluster's purpose. +- `emoji` (String) An emoji to use with the Cluster, this can either be set using :buildkite: notation, or with the +emoji itself, such as 🚀. -* `id` - The GraphQL ID that is created with the Cluster. -* `uuid` - The UUID created with the Cluster. +### Read-Only +- `id` (String) The GraphQL ID of the cluster. +- `uuid` (String) The UUID of the cluster. ## Import -Clusters can be imported using their `ID`, this can be found in the Clusters's `Settings` page, e.g. -```shell -terraform import buildkite_cluster.foo Q2x1c3Rlci0tLTI3ZmFmZjA4LTA3OWEtNDk5ZC1hMmIwLTIzNmY3NWFkMWZjYg== -``` +Import is supported using the following syntax: -A helpful GraphQL query to get the ID of the target cluster can be found below, or [this pre-saved query](https://buildkite.com/user/graphql/console/a803f254-decf-45a3-8332-a074b0a73483) can be used as a template. You'll need to substitute in your organization's `slug`. - -```graphql -query getClusters { - organization(slug: "ORGANIZATION"){ - clusters(first: 5, order:NAME) { - edges{ - node { - id - name - } - } - } - } -} +```shell +# import a cluster resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getClusters { +# organization(slug: "ORGANIZATION"){ +# clusters(first: 5, order:NAME) { +# edges{ +# node { +# id +# name +# } +# } +# } +# } +# } +terraform import buildkite_cluster.primary Q2x1c3Rlci0tLTI3ZmFmZjA4LTA3OWEtNDk5ZC1hMmIwLTIzNmY3NWFkMWZjYg== ``` - diff --git a/docs/resources/cluster_agent_token.md b/docs/resources/cluster_agent_token.md index b0089692..6335cf63 100644 --- a/docs/resources/cluster_agent_token.md +++ b/docs/resources/cluster_agent_token.md @@ -1,27 +1,55 @@ -# Resource: cluster_agent_token +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_cluster_agent_token Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + A Cluster Agent Token is a token used to connect an agent to a cluster in Buildkite. +--- -This resource allows you to create and manage cluster agent tokens. +# buildkite_cluster_agent_token (Resource) -Buildkite Documentation: https://buildkite.com/docs/clusters/manage-clusters#set-up-clusters-connect-agents-to-a-cluster +A Cluster Agent Token is a token used to connect an agent to a cluster in Buildkite. ## Example Usage -```hcl -provider "buildkite" {} +```terraform +# create a cluster +resource "buildkite_cluster" "primary" { + name = "Primary cluster" + description = "Runs the monolith build and deploy" + emoji = "🚀" + color = "#bada55" +} + +# create an agent token for the cluster +resource "buildkite_cluster_agent_token" "default" { + description = "Default cluster token" + cluster_id = buildkite_cluster.primary.id +} -resource "buildkite_cluster_agent_token" "cluster-token-1" { - cluster_id = "Q2x1c3Rlci0tLTkyMmVjOTA4LWRmNWItNDhhYS1hMThjLTczMzE0YjQ1ZGYyMA==" - description = "agent token for cluster-1" +resource "buildkite_pipeline" "monolith" { + name = "Monolith" + repository = "https://github.com/..." + cluster_id = buildkite_cluster.primary.id +} + +resource "buildkite_cluster_queue" "default" { + cluster_id = buildkite_cluster.primary.id + key = "default" } ``` -## Argument Reference + +## Schema + +### Required -* `cluster_id` - (Required) The ID of the cluster that this cluster queue belongs to. -* `description` - (Required) A description about what this cluster agent token is used for. +- `cluster_id` (String) The GraphQL ID of the Cluster that this Cluster Agent Token belongs to. +- `description` (String) A description about what this cluster agent token is used for. -## Attribute Reference +### Read-Only -* `id` - The Graphql ID of the created cluster queue. -* `uuid` - The UUID of the created cluster queue. -* `cluster_uuid` - The UUID of the cluster that this cluster queue belongs to. +- `cluster_uuid` (String) The UUID of the Cluster that this token belongs to. +- `id` (String) The GraphQL ID of the token. +- `token` (String, Sensitive) The token value used by an agent to register with the API. +- `uuid` (String) The UUID of the token. diff --git a/docs/resources/cluster_queue.md b/docs/resources/cluster_queue.md index 8c2017d1..f83ccacd 100644 --- a/docs/resources/cluster_queue.md +++ b/docs/resources/cluster_queue.md @@ -1,74 +1,78 @@ -# Resource: cluster_queue +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_cluster_queue Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + A Cluster Queue is a queue belonging to a specific Cluster for its Agents to target builds on. +--- -This resource allows you to create and manage cluster queues. +# buildkite_cluster_queue (Resource) -Buildkite Documentation: https://buildkite.com/docs/clusters/manage-clusters#set-up-clusters-create-a-queue +A Cluster Queue is a queue belonging to a specific Cluster for its Agents to target builds on. ## Example Usage -```hcl -provider "buildkite" {} +```terraform +# create a cluster +resource "buildkite_cluster" "primary" { + name = "Primary cluster" + description = "Runs the monolith build and deploy" + emoji = "🚀" + color = "#bada55" +} + +resource "buildkite_pipeline" "monolith" { + name = "Monolith" + repository = "https://github.com/..." + cluster_id = buildkite_cluster.primary.id +} -resource "buildkite_cluster_queue" "queue1" { - cluster_id = "Q2x1c3Rlci0tLTMzMDc0ZDhiLTM4MjctNDRkNC05YTQ3LTkwN2E2NWZjODViNg==" - key = "prod-deploy" - description = "Prod deployment cluster queue" +# create a queue to put pipeline builds in +resource "buildkite_cluster_queue" "default" { + cluster_id = buildkite_cluster.primary.id + key = "default" } ``` -## Argument Reference + +## Schema -* `cluster_id` - (Required) The ID of the cluster that this cluster queue belongs to. -* `key` - (Required) The key of the cluster queue. -* `description` - (Optional) The description of the cluster queue. +### Required -## Attribute Reference +- `cluster_id` (String) The ID of the cluster that this cluster queue belongs to. +- `key` (String) The key of the cluster queue. -* `id` - The Graphql ID of the created cluster queue. -* `uuid` - The UUID of the created cluster queue. -* `cluster_uuid` - The UUID of the cluster that this cluster queue belongs to. +### Optional -## Import +- `description` (String) A description for the cluster queue. -Cluster queues can be imported using its `GraphQL ID`, along with its respective cluster `UUID`, separated by a comma. e.g. +### Read-Only -``` -$ terraform import buildkite_cluster_queue.test Q2x1c3RlclF1ZXVlLS0tYjJiOGRhNTEtOWY5My00Y2MyLTkyMjktMGRiNzg3ZDQzOTAz,35498aaf-ad05-4fa5-9a07-91bf6cacd2bd -``` +- `cluster_uuid` (String) The UUID of the cluster this queue belongs to. +- `id` (String) The GraphQL ID of the cluster queue. +- `uuid` (String) The UUID of the cluster queue. -To find the cluster's `UUID` to utilize, you can use the below GraphQL query below. Alternatively, you can use this [pre-saved query](https://buildkite.com/user/graphql/console/3adf0389-02bd-45ef-adcd-4e8e5ae57f25), where you will need fo fill in the organization slug (ORGANIZATION_SLUG) for obtaining the relevant cluster name/`UUID` that the cluster queue is in. - -```graphql -query getClusters { - organization(slug: "ORGANIZATION_SLUG") { - clusters(first: 50) { - edges{ - node{ - name - uuid - } - } - } - } -} -``` +## Import -After the cluster `UUID` has been found, you can use the below GraphQL query to find the cluster queue's `GraphQL ID`. Alternatively, this [pre-saved query](https://buildkite.com/user/graphql/console/1d913905-900e-40e7-8f46-651543487b5a) can be used, specifying the organization slug (ORGANIZATION_SLUG) and the cluster `UUID` from above (CLUSTER_UUID). - -```graphql -query getClusterQueues { - organization(slug: "ORGANIZATION_SLUG") { - cluster(id: "CLUSTER_UUID") { - queues(first: 50) { - edges { - node { - id - key - } - } - } - } - } -} +Import is supported using the following syntax: + +```shell +# import a cluster queue resource using the GraphQL ID along with its respective cluster UUID +# +# you can use this query to find the ID: +# query getClusterQueues { +# organization(slug: "ORGANIZATION_SLUG") { +# cluster(id: "CLUSTER_UUID") { +# queues(first: 50) { +# edges { +# node { +# id +# key +# } +# } +# } +# } +# } +# } +terraform import buildkite_cluster_queue.test Q2x1c3RlclF1ZXVlLS0tYjJiOGRhNTEtOWY5My00Y2MyLTkyMjktMGRiNzg3ZDQzOTAz,35498aaf-ad05-4fa5-9a07-91bf6cacd2bd ``` - diff --git a/docs/resources/organization.md b/docs/resources/organization.md index 3064f56a..0f816a39 100644 --- a/docs/resources/organization.md +++ b/docs/resources/organization.md @@ -1,29 +1,46 @@ -# Resource: organization +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_organization Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + This resource allows you to manage the settings for an organization. + The user of your API token must be an organization administrator to manage organization settings. +--- -This resource allows you to manage the settings for an organization. +# buildkite_organization (Resource) -You must be an organization administrator to manage organization settings. +This resource allows you to manage the settings for an organization. -Note: The "Allowed API IP Addresses" feature must be enabled on your organization in order to manage the `allowed_api_ip_addresses` attribute. +The user of your API token must be an organization administrator to manage organization settings. ## Example Usage -```hcl -resource "buildkite_organization" "test_settings" { +```terraform +# allow api access only from 1.1.1.1 +resource "buildkite_organization" "settings" { allowed_api_ip_addresses = ["1.1.1.1/32"] } ``` -## Argument Reference + +## Schema + +### Optional + +- `allowed_api_ip_addresses` (List of String) A list of IP addresses in CIDR format that are allowed to access the Buildkite API.If not set, all IP addresses are allowed (the same as setting 0.0.0.0/0). -- `allowed_api_ip_addresses` - (Optional) A list of IP addresses in CIDR format that are allowed to access the Buildkite API. If not set, all IP addresses are allowed (the same as setting 0.0.0.0/0). +-> The "Allowed API IP Addresses" feature must be enabled on your organization in order to manage the `allowed_api_ip_addresses` attribute. + +### Read-Only + +- `id` (String) The GraphQL ID of the organization. +- `uuid` (String) The UUID of the organization. ## Import -Organization settings can be imported by passing the organization slug to the import command, along with the identifier of the resource. +Import is supported using the following syntax: +```shell +# import the organization settings via the organization slug +terraform import buildkite_organization.settings ``` -$ terraform import buildkite_organization.test_settings test_org -``` - -Your organization's slug can be found in your organisation's [settings](https://buildkite.com/organizations/~/settings) page. diff --git a/docs/resources/pipeline.md b/docs/resources/pipeline.md index 40e78f2a..201e42ba 100644 --- a/docs/resources/pipeline.md +++ b/docs/resources/pipeline.md @@ -1,77 +1,31 @@ -# Resource: pipeline +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_pipeline Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + This resource allows you to create and manage pipelines for repositories. + More information on pipelines can be found in the documentation](https://buildkite.com/docs/pipelines). +--- + +# buildkite_pipeline (Resource) This resource allows you to create and manage pipelines for repositories. -Buildkite Documentation: https://buildkite.com/docs/pipelines +More information on pipelines can be found in the documentation](https://buildkite.com/docs/pipelines). ## Example Usage -```hcl -# in ./steps.yml: -# steps: -# - label: ':pipeline:' -# command: buildkite-agent pipeline upload - -resource "buildkite_pipeline" "repo2" { - name = "repo2" - repository = "git@github.com:org/repo2" - steps = file("./steps.yml") +```terraform +# minimal repository +resource "buildkite_pipeline" "pipeline" { + name = "repo" + repository = "git@github.com:org/repo" } -``` - -## Example Usage with command timeouts -```hcl -resource "buildkite_pipeline" "test_new" { - name = "Testing Timeouts" - repository = "https://github.com/buildkite/terraform-provider-buildkite.git" - - steps = file("./deploy-steps.yml") - - default_timeout_in_minutes = 60 - maximum_timeout_in_minutes = 120 -} -``` - -Currently, the `default_timeout_in_minutes` and `maximum_timeout_in_minutes` will be retained in state even if removed from the configuration. In order to remove them, you must set them to `0` in either the configuration or the web UI. - -## Example Usage with Lifecycles - -```hcl -resource "buildkite_pipeline" "test_new" { - name = "Testing Timeouts" - repository = "https://github.com/buildkite/terraform-provider-buildkite.git" - - steps = file("./deploy-steps.yml") - - lifecycle { - prevent_destroy = true - } -} -``` - -[Lifecycles](https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle) allow you to set general rules -for resources, including the prevention of destruction of a resource. In the above example, the `destroy` command on the `Testing TImeouts` pipeline will fail. - -## Example Usage with GitHub Provider Settings - -```hcl -# Pipeline that should not be triggered from a GitHub webhook -resource "buildkite_pipeline" "repo2-deploy" { - name = "repo2" - repository = "git@github.com:org/repo2" - steps = file("./deploy-steps.yml") - - provider_settings { - trigger_mode = "none" - } -} - -# Release pipeline (triggered only when tags are pushed) -resource "buildkite_pipeline" "repo2-release" { - name = "repo2" - repository = "git@github.com:org/repo2" - steps = file("./release-steps.yml") +# with github provider settings +resource "buildkite_pipeline" "pipeline" { + name = "repo" + repository = "git@github.com:org/repo" provider_settings { build_branches = false @@ -82,88 +36,75 @@ resource "buildkite_pipeline" "repo2-release" { } ``` -## Argument Reference - -- `name` - (Required) The name of the pipeline. -- `repository` - (Required) The git URL of the repository. -- `steps` - (Optional) The string YAML steps to run the pipeline. Defaults to `buildkite-agent pipeline upload` if not specified. -- `description` - (Optional) A description of the pipeline. -- `default_branch` - (Optional) The default branch to prefill when new builds are created or triggered, usually main or master but can be anything. -- `default_timeout_in_minutes` - (Optional) The default timeout for commands in this pipeline, in minutes. -- `maximum_timeout_in_minutes` - (Optional) The maximum timeout for commands in this pipeline, in minutes. -- `branch_configuration` - (Optional) Limit which branches and tags cause new builds to be created, either via a code push or via the Builds REST API. -- `skip_intermediate_builds` - (Optional, Default: `false` ) A boolean to enable automatically skipping any unstarted builds on the same branch when a new build is created. -- `skip_intermediate_builds_branch_filter` - (Optional) Limit which branches build skipping applies to, for example `!master` will ensure that the master branch won't have its builds automatically skipped. -- `cancel_intermediate_builds` - (Optional, Default: `false` ) A boolean to enable automatically cancelling any running builds on the same branch when a new build is created. -- `cancel_intermediate_builds_branch_filter` - (Optional) Limit which branches build cancelling applies to, for example !master will ensure that the master branch won't have its builds automatically cancelled. -- `allow_rebuilds` - (Optional, Default: `true` ) A boolean on whether or not to allow rebuilds for the pipeline. -- `cluster_id` - (Optional) The GraphQL ID of the cluster you want to use for the pipeline. -- `tags` - (Optional) A set of tags to be set to the pipeline. For example `["terraform", "provider"]`. -- `provider_settings` - (Optional) Source control provider settings for the pipeline. See [Provider Settings Configuration](#provider-settings-configuration) below for details. - - -### Provider Settings Configuration - --> **Note:** Supported provider settings depend on a source version control provider used by your organization. - -Properties available for Bitbucket Server: - -- `build_pull_requests` - (Optional) Whether to create builds for commits that are part of a Pull Request. -- `build_branches` - (Optional) Whether to create builds when branches are pushed. -- `build_tags` - (Optional) Whether to create builds when tags are pushed. - -Properties available for Bitbucket Cloud, GitHub, and GitHub Enterprise: - -- `build_pull_requests` - (Optional) Whether to create builds for commits that are part of a Pull Request. -- `build_branches` - (Optional) Whether to create builds when branches are pushed. -- `build_tags` - (Optional) Whether to create builds when tags are pushed. -- `filter_enabled` - (Optional) [true/false] Whether to filter builds to only run when the condition in `filter_condition` is true -- `filter_condition` - (Optional) The condition to evaluate when deciding if a build should run. More details available in [the documentation](https://buildkite.com/docs/pipelines/conditionals#conditionals-in-pipelines) -- `pull_request_branch_filter_enabled` - (Optional) Whether to limit the creation of builds to specific branches or patterns. -- `pull_request_branch_filter_configuration` - (Optional) The branch filtering pattern. Only pull requests on branches matching this pattern will cause builds to be created. -- `skip_builds_for_existing_commits` - (Optional) Whether to skip creating a new build if an existing build for the commit and branch already exists. -- `skip_pull_request_builds_for_existing_commits` - (Optional) Whether to skip creating a new build for a pull request if an existing build for the commit and branch already exists. -- `publish_commit_status` - (Optional) Whether to update the status of commits in Bitbucket or GitHub. -- `publish_commit_status_per_step` - (Optional) Whether to create a separate status for each job in a build, allowing you to see the status of each job directly in Bitbucket or GitHub. -- `cancel_deleted_branch_builds` - (Optional, Default: `false` ) A boolean to enable automatically cancelling any running builds for a branch if the branch is deleted. - -Additional properties available for GitHub: - -- `trigger_mode` - (Optional) What type of event to trigger builds on. Must be one of: - - - `code` will create builds when code is pushed to GitHub. - - `deployment` will create builds when a deployment is created with the GitHub Deployments API. - - `fork` will create builds when the GitHub repository is forked. - - `none` will not create any builds based on GitHub activity. - -- `build_pull_request_forks` - (Optional) Whether to create builds for pull requests from third-party forks. -- `build_pull_request_labels_changed` - (Optional) Whether to create builds for pull requests when labels are added or removed. -- `build_pull_request_ready_for_review` - (Optional) Whether to create builds for pull requests that are ready for review. -- `prefix_pull_request_fork_branch_names` - (Optional) Prefix branch names for third-party fork builds to ensure they don't trigger branch conditions. For example, the `master` branch from `some-user` will become `some-user:master`. -- `separate_pull_request_statuses` - (Optional) Whether to create a separate status for pull request builds, allowing you to require a passing pull request build in your [required status checks](https://help.github.com/en/articles/enabling-required-status-checks) in GitHub. -- `publish_blocked_as_pending` - (Optional) The status to use for blocked builds. Pending can be used with [required status checks](https://help.github.com/en/articles/enabling-required-status-checks) to prevent merging pull requests with blocked builds. - -## Attribute Reference - -- `id` - The GraphQL ID of the pipeline -- `webhook_url` - The Buildkite webhook URL to configure on the repository to trigger builds on this pipeline. -- `slug` - The slug of the created pipeline. -- `badge_url` - The pipeline's last build status so you can display build status badge. + +## Schema + +### Required + +- `name` (String) Name to give the pipeline. +- `repository` (String) URL to the repository this pipeline is configured for. + +### Optional + +- `allow_rebuilds` (Boolean) Whether rebuilds are allowed for this pipeline. +- `branch_configuration` (String) Configure the pipeline to only build on this branch conditional. +- `cancel_intermediate_builds` (Boolean) Whether to cancel builds when a new commit is pushed to a matching branch. +- `cancel_intermediate_builds_branch_filter` (String) Filter the `cancel_intermediate_builds` setting based on this branch condition. +- `cluster_id` (String) Attach this pipeline to the given cluster GraphQL ID. +- `default_branch` (String) Default branch of the pipeline. +- `default_timeout_in_minutes` (Number) Set pipeline wide timeout for command steps. +- `description` (String) Description for the pipeline. Can include emoji 🙌. +- `maximum_timeout_in_minutes` (Number) Set pipeline wide maximum timeout for command steps. +- `provider_settings` (Block List) Control settings depending on the VCS provider used in `repository`. (see [below for nested schema](#nestedblock--provider_settings)) +- `skip_intermediate_builds` (Boolean) Whether to skip queued builds if a new commit is pushed to a matching branch. +- `skip_intermediate_builds_branch_filter` (String) Filter the `skip_intermediate_builds` setting based on this branch condition. +- `steps` (String) The YAML steps to configure for the pipeline. Defaults to `buildkite-agent pipeline upload`. +- `tags` (Set of String) Tags to attribute to the pipeline. Useful for searching by in the UI. + +### Read-Only + +- `badge_url` (String) The badge URL showing build state. +- `id` (String) The GraphQL ID of the pipeline. +- `slug` (String) The slug generated for the pipeline. +- `webhook_url` (String) The webhook URL used to trigger builds from VCS providers. + + +### Nested Schema for `provider_settings` + +Optional: + +- `build_branches` (Boolean) Whether to create builds when branches are pushed. Only valid for GitHub and Bitbucket repositories. +- `build_pull_request_forks` (Boolean) Whether to create builds for pull requests from third-party forks.Only valid for GitHub repositories that have `trigger_mode = "code"` and `build_pull_requests = true`. +- `build_pull_request_labels_changed` (Boolean) Whether to create builds for pull requests when labels are added or removed.Only valid for GitHub repositories that have `trigger_mode = "code"` and `build_pull_requests = true`. +- `build_pull_request_ready_for_review` (Boolean) Whether to create a build when a pull request changes to "Ready for review".Only valid for GitHub repositories that have `trigger_mode = "code"` and `build_pull_requests = true`. +- `build_pull_requests` (Boolean) Whether to create builds for commits that are part part of a pull request.Only valid for Bitbucket or GitHub using a `trigger_mode = "code"` +- `build_tags` (Boolean) Whether to create builds when tags are pushed. Only valid for GitHub and Bitbucket repositories. +- `cancel_deleted_branch_builds` (Boolean) Automatically cancel running builds for a branch if the branch is deleted. Only valid for GitHub repositories when `trigger_mode = "code"`. +- `filter_condition` (String) The condition to evaluate when deciding if a build should run.More details available in [the documentation](https://buildkite.com/docs/pipelines/conditionals#conditionals-in-pipelines).Only valid if `filter_enabled = true`. +- `filter_enabled` (Boolean) Whether to filter builds to only run when the condition in `filter_condition` is true.Only valid for GitHub repositories when `trigger_mode = "code"`. +- `prefix_pull_request_fork_branch_names` (Boolean) Prefix branch names for third-party fork builds to ensure they don't trigger branch conditions.For example, the master branch from some-user will become some-user:master.Only valid when `build_pull_request_forks = true`. +- `publish_blocked_as_pending` (Boolean) The status to use for blocked builds. Pending can be used with [required status checks](https://help.github.com/en/articles/enabling-required-status-checks)to prevent merging pull requests with blocked builds. Only valid for GitHub repositories when `publish_commit_statue = true`. +- `publish_commit_status` (Boolean) Whether to update the status of commits in Bitbucket or GitHub.Only valid for Bitbucket, or GitHub repositories when `trigger_mode = "code"`. +- `publish_commit_status_per_step` (Boolean) Whether to create a separate status for each job in a build, allowing you to see the status of each job directly in Bitbucket or GitHub. +- `pull_request_branch_filter_configuration` (String) Filter pull requests builds by the branch filter. Only valid if `pull_request_branch_filter_enabled = true`. +- `pull_request_branch_filter_enabled` (Boolean) Filter pull request builds. Only valid if `build_pull_requests = true`. +- `separate_pull_request_statuses` (Boolean) Whether to create a separate status for pull request builds, allowing you to require a passing pull requestbuild in your [required status checks](https://help.github.com/en/articles/enabling-required-status-checks) in GitHub. +- `skip_builds_for_existing_commits` (Boolean) Whether to skip creating a new build if an existing build for the commit and branch already exists.Only valid for GitHub repositories. +- `skip_pull_request_builds_for_existing_commits` (Boolean) Whether to skip creating a new build for a pull request if an existing build for the commit and branch already exists.Only valid if `build_pull_requests = true`. +- `trigger_mode` (String) What type of event to trigger builds on. Must be one of: + - `code` will create builds when code is pushed to GitHub. + - `deployment` will create builds when a deployment is created in GitHub. + - `fork` will create builds when the GitHub repository is forked. + - `none` will not create any builds based on GitHub activity. + + -> `trigger_mode` is only valid if the pipeline uses a GitHub repository. ## Import -Pipelines can be imported using the `GraphQL ID` (not UUID), e.g. +Import is supported using the following syntax: -``` -$ terraform import buildkite_pipeline.fleet UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ= -``` - -To find the ID to use, you can use the GraphQL query below. Alternatively, you could use this [pre-saved query](https://buildkite.com/user/graphql/console/04e6ac1d-222e-49f9-8167-4767ab0f5362). - -```graphql -query getPipelineId { - pipeline(slug: "ORGANIZATION_SLUG/PIPELINE_SLUG") { - id - } -} +```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= ``` diff --git a/docs/resources/pipeline_schedule.md b/docs/resources/pipeline_schedule.md index 18bf0b6a..32eaec8a 100644 --- a/docs/resources/pipeline_schedule.md +++ b/docs/resources/pipeline_schedule.md @@ -1,63 +1,83 @@ -# Resource: pipeline_schedule +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_pipeline_schedule Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + A pipeline schedule is a schedule that triggers a pipeline to run at a specific time. + You can find more information in the documentation https://buildkite.com/docs/pipelines/scheduled-builds. +--- -This resource allows you to create and manage pipeline schedules. +# buildkite_pipeline_schedule (Resource) -Buildkite Documentation: https://buildkite.com/docs/pipelines/scheduled-builds +A pipeline schedule is a schedule that triggers a pipeline to run at a specific time. + +You can find more information in the [documentation](https://buildkite.com/docs/pipelines/scheduled-builds). ## Example Usage -```hcl -resource "buildkite_pipeline_schedule" "repo2_nightly" { - pipeline_id = buildkite_pipeline.repo2.id +```terraform +# create a pipeline +resource "buildkite_pipeline" "pipeline" { + name = "my pipeline" + repository = "https://github.com/..." +} + +# schedule a build at midnight every day +resource "buildkite_pipeline_schedule" "nightly" { + pipeline_id = buildkite_pipeline.repo.id label = "Nightly build" cronline = "@midnight" - branch = buildkite_pipeline.repo2.default_branch + branch = buildkite_pipeline.repo.default_branch } ``` -## Argument Reference + +## Schema -* `pipeline_id` - (Required) Terraform resource ID of a buildkite pipeline (Buildkite GraphQL ID). -* `label` - (Required) Schedule label. -* `cronline` - (Required) Schedule interval (see [docs](https://buildkite.com/docs/pipelines/scheduled-builds#schedule-intervals)). -* `branch` - (Required) The branch to use for the build. -* `commit` - (Optional, Default: `HEAD`) The commit ref to use for the build. -* `message` - (Optional, Default: `Scheduled build`) The message to use for the build. -* `env` - (Optional) A map of environment variables to use for the build. -* `enabled` - (Optional, Default: `true`) Whether the schedule should run. +### Required -## Attribute Reference +- `branch` (String) The branch that the schedule should run on. +- `cronline` (String) The cronline that describes when the schedule should run. See[here](https://buildkite.com/docs/pipelines/scheduled-builds#schedule-intervals) for supported syntax. +- `label` (String) A label to describe the schedule. +- `pipeline_id` (String) The GraphQL ID of the pipeline that this schedule belongs to. -* `id` - The GraphQL ID of the pipeline schedule -* `uuid` - The UUID of the pipeline schedule +### Optional -## Import +- `commit` (String) The commit that the schedule should run on. +- `enabled` (Boolean) Whether the schedule is enabled or not. +- `env` (Map of String) The environment variables that scheduled builds should use. +- `message` (String) The message the builds show for builds created by this schedule. -Pipeline schedules can be imported using their `GraphQL ID`, e.g. +### Read-Only -``` -$ terraform import buildkite_pipeline_schedule.test UGlwZWxpgm5Tf2hhZHVsZ35tLWRk4DdmN7c4LTA5M2ItNDM9YS0gMWE0LTAwZDUgYTAxYvRf49== -``` +- `id` (String) The GraphQL ID of the schedule. +- `uuid` (String) The UUID of the schedule. -Your pipeline schedules' GraphQL ID can be found with the below GraphQL query below. Alternatively, you could use this [pre-saved query](https://buildkite.com/user/graphql/console/45687b7c-2565-4acb-8a74-750a3647875f), specifying the organisation slug (when known) and the pipeline search term (PIPELINE_SEARCH_TERM). - -```graphql -query getPipelineScheduleId { - organization(slug: "ORGANIZATION_SLUG") { - pipelines(first: 5, search: "PIPELINE_SEARCH_TERM") { - edges{ - node{ - name - schedules{ - edges{ - node{ - id - } - } - } - } - } - } - } -} +## Import + +Import is supported using the following syntax: + +```shell +# import a pipeline schedule resource using the schedules GraphQL ID +# +# you can use this query to find the schedule: +# query getPipelineScheduleId { +# organization(slug: "ORGANIZATION_SLUG") { +# pipelines(first: 5, search: "PIPELINE_SEARCH_TERM") { +# edges{ +# node{ +# name +# schedules{ +# edges{ +# node{ +# id +# } +# } +# } +# } +# } +# } +# } +# } +terraform import buildkite_pipeline_schedule.test UGlwZWxpgm5Tf2hhZHVsZ35tLWRk4DdmN7c4LTA5M2ItNDM9YS0gMWE0LTAwZDUgYTAxYvRf49== ``` diff --git a/docs/resources/pipeline_team.md b/docs/resources/pipeline_team.md index 677ee840..0012345f 100644 --- a/docs/resources/pipeline_team.md +++ b/docs/resources/pipeline_team.md @@ -1,49 +1,70 @@ -# Resource: pipeline_team +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_pipeline_team Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + Manage team access to a pipeline. +--- -This resource allows you to create and manage team configuration in a pipeline. +# buildkite_pipeline_team (Resource) -Buildkite Documentation: https://buildkite.com/docs/pipelines/permissions#permissions-with-teams-pipeline-level-permissions +Manage team access to a pipeline. ## Example Usage -```hcl -resource "buildkite_pipeline_team" "developers" { - pipeline_id = buildkite_pipeline.repo2 - team_id = buildkite_team.test.id - access_level = "MANAGE_BUILD_AND_READ" +```terraform +resource "buildkite_pipeline" "pipeline" { + name = "my pipeline" + repository = "https://github.com/..." +} + +resource "buildkite_team" "team" { + name = "Everyone" + privacy = "VISIBLE" + default_team = false + default_member_role = "MEMBER" +} + +# allow everyone in the "Everyone" team read-only access to pipeline +resource "buildkite_pipeline_team" "pipeline_team" { + pipeline_id = buildkite_pipeline.pipeline.id + team_id = buildkite_team.team.id + access_level = "READ_ONLY" } ``` -## Argument Reference + +## Schema -* `team_id` - (Required) The GraphQL ID of the team to add to/remove from. -* `pipeline_id` - (Required) Terraform resource ID of a buildkite pipeline (Buildkite GraphQL ID). -* `access_level` - (Required) The level of access to grant. Must be one of `READ_ONLY`, `BUILD_AND_READ` or `MANAGE_BUILD_AND_READ`. +### Required -## Attribute Reference +- `access_level` (String) The access level for the team. Either `READ_ONLY`, `BUILD_AND_READ` or `MANAGE_BUILD_AND_READ`. +- `pipeline_id` (String) The GraphQL ID of the pipeline. +- `team_id` (String) The GraphQL ID of the team. -* `id` - The GraphQL ID of the pipeline schedule -* `uuid` - The UUID of the pipeline schedule +### Read-Only -## Import +- `id` (String) The GraphQL ID of the pipeline-team relationship. +- `uuid` (String) The UUID of the pipeline-team relationship. -Pipeline teams can be imported using their `GraphQL ID`, e.g. +## Import -``` -$ terraform import buildkite_pipeline_team.guests VGVhbS0tLWU1YjQyMDQyLTUzN2QtNDZjNi04MjY0LTliZjFkMzkyYjZkNQ== -``` +Import is supported using the following syntax: -Your pipeline team's GraphQL ID can be found with the below GraphQL query below. -```graphql -query getPipelineTeamId { - pipeline(slug: "ORGANIZATION_SLUG/PIPELINE_SLUG") { - teams(first: 5, search: "PIPELINE_SEARCH_TERM") { - edges{ - node{ - id - } - } - } - } -} +```shell +# import a pipeline team resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getPipelineTeamId { +# pipeline(slug: "ORGANIZATION_SLUG/PIPELINE_SLUG") { +# teams(first: 5, search: "PIPELINE_SEARCH_TERM") { +# edges{ +# node{ +# id +# } +# } +# } +# } +# } +terraform import buildkite_pipeline_team.guests VGVhbS0tLWU1YjQyMDQyLTUzN2QtNDZjNi04MjY0LTliZjFkMzkyYjZkNQ== ``` diff --git a/docs/resources/team.md b/docs/resources/team.md index c1072c15..2869aa83 100644 --- a/docs/resources/team.md +++ b/docs/resources/team.md @@ -1,60 +1,66 @@ -# Resource: team +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_team Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + A Cluster is a group of Agents that can be used to run your builds. Clusters are useful for grouping Agents by their capabilities, such as operating system, hardware, or location. +--- -This resource allows you to create and manage teams. +# buildkite_team (Resource) -Buildkite Documentation: https://buildkite.com/docs/pipelines/permissions - -Note: You must first enable Teams on your organization. +A Cluster is a group of Agents that can be used to run your builds. Clusters are useful for grouping Agents by their capabilities, such as operating system, hardware, or location. ## Example Usage -```hcl -resource "buildkite_team" "team" { - name = "developers" - - privacy = "VISIBLE" - - default_team = true +```terraform +resource "buildkite_team" "everyone" { + name = "Everyone" + privacy = "VISIBLE" + default_team = false default_member_role = "MEMBER" } ``` -## Argument Reference + +## Schema -* `name` - (Required) The name of the team. -* `privacy` - (Required) The privacy level to set the team too. -* `default_team` - (Required) Whether to assign this team to a user by default. -* `default_member_role` - (Required) Default role to assign to a team member. -* `members_can_create_pipelines` - (Optional) Whether team members can create. -* `description` - (Optional) The description to assign to the team. +### Required -## Attribute Reference +- `default_member_role` (String) The default role for new members of the team. This can be either `MEMBER` or `MAINTAINER`. +- `default_team` (Boolean) Whether this is the default team for the organization. +- `name` (String) The name of the team. +- `privacy` (String) The privacy setting for the team. This can be either `VISIBLE` or `SECRET`. -* `id` - The GraphQL ID of the team. -* `slug` - The name of the team. -* `uuid` - The UUID for the team. +### Optional -## Import +- `description` (String) A description for the team. This is displayed in the Buildkite UI. +- `members_can_create_pipelines` (Boolean) Whether members of the team can create Pipelines. -Teams can be imported using the `GraphQL ID` (not UUID), e.g. +### Read-Only -``` -$ terraform import buildkite_team.fleet UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ= -``` +- `id` (String) The GraphQL ID of the team. +- `slug` (String) The generated slug for the team. +- `uuid` (String) The UUID of the team. -To find the ID to use, you can use the GraphQL query below. Alternatively, you could use this [pre-saved query](https://buildkite.com/user/graphql/console/6e74c89c-4e91-4d1d-92ca-4fb19d0ea453), where you will need fo fill in the organization slug and search term (TEAM_SEARCH_TERM) for the team. - -```graphql -query getTeamId { - organization(slug: "ORGANIZATION_SLUG") { - teams(first: 1, search: "TEAM_SEARCH_TERM") { - edges { - node { - id - name - } - } - } - } -} +## Import + +Import is supported using the following syntax: + +```shell +# import a team resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getTeamId { +# organization(slug: "ORGANIZATION_SLUG") { +# teams(first: 1, search: "TEAM_SEARCH_TERM") { +# edges { +# node { +# id +# name +# } +# } +# } +# } +# } +terraform import buildkite_team.everyone UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ= ``` diff --git a/docs/resources/team_member.md b/docs/resources/team_member.md index 9dc324b8..643e16d3 100644 --- a/docs/resources/team_member.md +++ b/docs/resources/team_member.md @@ -1,69 +1,70 @@ -# Resource: team_member +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_team_member Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + A team member resource allows for the management of team membership for existing organization users. +--- -This resource allows manage team membership for existing organization users. +# buildkite_team_member (Resource) -The user must already be part of the organization to which you are managing team membership. This will not invite a new user to the organization. - -Buildkite Documentation: https://buildkite.com/docs/pipelines/permissions - -Note: You must first enable Teams on your organization. +A team member resource allows for the management of team membership for existing organization users. ## Example Usage -```hcl -resource "buildkite_team" "team" { - name = "developers" - - privacy = "VISIBLE" - - default_team = true +```terraform +resource "buildkite_team" "everyone" { + name = "Everyone" + privacy = "VISIBLE" + default_team = false default_member_role = "MEMBER" } resource "buildkite_team_member" "a_smith" { + team_id = buildkite_team.everyone.id + user_id = "VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg==" role = "MEMBER" - team_id = buildkite_team.team.id - user_id = "VXNlci0tLWRlOTdmMjBiLWJkZmMtNGNjOC1hOTcwLTY1ODNiZTk2ZGEyYQ==" } ``` -## Argument Reference - -* `role` - (Required) Either MEMBER or MAINTAINER. -* `team_id` - (Required) The GraphQL ID of the team to add to/remove from. -* `user_id` - (Required) The GraphQL ID of the user to add/remove. + +## Schema -## Attribute Reference +### Required -* `id` - The GraphQL ID of the team membership. -* `uuid` - The UUID for the team membership. +- `role` (String) The role for the user. Either `MEMBER` or `MAINTAINER`. +- `team_id` (String) The GraphQL ID of the team. +- `user_id` (String) The GraphQL ID of the user. -## Import +### Read-Only -Team members can be imported using the GraphQL ID of the membership. Note this is different to the ID of the user. +- `id` (String) The GraphQL ID of the team membership. +- `uuid` (String) The UUID of the team membership. -``` -$ terraform import buildkite_team_member.a_smith VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg== -``` - -To find the ID to use, you can use the GraphQL query below. Alternatively, you could use this [pre-saved query](https://buildkite.com/user/graphql/console/ce4540dd-4f60-4e79-8e8f-9f4c3bc8784e), where you will need fo fill in the organization slug and search terms for teams and members. Both search terms (TEAM_SEARCH_TERM and TEAM_MEMBER_SEARCH_TERM) work on the name of the associated object. +## Import -```graphql -query getTeamMemberId { - organization(slug: "ORGANIZATION_SLUG") { - teams(first: 2, search: "TEAM_SEARCH_TERM") { - edges { - node { - members(first: 2, search: "TEAM_MEMBER_SEARCH_TERM") { - edges { - node { - id - } - } - } - } - } - } - } -} +Import is supported using the following syntax: + +```shell +# import a team member resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getTeamMemberId { +# organization(slug: "ORGANIZATION_SLUG") { +# teams(first: 2, search: "TEAM_SEARCH_TERM") { +# edges { +# node { +# members(first: 2, search: "TEAM_MEMBER_SEARCH_TERM") { +# edges { +# node { +# id +# } +# } +# } +# } +# } +# } +# } +# } +terraform import buildkite_team_member.a_smith VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg== ``` diff --git a/docs/resources/test_suite.md b/docs/resources/test_suite.md index 2f63aa8e..42d6ae16 100644 --- a/docs/resources/test_suite.md +++ b/docs/resources/test_suite.md @@ -1,38 +1,38 @@ -# Resource: test_suite +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_test_suite Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + A test suite is a collection of tests. A run is to a suite what a build is to a Pipeline.Use this resource to manage Test Suites https://buildkite.com/docs/test-analytics on Buildkite. +--- -This resources allows you to create and manage a Test Suite. +# buildkite_test_suite (Resource) -Buildkite documentation: https://buildkite.com/docs/test-analytics +A test suite is a collection of tests. A run is to a suite what a build is to a Pipeline.Use this resource to manage [Test Suites](https://buildkite.com/docs/test-analytics) on Buildkite. ## Example Usage -```hcl -provider "buildkite" {} - -resource "buildkite_team" "test" { - name = "Manage unit tests" - - privacy = "VISIBLE" - default_team = false - default_member_role = "MEMBER" -} - -resource "buildkite_test_suite" "unit_tests" { - name = "Unit tests" +```terraform +# create a test suite for the main repository +resource "buildkite_test_suite" "main" { + name = "main" default_branch = "main" - team_owner_id = buildkite_team.test.id + team_owner_id = "VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi" } ``` -## Argument Reference + +## Schema + +### Required -* `name` - (Required) This is the name of the test suite. -* `default_branch` - (Required) This is the default branch used to compare tests against. -* `team_owner_id` - (Required) This is a single team linked to the test suite upon creation. +- `default_branch` (String) The default branch for the repository this test suite is for. +- `name` (String) The name to give the test suite. +- `team_owner_id` (String) The GraphQL ID of the team to mark as the owner/admin of the test suite. -## Attribute Reference +### Read-Only -* `api_token` - This is the unique API token used when send test results. -* `id` - This is the GraphQL ID of the suite. -* `uuid` - This is the UUID of the suite. -* `slug` - This is the unique slug generated from the name upon creation. +- `api_token` (String, Sensitive) The API token to use to send test run data to the API. +- `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. diff --git a/docs/resources/test_suite_team.md b/docs/resources/test_suite_team.md index c427c734..528c2f63 100644 --- a/docs/resources/test_suite_team.md +++ b/docs/resources/test_suite_team.md @@ -1,84 +1,77 @@ -# Resource: test_suite_team +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "buildkite_test_suite_team Resource - terraform-provider-buildkite" +subcategory: "" +description: |- + Manage team access to a test suite. +--- -This resources allows you to create, manage and import team access to Test Suites. +# buildkite_test_suite_team (Resource) -Buildkite documentation: https://buildkite.com/docs/test-analytics +Manage team access to a test suite. ## Example Usage -```hcl -provider "buildkite" {} - -resource "buildkite_team" "owners" { - name = "Owning team" - default_team = false - privacy = "VISIBLE" - default_member_role = "MAINTAINER" -} - -resource "buildkite_team" "viewers" { - name = "Viewers team" - default_team = false - privacy = "VISIBLE" - default_member_role = "MAINTAINER" +```terraform +# create a test suite +resource "buildkite_test_suite" "main" { + name = "main" + default_branch = "main" + team_owner_id = "VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg==" } -resource "buildkite_test_suite" "rspec_suite" { - name = "RSpec Test Suite" - default_branch = "main" - team_owner_id = buildkite_team.owners.id -} - -resource "buildkite_test_suite_team" "viewers_rspec" { - test_suite_id = buildkite_test_suite.rspec_suite.id - team_id = buildkite_team.viewers.id - access_level = "READ_ONLY" +# give the "everyone" team manage access to the "main" test suite +resource "buildkite_test_suite_team" "main_everyone" { + test_suite_id = buildkite_test_suite.main.id + team_id = "VGVhbS0tLWU1YjQyMDQyLTUzN2QtNDZjNi04MjY0LTliZjFkMzkyYjZkNQ==" + access_level = "MANAGE_AND_READ" } ``` -## Argument Reference - -* `test_suite_id` - (Required) The GraphQL ID of the test suite. -* `team_id` - (Required) The GraphQL ID of the team. -* `access_level` - (Required) The access level the team has on the test suite. Either READ_ONLY or MANAGE_AND_READ. + +## Schema -## Attribute Reference +### Required -* `id` - This is the GraphQL ID of the test suite team. -* `uuid` - This is the UUID of the test suite team. +- `access_level` (String) The access level the team has on the test suite. Either `READ_ONLY` or `MANAGE_AND_READ`. +- `team_id` (String) The GraphQL ID of the team. +- `test_suite_id` (String) The GraphQL ID of the test suite. -## Import - -Test suite teams can be imported using the `GraphQL ID` (not UUID), e.g. +### Read-Only -``` -$ terraform import buildkite_test_suite_team.viewers VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi -``` +- `id` (String) The GraphQL ID of the test suite-team relationship. +- `uuid` (String) The UUID of the test suite-team relationship. -To find the ID to use, you can use the GraphQL query below. Alternatively, you could use this [pre-saved query](https://buildkite.com/user/graphql/console/e8480014-37a8-4150-a011-6d35f33b4dfd), where you will need fo fill in the organization slug and suite search term (SUITE_SEARCH_TERM) for the particular test suite required. +## Import -```graphql -query getTeamSuiteIds { - organization(slug: "ORGANIZATION_SLUG") { - suites(first: 1, search:"SUITE_SEARCH_TERM") { - edges { - node { - id - name - teams(first: 10){ - edges { - node { - id - accessLevel - team{ - name - } - } - } - } - } - } - } - } -} +Import is supported using the following syntax: + +```shell +# import a test suite team resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getTeamSuiteIds { +# organization(slug: "ORGANIZATION_SLUG") { +# suites(first: 1, search:"SUITE_SEARCH_TERM") { +# edges { +# node { +# id +# name +# teams(first: 10){ +# edges { +# node { +# id +# accessLevel +# team{ +# name +# } +# } +# } +# } +# } +# } +# } +# } +# } +terraform import buildkite_test_suite_team.main_everyone VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi ``` diff --git a/examples/data-sources/buildkite_cluster/data-source.tf b/examples/data-sources/buildkite_cluster/data-source.tf new file mode 100644 index 00000000..cedd8d40 --- /dev/null +++ b/examples/data-sources/buildkite_cluster/data-source.tf @@ -0,0 +1,11 @@ +# Find the "default" cluster +data "buildkite_cluster" "default" { + name = "default" +} + +# Assign a pipeline to that cluster +resource "buildkite_pipeline" "terraform-provider-buildkite" { + name = "terraform-provider-buildkite" + repository = "git@github.com:buildkite/terraform-provider-buildkite.git" + cluster_id = data.buildkite_cluster.default.id +} diff --git a/examples/data-sources/buildkite_meta/data-source.tf b/examples/data-sources/buildkite_meta/data-source.tf new file mode 100644 index 00000000..5bf33102 --- /dev/null +++ b/examples/data-sources/buildkite_meta/data-source.tf @@ -0,0 +1,13 @@ +data "buildkite_meta" "ips" {} + +# Create an AWS security group allowing ingress from Buildkite +resource "aws_security_group" "from_buildkite" { + name = "from_buildkite" + + ingress { + from_port = "*" + to_port = "443" + protocol = "tcp" + cidr_blocks = data.buildkite_meta.ips.webhook_ips + } +} diff --git a/examples/data-sources/buildkite_pipeline/data-source.tf b/examples/data-sources/buildkite_pipeline/data-source.tf new file mode 100644 index 00000000..1e3eb978 --- /dev/null +++ b/examples/data-sources/buildkite_pipeline/data-source.tf @@ -0,0 +1,3 @@ +data "buildkite_pipeline" "pipeline" { + slug = "buildkite" +} diff --git a/examples/data-sources/buildkite_team/data-source.tf b/examples/data-sources/buildkite_team/data-source.tf new file mode 100644 index 00000000..3428e149 --- /dev/null +++ b/examples/data-sources/buildkite_team/data-source.tf @@ -0,0 +1,3 @@ +data "buildkite_team" "team" { + id = "Everyone" +} diff --git a/examples/main.tf b/examples/main.tf deleted file mode 100644 index c6bb2451..00000000 --- a/examples/main.tf +++ /dev/null @@ -1,106 +0,0 @@ -provider "buildkite" { - timeouts { - create = "10s" - update = "15s" - } -} - -resource "buildkite_team" "test" { - name = "terraform_provider_test" - - privacy = "VISIBLE" - default_team = false - default_member_role = "MEMBER" -} - -resource "buildkite_team" "testtwo" { - name = "terraform_provider_test_two" - - privacy = "VISIBLE" - default_team = false - default_member_role = "MEMBER" -} - -resource "buildkite_team_member" "member1" { - role = "MEMBER" - team_id = "VXfhnVUS78HavgtP55WhWGzT401guK38Vm9LMMeCgQD124m8xaKBRq0Fth==" - user_id = "VXNbwSA9hwVPpMgUXu1dWIDWf45ZwU6J7deETygiLUrKBg2TZBxuDr6aKj==" -} - - -resource "buildkite_pipeline" "repo2" { - name = "terraform_provider_buildkite_pipeline" - repository = "git@github.com:org/repo2" - steps = file("./steps.yml") - - lifecycle { - prevent_destroy = true - } - - provider_settings { - trigger_mode = "code" - build_pull_requests = true - build_pull_request_ready_for_review = true - } -} - -resource "buildkite_pipeline_schedule" "weekly" { - pipeline_id = buildkite_pipeline.repo2 - label = "Weekly build from default branch" - cronline = "@midnight" - branch = "default" - message = "Weekly scheduled build" -} - -resource "buildkite_pipeline_team" "developers" { - pipeline_id = buildkite_pipeline.repo2 - team_id = buildkite_team.test.id - access_level = "MANAGE_BUILD_AND_READ" -} - -data "buildkite_pipeline" "data2" { - slug = buildkite_pipeline.repo2.slug -} - -resource "buildkite_agent_token" "fleet" { - description = "token used by build fleet" -} - -resource "buildkite_cluster" "my_awesome_cluster" { - name = "best cluster ever" - description = "This cluster can do it all 😍" - color = "#BADA55" - emoji = ":muscle:" -} - -resource "buildkite_cluster_queue" "queue1" { - cluster_id = "Q2x1c3Rlci0tLTMzMDc0ZDhiLTM4MjctNDRkNC05YTQ3LTkwN2E2NWZjODViNg==" - key = "dev" - description = "Dev cluster queue" -} - -resource "buildkite_cluster_agent_token" "token1" { - cluster_id = "Q2x1c3Rlci0tLTMzMDc0ZDhiLTM4MjctNDRkNC05YTQ3LTkwN2E2NWZjODViNg==" - description = "agent token for Dev cluster" -} - -resource "buildkite_test_suite" "unit_tests" { - name = "Unit tests" - default_branch = "main" - team_owner_id = buildkite_team.test.id -} - -resource "buildkite_test_suite_team" "suite_read_only" { - test_suite_id = buildkite_test_suite.unit_tests.id - team_id = buildkite_team.testtwo.id - access_level = "READ_ONLY" -} - -output "agent_token" { - value = buildkite_agent_token.fleet.token -} - -output "badge_url" { - value = buildkite_pipeline.test.badge_url -} - diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf new file mode 100644 index 00000000..1a3d7dc5 --- /dev/null +++ b/examples/provider/provider.tf @@ -0,0 +1,20 @@ +terraform { + required_providers { + buildkite = { + source = "buildkite/buildkite" + version = "~> 1.0" + } + } +} + +# Configure the Buildkite Provider +provider "buildkite" { + organization = "buildkite" + # Use the `BUILDKITE_API_TOKEN` environment variable so the token is not committed + # api_token = "" +} + +# Add a pipeline +resource "buildkite_pipeline" "pipeline" { + # ... +} diff --git a/examples/resources/buildkite_agent_token/resource.tf b/examples/resources/buildkite_agent_token/resource.tf new file mode 100644 index 00000000..5b41d3f3 --- /dev/null +++ b/examples/resources/buildkite_agent_token/resource.tf @@ -0,0 +1,4 @@ +# create a default token +resource "buildkite_agent_token" "default" { + description = "Default token" +} diff --git a/examples/resources/buildkite_cluster/import.sh b/examples/resources/buildkite_cluster/import.sh new file mode 100644 index 00000000..c604afae --- /dev/null +++ b/examples/resources/buildkite_cluster/import.sh @@ -0,0 +1,16 @@ +# import a cluster resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getClusters { +# organization(slug: "ORGANIZATION"){ +# clusters(first: 5, order:NAME) { +# edges{ +# node { +# id +# name +# } +# } +# } +# } +# } +terraform import buildkite_cluster.primary Q2x1c3Rlci0tLTI3ZmFmZjA4LTA3OWEtNDk5ZC1hMmIwLTIzNmY3NWFkMWZjYg== diff --git a/examples/resources/buildkite_cluster/resource.tf b/examples/resources/buildkite_cluster/resource.tf new file mode 100644 index 00000000..fde30725 --- /dev/null +++ b/examples/resources/buildkite_cluster/resource.tf @@ -0,0 +1,19 @@ +# create a cluster +resource "buildkite_cluster" "primary" { + name = "Primary cluster" + description = "Runs the monolith build and deploy" + emoji = "🚀" + color = "#bada55" +} + +# add a pipeline to the cluster +resource "buildkite_pipeline" "monolith" { + name = "Monolith" + repository = "https://github.com/..." + cluster_id = buildkite_cluster.primary.id +} + +resource "buildkite_cluster_queue" "default" { + cluster_id = buildkite_cluster.primary.id + key = "default" +} diff --git a/examples/resources/buildkite_cluster_agent_token/resource.tf b/examples/resources/buildkite_cluster_agent_token/resource.tf new file mode 100644 index 00000000..62e6eeee --- /dev/null +++ b/examples/resources/buildkite_cluster_agent_token/resource.tf @@ -0,0 +1,24 @@ +# create a cluster +resource "buildkite_cluster" "primary" { + name = "Primary cluster" + description = "Runs the monolith build and deploy" + emoji = "🚀" + color = "#bada55" +} + +# create an agent token for the cluster +resource "buildkite_cluster_agent_token" "default" { + description = "Default cluster token" + cluster_id = buildkite_cluster.primary.id +} + +resource "buildkite_pipeline" "monolith" { + name = "Monolith" + repository = "https://github.com/..." + cluster_id = buildkite_cluster.primary.id +} + +resource "buildkite_cluster_queue" "default" { + cluster_id = buildkite_cluster.primary.id + key = "default" +} diff --git a/examples/resources/buildkite_cluster_queue/import.sh b/examples/resources/buildkite_cluster_queue/import.sh new file mode 100644 index 00000000..8b8e1d39 --- /dev/null +++ b/examples/resources/buildkite_cluster_queue/import.sh @@ -0,0 +1,18 @@ +# import a cluster queue resource using the GraphQL ID along with its respective cluster UUID +# +# you can use this query to find the ID: +# query getClusterQueues { +# organization(slug: "ORGANIZATION_SLUG") { +# cluster(id: "CLUSTER_UUID") { +# queues(first: 50) { +# edges { +# node { +# id +# key +# } +# } +# } +# } +# } +# } +terraform import buildkite_cluster_queue.test Q2x1c3RlclF1ZXVlLS0tYjJiOGRhNTEtOWY5My00Y2MyLTkyMjktMGRiNzg3ZDQzOTAz,35498aaf-ad05-4fa5-9a07-91bf6cacd2bd diff --git a/examples/resources/buildkite_cluster_queue/resource.tf b/examples/resources/buildkite_cluster_queue/resource.tf new file mode 100644 index 00000000..d025235d --- /dev/null +++ b/examples/resources/buildkite_cluster_queue/resource.tf @@ -0,0 +1,19 @@ +# create a cluster +resource "buildkite_cluster" "primary" { + name = "Primary cluster" + description = "Runs the monolith build and deploy" + emoji = "🚀" + color = "#bada55" +} + +resource "buildkite_pipeline" "monolith" { + name = "Monolith" + repository = "https://github.com/..." + cluster_id = buildkite_cluster.primary.id +} + +# create a queue to put pipeline builds in +resource "buildkite_cluster_queue" "default" { + cluster_id = buildkite_cluster.primary.id + key = "default" +} diff --git a/examples/resources/buildkite_organization/import.sh b/examples/resources/buildkite_organization/import.sh new file mode 100644 index 00000000..019a27e1 --- /dev/null +++ b/examples/resources/buildkite_organization/import.sh @@ -0,0 +1,2 @@ +# import the organization settings via the organization slug +terraform import buildkite_organization.settings diff --git a/examples/resources/buildkite_organization/resource.tf b/examples/resources/buildkite_organization/resource.tf new file mode 100644 index 00000000..6db9d76c --- /dev/null +++ b/examples/resources/buildkite_organization/resource.tf @@ -0,0 +1,4 @@ +# allow api access only from 1.1.1.1 +resource "buildkite_organization" "settings" { + allowed_api_ip_addresses = ["1.1.1.1/32"] +} diff --git a/examples/resources/buildkite_pipeline/import.sh b/examples/resources/buildkite_pipeline/import.sh new file mode 100644 index 00000000..040d1edb --- /dev/null +++ b/examples/resources/buildkite_pipeline/import.sh @@ -0,0 +1,3 @@ +# 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= diff --git a/examples/resources/buildkite_pipeline/resource.tf b/examples/resources/buildkite_pipeline/resource.tf new file mode 100644 index 00000000..ec05675d --- /dev/null +++ b/examples/resources/buildkite_pipeline/resource.tf @@ -0,0 +1,18 @@ +# minimal repository +resource "buildkite_pipeline" "pipeline" { + name = "repo" + repository = "git@github.com:org/repo" +} + +# with github provider settings +resource "buildkite_pipeline" "pipeline" { + name = "repo" + repository = "git@github.com:org/repo" + + provider_settings { + build_branches = false + build_tags = true + build_pull_requests = false + trigger_mode = "code" + } +} diff --git a/examples/resources/buildkite_pipeline_schedule/import.sh b/examples/resources/buildkite_pipeline_schedule/import.sh new file mode 100644 index 00000000..0f674273 --- /dev/null +++ b/examples/resources/buildkite_pipeline_schedule/import.sh @@ -0,0 +1,22 @@ +# import a pipeline schedule resource using the schedules GraphQL ID +# +# you can use this query to find the schedule: +# query getPipelineScheduleId { +# organization(slug: "ORGANIZATION_SLUG") { +# pipelines(first: 5, search: "PIPELINE_SEARCH_TERM") { +# edges{ +# node{ +# name +# schedules{ +# edges{ +# node{ +# id +# } +# } +# } +# } +# } +# } +# } +# } +terraform import buildkite_pipeline_schedule.test UGlwZWxpgm5Tf2hhZHVsZ35tLWRk4DdmN7c4LTA5M2ItNDM9YS0gMWE0LTAwZDUgYTAxYvRf49== diff --git a/examples/resources/buildkite_pipeline_schedule/resource.tf b/examples/resources/buildkite_pipeline_schedule/resource.tf new file mode 100644 index 00000000..de1be4f2 --- /dev/null +++ b/examples/resources/buildkite_pipeline_schedule/resource.tf @@ -0,0 +1,13 @@ +# create a pipeline +resource "buildkite_pipeline" "pipeline" { + name = "my pipeline" + repository = "https://github.com/..." +} + +# schedule a build at midnight every day +resource "buildkite_pipeline_schedule" "nightly" { + pipeline_id = buildkite_pipeline.repo.id + label = "Nightly build" + cronline = "@midnight" + branch = buildkite_pipeline.repo.default_branch +} diff --git a/examples/resources/buildkite_pipeline_team/import.sh b/examples/resources/buildkite_pipeline_team/import.sh new file mode 100644 index 00000000..eabf76dd --- /dev/null +++ b/examples/resources/buildkite_pipeline_team/import.sh @@ -0,0 +1,15 @@ +# import a pipeline team resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getPipelineTeamId { +# pipeline(slug: "ORGANIZATION_SLUG/PIPELINE_SLUG") { +# teams(first: 5, search: "PIPELINE_SEARCH_TERM") { +# edges{ +# node{ +# id +# } +# } +# } +# } +# } +terraform import buildkite_pipeline_team.guests VGVhbS0tLWU1YjQyMDQyLTUzN2QtNDZjNi04MjY0LTliZjFkMzkyYjZkNQ== diff --git a/examples/resources/buildkite_pipeline_team/resource.tf b/examples/resources/buildkite_pipeline_team/resource.tf new file mode 100644 index 00000000..a05e3989 --- /dev/null +++ b/examples/resources/buildkite_pipeline_team/resource.tf @@ -0,0 +1,18 @@ +resource "buildkite_pipeline" "pipeline" { + name = "my pipeline" + repository = "https://github.com/..." +} + +resource "buildkite_team" "team" { + name = "Everyone" + privacy = "VISIBLE" + default_team = false + default_member_role = "MEMBER" +} + +# allow everyone in the "Everyone" team read-only access to pipeline +resource "buildkite_pipeline_team" "pipeline_team" { + pipeline_id = buildkite_pipeline.pipeline.id + team_id = buildkite_team.team.id + access_level = "READ_ONLY" +} diff --git a/examples/resources/buildkite_team/import.sh b/examples/resources/buildkite_team/import.sh new file mode 100644 index 00000000..4cea1aae --- /dev/null +++ b/examples/resources/buildkite_team/import.sh @@ -0,0 +1,16 @@ +# import a team resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getTeamId { +# organization(slug: "ORGANIZATION_SLUG") { +# teams(first: 1, search: "TEAM_SEARCH_TERM") { +# edges { +# node { +# id +# name +# } +# } +# } +# } +# } +terraform import buildkite_team.everyone UGlwZWxpbmUtLS00MzVjYWQ1OC1lODFkLTQ1YWYtODYzNy1iMWNmODA3MDIzOGQ= diff --git a/examples/resources/buildkite_team/resource.tf b/examples/resources/buildkite_team/resource.tf new file mode 100644 index 00000000..573bd457 --- /dev/null +++ b/examples/resources/buildkite_team/resource.tf @@ -0,0 +1,6 @@ +resource "buildkite_team" "everyone" { + name = "Everyone" + privacy = "VISIBLE" + default_team = false + default_member_role = "MEMBER" +} diff --git a/examples/resources/buildkite_team_member/import.sh b/examples/resources/buildkite_team_member/import.sh new file mode 100644 index 00000000..0d1d1807 --- /dev/null +++ b/examples/resources/buildkite_team_member/import.sh @@ -0,0 +1,21 @@ +# import a team member resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getTeamMemberId { +# organization(slug: "ORGANIZATION_SLUG") { +# teams(first: 2, search: "TEAM_SEARCH_TERM") { +# edges { +# node { +# members(first: 2, search: "TEAM_MEMBER_SEARCH_TERM") { +# edges { +# node { +# id +# } +# } +# } +# } +# } +# } +# } +# } +terraform import buildkite_team_member.a_smith VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg== diff --git a/examples/resources/buildkite_team_member/resource.tf b/examples/resources/buildkite_team_member/resource.tf new file mode 100644 index 00000000..0b67e749 --- /dev/null +++ b/examples/resources/buildkite_team_member/resource.tf @@ -0,0 +1,12 @@ +resource "buildkite_team" "everyone" { + name = "Everyone" + privacy = "VISIBLE" + default_team = false + default_member_role = "MEMBER" +} + +resource "buildkite_team_member" "a_smith" { + team_id = buildkite_team.everyone.id + user_id = "VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg==" + role = "MEMBER" +} diff --git a/examples/resources/buildkite_test_suite/resource.tf b/examples/resources/buildkite_test_suite/resource.tf new file mode 100644 index 00000000..91059051 --- /dev/null +++ b/examples/resources/buildkite_test_suite/resource.tf @@ -0,0 +1,6 @@ +# create a test suite for the main repository +resource "buildkite_test_suite" "main" { + name = "main" + default_branch = "main" + team_owner_id = "VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi" +} diff --git a/examples/resources/buildkite_test_suite_team/import.sh b/examples/resources/buildkite_test_suite_team/import.sh new file mode 100644 index 00000000..6fa1fa6a --- /dev/null +++ b/examples/resources/buildkite_test_suite_team/import.sh @@ -0,0 +1,27 @@ +# import a test suite team resource using the GraphQL ID +# +# you can use this query to find the ID: +# query getTeamSuiteIds { +# organization(slug: "ORGANIZATION_SLUG") { +# suites(first: 1, search:"SUITE_SEARCH_TERM") { +# edges { +# node { +# id +# name +# teams(first: 10){ +# edges { +# node { +# id +# accessLevel +# team{ +# name +# } +# } +# } +# } +# } +# } +# } +# } +# } +terraform import buildkite_test_suite_team.main_everyone VGVhbvDf4eRef20tMzIxMGEfYTctNzEF5g00M8f5s6E2YjYtODNlOGNlZgD6HcBi diff --git a/examples/resources/buildkite_test_suite_team/resource.tf b/examples/resources/buildkite_test_suite_team/resource.tf new file mode 100644 index 00000000..5fd6a3bf --- /dev/null +++ b/examples/resources/buildkite_test_suite_team/resource.tf @@ -0,0 +1,13 @@ +# create a test suite +resource "buildkite_test_suite" "main" { + name = "main" + default_branch = "main" + team_owner_id = "VGVhbU1lbWJlci0tLTVlZDEyMmY2LTM2NjQtNDI1MS04YzMwLTc4NjRiMDdiZDQ4Zg==" +} + +# give the "everyone" team manage access to the "main" test suite +resource "buildkite_test_suite_team" "main_everyone" { + test_suite_id = buildkite_test_suite.main.id + team_id = "VGVhbS0tLWU1YjQyMDQyLTUzN2QtNDZjNi04MjY0LTliZjFkMzkyYjZkNQ==" + access_level = "MANAGE_AND_READ" +} diff --git a/examples/steps.yml b/examples/steps.yml deleted file mode 100644 index 41727d87..00000000 --- a/examples/steps.yml +++ /dev/null @@ -1,3 +0,0 @@ -steps: - - label: ':pipeline:' - command: buildkite-agent pipeline upload diff --git a/go.mod b/go.mod index 0463afcb..f679d790 100644 --- a/go.mod +++ b/go.mod @@ -14,25 +14,40 @@ require ( ) require ( + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.1.1 // indirect + github.com/Masterminds/sprig/v3 v3.2.2 // indirect github.com/agnivade/levenshtein v1.1.1 // indirect github.com/alexflint/go-arg v1.4.2 // indirect github.com/alexflint/go-scalar v1.0.0 // indirect + github.com/armon/go-radix v1.0.0 // indirect + github.com/bgentry/speakeasy v0.1.0 // indirect + github.com/cli/safeexec v1.0.0 // indirect github.com/dnephin/pflag v1.0.7 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/hashicorp/terraform-plugin-docs v0.16.0 // indirect + github.com/huandu/xstrings v1.3.2 // indirect + github.com/imdario/mergo v0.3.13 // indirect + github.com/mitchellh/cli v1.1.5 // indirect + github.com/posener/complete v1.2.3 // indirect + github.com/russross/blackfriday v1.6.0 // indirect + github.com/shopspring/decimal v1.3.1 // indirect + github.com/spf13/cast v1.5.0 // indirect github.com/suessflorian/gqlfetch v0.6.0 // indirect github.com/vektah/gqlparser v1.3.1 // indirect + golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect golang.org/x/sync v0.1.0 // indirect golang.org/x/term v0.11.0 // indirect golang.org/x/tools v0.8.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gotest.tools/gotestsum v1.10.1 // indirect - github.com/cli/safeexec v1.0.0 // indirect - golang.org/x/exp v0.0.0-20230809150735-7b3493d9a819 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + gotest.tools/gotestsum v1.10.1 // indirect ) require ( + github.com/MakeNowJust/heredoc v1.0.0 github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect github.com/agext/levenshtein v1.2.2 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect @@ -40,7 +55,7 @@ require ( github.com/fatih/color v1.13.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 - github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-checkpoint v0.5.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect diff --git a/go.sum b/go.sum index 0c2d1005..b1138046 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,14 @@ github.com/Khan/genqlient v0.6.0 h1:Bwb1170ekuNIVIwTJEqvO8y7RxBxXu639VJOkKSrwAk= github.com/Khan/genqlient v0.6.0/go.mod h1:rvChwWVTqXhiapdhLDV4bp9tz/Xvtewwkon4DpWWCRM= +github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ= +github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE= +github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/Masterminds/sprig/v3 v3.2.1/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= +github.com/Masterminds/sprig/v3 v3.2.2 h1:17jRggJu518dr3QaafizSXOjKYp94wKfABxUmyxvxX8= +github.com/Masterminds/sprig/v3 v3.2.2/go.mod h1:UoaO7Yp8KlPnJIYWTFkMaqPUYKTfGFPhxNuwnnxkKlk= github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA= github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g= @@ -19,6 +28,11 @@ github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJE github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/cli/go-gh v1.2.1 h1:xFrjejSsgPiwXFP6VYynKWwxLQcNJy3Twbu82ZDlR/o= github.com/cli/go-gh v1.2.1/go.mod h1:Jxk8X+TCO4Ui/GarwY9tByWm/8zp4jJktzVZNlTW5VM= @@ -33,10 +47,12 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= +github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.4.1 h1:Uwp5tDRkPr+l/TnbHOQzp+tmJfLceOlbVucgpTz8ix4= github.com/go-git/go-git/v5 v5.6.1 h1:q4ZRqQl4pR/ZJHc1L5CFjGA1a10u76aV1iC+nh+bHsk= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= @@ -51,8 +67,14 @@ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -62,6 +84,7 @@ github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUK github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.4.10 h1:xUbmA4jC6Dq163/fWcp8P3JuHilrHHMLNRxzGQJ9hNk= @@ -81,6 +104,8 @@ github.com/hashicorp/terraform-exec v0.18.1 h1:LAbfDvNQU1l0NOQlTuudjczVhHj061fNX github.com/hashicorp/terraform-exec v0.18.1/go.mod h1:58wg4IeuAJ6LVsLUeD2DWZZoc/bYi6dzhLHzxM41980= github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA= github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o= +github.com/hashicorp/terraform-plugin-docs v0.16.0 h1:UmxFr3AScl6Wged84jndJIfFccGyBZn52KtMNsS12dI= +github.com/hashicorp/terraform-plugin-docs v0.16.0/go.mod h1:M3ZrlKBJAbPMtNOPwHicGi1c+hZUh7/g0ifT/z7TVfA= github.com/hashicorp/terraform-plugin-framework v1.3.5 h1:FJ6s3CVWVAxlhiF/jhy6hzs4AnPHiflsp9KgzTGl1wo= github.com/hashicorp/terraform-plugin-framework v1.3.5/go.mod h1:2gGDpWiTI0irr9NSTLFAKlTi6KwGti3AoU19rFqU30o= github.com/hashicorp/terraform-plugin-framework-timeouts v0.4.1 h1:gm5b1kHgFFhaKFhm4h2TgvMUlNzFAtUqlcOWnWPm+9E= @@ -101,8 +126,14 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= +github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= +github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= +github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -110,24 +141,32 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mitchellh/cli v1.1.5 h1:OxRIeJXpAMztws/XHlN2vu6imG5Dpq+j61AzAX5fLng= +github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= @@ -135,17 +174,30 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= +github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= +github.com/sebdah/goldie v1.0.0/go.mod h1:jXP4hmWywNEwZzhMuv2ccnqTSFpuq8iyQhtQdkkZBH4= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f h1:tygelZueB1EtXkPI6mQ4o9DQ0+FKW41hTbunoXZCTqk= github.com/shurcooL/graphql v0.0.0-20181231061246-d48a9a75455f/go.mod h1:AuYgA5Kyo4c7HfUmvRGs/6rGlMMV/6B1bVnB9JxJEEg= github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= @@ -167,9 +219,12 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zclconf/go-cty v1.13.3 h1:m+b9q3YDbg6Bec5rr+KGy1MzEVzY/jC2X+YX4yqKtHI= github.com/zclconf/go-cty v1.13.3/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= @@ -251,12 +306,15 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/gotestsum v1.10.1/go.mod h1:6JHCiN6TEjA7Kaz23q1bH0e2Dc3YJjDUZ0DmctFZf+w= diff --git a/templates/guides/elastic-ci-stack.md b/templates/guides/elastic-ci-stack.md new file mode 100644 index 00000000..9812706f --- /dev/null +++ b/templates/guides/elastic-ci-stack.md @@ -0,0 +1,35 @@ +--- +page_title: Usage with Elastic CI Stack for AWS +--- + +# Usage with the Elastic CI Stack for AWS + +There is not an official Terraform module for deploying Buildkite agents to AWS. However, there is a CloudFormation +stack available: https://github.com/buildkite/elastic-ci-stack-for-aws. + +If you want to manage all your infrastructure through Terraform, you can utilize the +[`aws`](https://registry.terraform.io/providers/hashicorp/aws/latest) provider to create a CloudFormation stack using +our template. An example is given below: + +For more information on the Elastic CI Stack for AWS, visit https://buildkite.com/docs/agent/v3/elastic-ci-aws/elastic-ci-stack-overview. + +```tf +resource "buildkite_agent_token" "elastic_stack" { + description = "Elastic stack" +} + +resource "aws_cloudformation_stack" "buildkite_agent_default" { + name = "buildkite-agent-default" + template_url = "https://s3.amazonaws.com/buildkite-aws-stack/master/aws-stack.yml" + capabilities = ["CAPABILITY_NAMED_IAM"] + parameters = { + AgentsPerInstance = 5 + AssociatePublicIpAddress = true + InstanceType = "i3.2xlarge" + MaxSize = 10 + MinSize = 0 + RootVolumeSize = 50 + BuildkiteAgentToken = buildkite_agent_token.elastic_stack.token + } +} +``` diff --git a/templates/guides/upgrade-v1.md b/templates/guides/upgrade-v1.md new file mode 100644 index 00000000..616e813d --- /dev/null +++ b/templates/guides/upgrade-v1.md @@ -0,0 +1,152 @@ +--- +page_title: Upgrading to v1.0 +--- + +# Upgrading to v1.0 + +The Buildkite Terraform provider 1.0 is considered stable and ready for production use. If you have been using the +provider prior to the 1.0 release, this guides you through upgrading. + +## New Features + +### Protocol version 6 +The provider has been upgraded to protocol v6. It is therefor only compatible with terraform CLI version 1.0 and later. + +### Cluster resources +You are now able to manage cluster resources with the provider. This includes `cluster`, `cluster_queue`, and +`cluster_agent_token`. + +### Test Analytics resources +You can now create test suites and assign teams access to them with `test_suite`, and `test_suite_team`. + +### Configurable API retry timeouts +API retries and timeouts have been implemented in the majority of resources. This adds reliability to the provider +around API latency and outages. + +By default, retries are set to 30 seconds. You can override this by operation type on the provider settings: + +```tf +provider "buildkite" { + organization = "buildkite" + timeouts = { + create = "90s" + delete = "10s" + } +} +``` + +### Archive pipeline on delete +Pipeline resources can now be archived instead of deleted when the resource is destroyed. This might be useful for users +who wish to keep the history around but disable the pipeline. This is configurable at the provider level: + +```tf +provider "buildkite" { + organization = "buildkite" + archive_pipeline_on_delete = true +} +``` + +## Changed Features + +### Pipeline resource `provider_settings` type change +The `provider_settings` attribute on the pipeline resource has been completely overhauled. It is now a nested attribute +(thanks to protocol v6) and has validation on inner attributes. + +Previously: + +```tf +resource "buildkite_pipeline" "pipeline" { + name = "deploy" + repository = "https://github.com/company/project.git" + provider_settings { + trigger_mode = "deployment" + } +} +``` + +Now, `provider_settings` is a nested attribute: + +```tf +resource "buildkite_pipeline" "pipeline" { + name = "deploy" + repository = "https://github.com/company/project.git" + provider_settings = { + trigger_mode = "deployment" + } +} +``` + +### Consistent IDs across resources +All resources now use their GraphQL IDs as the primary ID in the schema. + +## Removed Features + +- `team` attribute on pipeline resource has been removed. + +## Upgrade Guide + +### Pin provider version + +You should pin your provider installation to the 1.x releases. + +```tf +terraform { + required_providers { + buildkite = { + source = "buildkite/buildkite" + version = "~> 1.0" + } + } +} +``` + +### Migrate `pipeline.team` usage to `pipeline_team` resource + +The `team` attribute on the `pipeline` resource was removed in v1.0 in favour of a separate resource: +[`pipeline_team`](../resources/pipeline_team). + +You'll need to upgrade your provider to version `0.27.0` and switch over to the new resource prior to upgrading to v1.0. + +Before this change: + +```tf +resource "buildkite_team" "deploy" { + name = "deploy" + privacy = "VISIBLE" + default_team = true + default_member_role = "MEMBER" +} + +# only allow the deploy team to build the deploy pipeline +resource "buildkite_pipeline" "pipeline" { + name = "deploy" + repository = "https://github.com/company/project.git" + team { + slug = "deploy" + access_level = "BUILD_AND_READ" + } +} +``` + +After this change: + +```tf +resource "buildkite_team" "deploy" { + name = "deploy" + privacy = "VISIBLE" + default_team = true + default_member_role = "MEMBER" +} + +resource "buildkite_pipeline" "pipeline" { + name = "deploy" + repository = "https://github.com/company/project.git" +} + +# only allow the deploy team to build the deploy pipeline +resource "buildkite_pipeline_team" "deploy_pipeline" { + pipeline_id = buildkite_pipeline.pipeline.id + team_id = buildkite_team.deploy.id + access_level = "BUILD_AND_READ" +} +```