Skip to content

Commit

Permalink
Use tfplugins templates to enhance the documents for the providers
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsbhat committed Feb 23, 2023
1 parent 8258d5e commit 1efb0a3
Show file tree
Hide file tree
Showing 29 changed files with 1,137 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ terraform.tfstate*
.terraform
*.log

# dropping the templates
templates-latest/

/dist
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ upload.newversion.provider: create.newversion.tfregistry ## Uploads the updated
@cp terraform-provider-gocd_v$(VERSION) ~/terraform-providers/registry.terraform.io/hashicorp/gocd/$(VERSION)/darwin_arm64/

generate.document:
@tfplugindocs generate examples/
tfplugindocs generate --website-source-dir templates/ --website-temp-dir templates-latest --examples-dir examples

tflint:
@terraform fmt -write=false -check=true -diff=true examples/
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/nikhilsbhat/terraform-provider-gocd)](https://goreportcard.com/report/github.com/nikhilsbhat/terraform-provider-gocd)
[![shields](https://img.shields.io/badge/license-MIT-blue)](https://github.com/nikhilsbhat/terraform-provider-gocd/blob/master/LICENSE)
[![shields](https://godoc.org/github.com/nikhilsbhat/terraform-provider-gocd?status.svg)](https://godoc.org/github.com/nikhilsbhat/terraform-provider-gocd)
[![shields](https://img.shields.io/github/v/tag/nikhilsbhat/terraform-provider-gocd.svg)](https://github.com/nikhilsbhat/terraform-provider-gocd/tags)
[![shields](https://img.shields.io/github/downloads/nikhilsbhat/terraform-provider-gocd/total.svg)](https://github.com/nikhilsbhat/terraform-provider-gocd/releases)

Terraform provider for `GoCD` that helps in performing tasks on [GoCD](https://www.gocd.org/) server.
Expand Down
46 changes: 42 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,55 @@ description: |-
---

# GoCD Provider
A provider to interact with continuous delivery server [GoCD](https://www.gocd.org/).
This helps to GET/CREATE/UPDATE various resources in GoCD server with the helm of GoCD [api](https://api.gocd.org/current/).
You must configure the provider with the proper credentials before you can use it.

## Example Usage
```terraform
terraform {
required_providers {
gocd = {
source = "hashicorp/gocd"
version = "~> 0.0.1"
}
}
}
A provider for a continuous delivery server [GoCD](https://www.gocd.org/).

```hcl
// Configure GoCD Provider
provider "gocd" {
# configuration for gocd goes here
base_url = "http://localhost:8153/go"
username = "admin"
auth_token = "d8fccbc997d04e917b1490af8e7bf46290ab8c99"
skip_check = true
}
// Create cluster profiles in GoCD
resource "gocd_cluster_profile" "kube_cluster_profile" {
profile_id = "kube_cluster_profile"
plugin_id = "cd.go.contrib.elasticagent.kubernetes"
properties {
key = "go_server_url"
value = "https://gocd.sample.com/go"
}
properties {
key = "auto_register_timeout"
value = "15"
}
}
```

## Authentication in GoCD provider
GoCD credentials can be passed to provider as both terraform variables and environment variables.

It supports both basic auth using `password` and bearer token based auth using `auth_token`.
### Environment variable:
- `GOCD_BASE_URL`
- `GOCD_CAFILE_CONTENT`
- `GOCD_USERNAME`
- `GOCD_PASSWORD`
- `GOCD_AUTH_TOKEN`

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

Expand Down
16 changes: 13 additions & 3 deletions docs/resources/auth_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ description: |-
---

# gocd_auth_config (Resource)



Creates an authorization configuration in GoCD with all below passed parameters by interacting with authorization configuration [api](https://api.gocd.org/current/#authorization-configuration).

## Example Usage
```terraform
resource "gocd_auth_config" "password_file_config" {
profile_id = "admin_new"
plugin_id = "cd.go.authentication.passwordfile"
properties {
key = "PasswordFilePath"
value = "path/to/.gocdadmin2"
}
}
```


<!-- schema generated by tfplugindocs -->
Expand Down
20 changes: 17 additions & 3 deletions docs/resources/cluster_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,23 @@ description: |-
---

# gocd_cluster_profile (Resource)



Creates cluster profiles in GoCD with all below passed parameters by interacting with GoCD cluster profile [api](https://api.gocd.org/current/#cluster-profiles).

## Example Usage
```terraform
resource "gocd_cluster_profile" "kube_cluster_profile" {
profile_id = "kube_cluster_profile"
plugin_id = "cd.go.contrib.elasticagent.kubernetes"
properties {
key = "go_server_url"
value = "https://gocd.sample.com/go"
}
properties {
key = "auto_register_timeout"
value = "15"
}
}
```


<!-- schema generated by tfplugindocs -->
Expand Down
32 changes: 31 additions & 1 deletion docs/resources/config_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,37 @@ description: |-
---

# gocd_config_repository (Resource)

Creates config repos in GoCD with all below passed parameters by interacting with GoCD config repo [api](https://api.gocd.org/current/#config-repo).

## Example Usage
```terraform
resource "gocd_config_repository" "sample_config_repo" {
profile_id = "sample_config_repo"
plugin_id = "yaml.config.plugin"
configuration {
key = "username"
value = "admin"
}
material {
type = "git"
attributes {
url = "https://github.com/config-repo/gocd-json-config-example.git"
username = "bob"
password = "aSdiFgRRZ6A="
branch = "master"
auto_update = false
}
}
rules = [
{
"directive" : "allow",
"action" : "refer",
"type" : "pipeline_group",
"resource" : "*"
}
]
}
```



Expand Down
16 changes: 13 additions & 3 deletions docs/resources/elastic_agent_profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ description: |-
---

# gocd_elastic_agent_profile (Resource)



Creates an elastic agent profiles in GoCD with all below passed parameters by interacting with elastic agent profiles [api](https://api.gocd.org/current/#elastic-agent-profiles).

## Example Usage
```terraform
resource "gocd_elastic_agent_profile" "sample_kubernetes" {
profile_id = "sample_kubernetes"
cluster_profile_id = gocd_cluster_profile.kube_cluster_profile.profile_id
properties {
key = "Image"
value = "basnik/thanosbench:with-thanos"
}
}
```


<!-- schema generated by tfplugindocs -->
Expand Down
11 changes: 8 additions & 3 deletions docs/resources/encrypt_value.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ description: |-
---

# gocd_encrypt_value (Resource)



Encrypts a plain text with GoCD by interacting with encryption [api](https://api.gocd.org/current/#encryption).

## Example Usage
```terraform
resource "gocd_encrypt_value" "new_value" {
value = "sample"
}
```


<!-- schema generated by tfplugindocs -->
Expand Down
19 changes: 16 additions & 3 deletions docs/resources/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ description: |-
---

# gocd_environment (Resource)



Creates environments in GoCD with all below passed parameters by interacting with GoCD environment [api](https://api.gocd.org/current/#environment-config).

## Example Usage
```terraform
resource "gocd_environment" "sample_environment" {
name = "sample_environment"
pipelines = [
"gocd-prometheus-exporter",
"helm-images",
]
environment_variables {
name = "TEST_ENV11"
value = "value_env11"
}
}
```


<!-- schema generated by tfplugindocs -->
Expand Down
19 changes: 16 additions & 3 deletions docs/resources/plugin_setting.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,22 @@ description: |-
---

# gocd_plugin_setting (Resource)



Manage the settings of an installed plugin in GoCD with all below passed parameters by interacting with GoCD plugin setting [api](https://api.gocd.org/current/#plugin-settings).

## Example Usage
```terraform
resource "gocd_plugin_setting" "json_plugin_settings" {
plugin_id = "json.config.plugin"
plugin_configurations {
key = "pipeline_pattern"
value = "*.gocdpipeline.test.json"
}
plugin_configurations {
key = "environment_pattern"
value = "*.gocdenvironment.test.json"
}
}
```


<!-- schema generated by tfplugindocs -->
Expand Down
41 changes: 38 additions & 3 deletions docs/resources/secret_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,44 @@ description: |-
---

# gocd_secret_config (Resource)



Creates secret configs in GoCD with all below passed parameters by interacting with GoCD secret configs [api](https://api.gocd.org/current/#secret-configs).

## Example Usage
```terraform
resource "gocd_secret_config" "sample_kube_secret_config" {
profile_id = "sample-kube-secret-config-new"
plugin_id = "cd.go.contrib.secrets.kubernetes"
description = "sample secret new config"
properties {
key = "kubernetes_secret_name"
value = "ci_secret"
}
properties {
key = "kubernetes_cluster_url"
value = "https://0.0.0.0:64527"
}
properties {
key = "security_token"
value = "AES:1poYVwRFAh8geGFaeY0GiQ==:7YQOCRx6sIMG9OjBkH0pdUvr1qJuokihboN+D0JBXzsrrFrmooItzZbyDFav/EcO"
}
properties {
key = "kubernetes_cluster_ca_cert"
value = "AES:frDz530rq4p6ZgzQUD0X5Q==:Ra9Ldo9TgwcvrzSwPoU4g1KqgDi0ByZXPV7oayJYMxsSXqsIUsDUrS4cyAtq5pPz"
}
properties {
key = "namespace"
value = "default"
}
rules = [
{
action = "refer",
directive = "allow",
resource = "*",
type = "*"
},
]
}
```


<!-- schema generated by tfplugindocs -->
Expand Down
2 changes: 1 addition & 1 deletion examples/authorization_configuration.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "gocd_auth_config" "password_file_config" {
plugin_id = "cd.go.authentication.passwordfile"
properties {
key = "PasswordFilePath"
value = "/Users/nikhil.bhat/idfc/gocd-setup/.gocdadmin2"
value = "path/to/.gocdadmin2"
}
}

Expand Down
46 changes: 46 additions & 0 deletions templates/data-sources/auth_config.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "gocd_auth_config Data Source - terraform-provider-gocd"
subcategory: ""
description: |-

---

# gocd_auth_config (Data Source)





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

### Required

- `profile_id` (String) The identifier of the authorization configuration.

### Optional

- `allow_only_known_users_to_login` (Boolean) Allow only those users to login who have explicitly been added by an administrator.
- `etag` (String) Etag used to track the authorization configuration.
- `plugin_id` (String) The plugin identifier of the authorization plugin.
- `properties` (Block List) The list of configuration properties that represent the configuration of this authorization configuration. (see [below for nested schema](#nestedblock--properties))

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--properties"></a>
### Nested Schema for `properties`

Required:

- `key` (String) the name of the property key.

Optional:

- `encrypted_value` (String) The encrypted value of the property
- `is_secure` (Boolean) Specify whether the given property is secure or not. If true and encrypted_value is not specified, GoCD will store the value in encrypted format.
- `value` (String) The value of the property


Loading

0 comments on commit 1efb0a3

Please sign in to comment.