Skip to content

Commit bbc6a6a

Browse files
authored
Chore: Documentation Overhaul, General Cleanup (#104)
## What * Port all documentation to be generated via [terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs) * Add https://allcontributors.org * Add issue templates. * Misc cleanups * Update to go 1.18 ## Why * Documentation is missing <img width="1374" alt="CleanShot 2023-03-05 at 19 59 16@2x" src="https://user-images.githubusercontent.com/10080107/222987456-85f42b4c-ceeb-4be3-afed-baf0e8483a53.png"> ## Notes <!-- Add any notes here --> ## PR Checklist * [x] _I have [allowed changes to my fork to be made](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)._ * [x] _I have added tests, assuming new tests are warranted_. * [x] _I have updated the Terraform docs in this repo, assuming any changes to the schema of Resources or Data Sources have been made._ * [x] _I understand that the `/test` comment will be ignored by the CI trigger [unless it is made by a repo admin or collaborator](https://codefresh.io/docs/docs/pipelines/triggers/git-triggers/#support-for-building-pull-requests-from-forks)._ --------- Co-authored-by: Yonatan Koren <[email protected]>
1 parent 5e7a78e commit bbc6a6a

File tree

96 files changed

+3568
-1382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+3568
-1382
lines changed

.github/ISSUE_TEMPLATES/bug.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Bug Report
2+
description: File a bug report
3+
title: "[Bug]: "
4+
labels: ["bug", "triage"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill out this bug report!
10+
- type: textarea
11+
id: what-happened
12+
attributes:
13+
label: What happened?
14+
description: Describe the bug in detail. What did you expect to happen? What actually happened?
15+
value: "A bug happened!"
16+
validations:
17+
required: true
18+
- type: textarea
19+
id: version
20+
attributes:
21+
label: Version
22+
description: What version of the Provider are you running?
23+
validations:
24+
required: true
25+
- type: textarea
26+
id: logs
27+
attributes:
28+
label: Relevant Terraform Configuration
29+
description: Please copy and paste any relevant Terraform configurations we can use to reproduce the bug.
30+
render: hcl

.github/ISSUE_TEMPLATES/feature.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Feature Request
2+
description: Submit a feature request
3+
title: "[Feature]: "
4+
labels: ["enhancement"]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Thanks for taking the time to fill out this feature request!
10+
- type: textarea
11+
id: feature
12+
attributes:
13+
label: What would you like to be added?
14+
description: If applicable, add a mock Terraform schema for the new resource or data source.
15+
value: "The following feature would be great!"
16+
validations:
17+
required: true

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
## PR Checklist
99

10+
* [ ] _I have read [CONTRIBUTING.md](https://github.com/codefresh-io/terraform-provider-codefresh/blob/master/README.md)._
1011
* [ ] _I have [allowed changes to my fork to be made](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)._
1112
* [ ] _I have added tests, assuming new tests are warranted_.
1213
* [ ] _I have updated the Terraform docs in this repo, assuming any changes to the schema of Resources or Data Sources have been made._
13-
* [ ] _I understand that the `/test` comment will be ignored by the CI trigger [unless it is made by a repo admin or collaborator](https://codefresh.io/docs/docs/pipelines/triggers/git-triggers/#support-for-building-pull-requests-from-forks)._
14+
* [ ] _I understand that the `/test` comment will be ignored by the CI trigger [unless it is made by a repo admin or collaborator](https://codefresh.io/docs/docs/pipelines/triggers/git-triggers/#support-for-building-pull-requests-from-forks)._

.github/labeler.yml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
source:
2-
- 'client/**/*'
3-
- 'codefresh/**/*'
4-
- '*.go'
5-
- '*.mod'
6-
- '*.sum'
2+
- "client/**/*"
3+
- "codefresh/**/*"
4+
- "*.go"
5+
- "*.mod"
6+
- "*.sum"
77

88
docs:
9-
- README.md
10-
- docs/**/*
11-
- examples/**/*
12-
- tf_modules/**/*
13-
- CHANGELOG.md
9+
- README.md
10+
- docs/**/*
11+
- templates/**/*
12+
- examples/**/*
13+
- tf_modules/**/*
14+
- CHANGELOG.md
1415

1516
automation:
16-
- scripts/**/*
17-
- .github/**/*
18-
- codefresh.yml
19-
- .goreleaser.yml
20-
- GNUmakefile
17+
- scripts/**/*
18+
- .github/**/*
19+
- codefresh.yml
20+
- .goreleaser.yml
21+
- GNUmakefile

.github/release-drafter.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ categories:
1414
label: "chore"
1515
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
1616
change-title-escapes: '\<*_&'
17+
exclude-labels:
18+
- "no-release"
1719
version-resolver:
1820
major:
1921
labels:
@@ -32,4 +34,4 @@ version-resolver:
3234
default: patch
3335
template: |
3436
## Changes
35-
$CHANGES
37+
$CHANGES

CONTRIBUTING.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Contributing
2+
3+
## Updating Provider Documentation
4+
5+
The documentation is generated using [tfplugindocs](https://github.com/hashicorp/terraform-plugin-docs).
6+
7+
`docs/` should never be edited by hand. Instead, update the documentation via updating `Description` fields within the `schema` blocks of the provider's resources and data sources. And if needed, update the templates in `templates/`. Finally, you can run the following command to re-generate the documentation:
8+
9+
```bash
10+
make docs
11+
```
12+
13+
## Submitting a PR
14+
15+
1. Fork the repo
16+
2. Create a PR from your fork against the `master` branch
17+
3. Add labels to your PR (see: [Labels](.github/release-drafter.yaml))
18+
19+
### PR Requirements
20+
21+
1. Ensure that all tests pass (via commenting `/test` if you are an admin or a contributor with write access on this repo, otherwise wait for a maintainer to submit the comment. The comment will be ignored if you are not an admin or a contributor with write access on this repo. See: https://codefresh.io/docs/docs/pipelines/triggers/git-triggers/#support-for-building-pull-requests-from-forks)
22+
2. Ensure that `make docs` has been run and the changes have been committed.
23+
3. Ensure that `make fmt` has been run and the changes have been committed.
24+
25+
### Adding Yourself to the Contributors List
26+
27+
Comment on the PR with `@all-contributors please add @<username> for <contributions>` and the bot will add you to the contributors list. See: [All Contributors](https://allcontributors.org/docs/en/bot/usage).
28+
29+
For example: `@all-contributors please add @mitchellh for code`.

GNUmakefile

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ NAMESPACE=app
77
BINARY=terraform-provider-${PKG_NAME}
88
VERSION=0.2.1
99
OS_ARCH=darwin_amd64
10+
TFPLUGINDOCS_VERSION=v0.14.1
1011

1112
default: build
1213

@@ -20,8 +21,7 @@ build: fmtcheck
2021
go build -o ${BINARY}
2122

2223
install: build
23-
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${PKG_NAME}/${VERSION}/${OS_ARCH}
24-
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${PKG_NAME}/${VERSION}/${OS_ARCH}
24+
mv ${BINARY} $(HOME)/go/bin/
2525

2626
fmt:
2727
@echo "==> Fixing source code with gofmt..."
@@ -59,22 +59,9 @@ vet:
5959
exit 1; \
6060
fi
6161

62-
website:
63-
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
64-
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
65-
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
66-
endif
67-
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
62+
docs:
63+
@echo "==> Generating Provider Documentation..."
64+
which tfplugindocs || go get github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@${TFPLUGINDOCS_VERSION}
65+
tfplugindocs generate
6866

69-
website-lint:
70-
@echo "==> Checking website against linters..."
71-
@misspell -error -source=text website/
72-
73-
website-test:
74-
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
75-
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
76-
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
77-
endif
78-
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
79-
80-
.PHONY: build test testacc vet fmt fmtcheck lint tools test-compile website website-lint website-test
67+
.PHONY: build test testacc vet fmt fmtcheck lint tools test-compile docs

README.md

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,43 @@
1-
# Terraform provider for Codefresh
1+
# Terraform Provider for Codefresh
22

3-
This provider was initialized by [LightStep](https://lightstep.com/) and will be maintained as the official Terraform provider for Codefresh.
3+
This is the official Terraform Provider for Codefresh.
44

5-
The provider is still under development, and can be used as a terraform [third-party plugin](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins) only.
5+
Terraform Registry: [registry.terraform.io/providers/codefresh-io/codefresh](https://registry.terraform.io/providers/codefresh-io/codefresh/latest)
66

77
## Requirements
88

9-
- [Terraform](https://www.terraform.io/downloads.html) 0.12+ ;
10-
- [Go](https://golang.org/doc/install) 1.12+ (to build the provider plugin).
9+
- [Terraform](https://www.terraform.io/downloads.html) `1.x.x`
1110

12-
## Download Provider
13-
Download and extract terraform-provider-codefresh from [releases](https://github.com/codefresh-io/terraform-provider-codefresh/releases)
14-
15-
## Building the Provider
11+
## Download the Provider
1612

17-
```sh
18-
go build -o terraform-provider-codefresh
19-
```
13+
Download and extract terraform-provider-codefresh from [releases](https://github.com/codefresh-io/terraform-provider-codefresh/releases)
2014

2115
## Using the Provider
2216

23-
Compile or take from the [Releases](https://github.com/codefresh-contrib/terraform-provider-codefresh/releases) `terraform-provider-codefresh` binary and place it locally according the Terraform plugins [documentation](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins).
24-
25-
### for terraform 0.12:
26-
- _~/.terraform.d/plugins/linux\_amd64_
27-
- _./terraform.d/plugins/linux\_amd64_. The relative path in your Terraform project.
17+
In `versions.tf`:
2818

29-
### for terraform 0.13 follow [required providers](https://www.terraform.io/docs/configuration/provider-requirements.html):
30-
```bash
31-
# OS is linux|windows|darwin, ARCH is amd64|arm|x86
32-
PLUGIN_DIR=~/.terraform.d/plugins/codefresh.io/app/codefresh/0.1.0/<OS_ARCH>
33-
mkdir -p ${PLUGIN_DIR}
34-
cp terraform-provider-codefresh ${PLUGIN_DIR}/
35-
```
36-
37-
add [required_providers block](https://www.terraform.io/docs/configuration/provider-requirements.html#requiring-providers)
3819
```terraform
3920
terraform {
40-
4121
required_providers {
4222
codefresh = {
43-
version = "0.1.0"
44-
source = "codefresh.io/app/codefresh"
23+
version = "x.y.z" # Optional but recommended; replace with latest semantic version
24+
source = "codefresh.io/codefresh"
4525
}
4626
}
4727
}
4828
```
4929

30+
## Building the Provider Locally
5031

51-
## [Documentation](./docs)
32+
```sh
33+
make install
34+
```
5235

53-
## [Examples](./examples)
36+
## [Provider Documentation](./docs)
37+
38+
The documentation is generated using [tfplugindocs](https://github.com/hashicorp/terraform-plugin-docs).
39+
40+
See: [CONTRIBUTING.md](./CONTRIBUTING.md#documentation)
5441

5542
## To configure Codefresh provider:
5643

@@ -77,12 +64,30 @@ export CODEFRESH_API_KEY='xyz'
7764

7865
## Testing the Provider
7966

67+
**NOTE:** Acceptance tests create real resources, including admin resources (accounts, users) so make sure that `CODEFRESH_API_KEY` is set to an account that you are ok with being modified.
68+
8069
```bash
81-
export TF_ACC="test"
82-
export CODEFRESH_API_KEY=[YOUR API TOKEN]
83-
go test -v ./...
70+
make testacc
8471
```
8572

73+
## Contributors
74+
75+
[![All Contributors](https://img.shields.io/github/all-contributors/codefresh-io/terraform-provider-aws?color=ee8449&style=flat-square)](#contributors)
76+
77+
78+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
79+
<!-- prettier-ignore-start -->
80+
<!-- markdownlint-disable -->
81+
82+
<!-- markdownlint-restore -->
83+
<!-- prettier-ignore-end -->
84+
85+
<!-- ALL-CONTRIBUTORS-LIST:END -->
86+
87+
## Acknowledgements
88+
89+
_This provider was initialized by [LightStep](https://lightstep.com/)_.
90+
8691
## License
8792

8893
Copyright 2023 Codefresh.

codefresh/data_account.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package codefresh
22

33
import (
44
"fmt"
5+
56
cfClient "github.com/codefresh-io/terraform-provider-codefresh/client"
67
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
78
)
89

910
func dataSourceAccount() *schema.Resource {
1011
return &schema.Resource{
11-
Read: dataSourceAccountRead,
12+
Description: "This data source retrieves an account by _id or name.",
13+
Read: dataSourceAccountRead,
1214
Schema: map[string]*schema.Schema{
1315
"_id": {
1416
Type: schema.TypeString,

codefresh/data_context.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010

1111
func dataSourceContext() *schema.Resource {
1212
return &schema.Resource{
13-
Read: dataSourceContextRead,
13+
Description: "This data source allows to retrieve information on any defined context.",
14+
Read: dataSourceContextRead,
1415
Schema: map[string]*schema.Schema{
1516
"name": {
1617
Type: schema.TypeString,

codefresh/data_current_account.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package codefresh
22

33
import (
44
"fmt"
5+
56
cfClient "github.com/codefresh-io/terraform-provider-codefresh/client"
67
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
78
)
89

910
func dataSourceCurrentAccount() *schema.Resource {
1011
return &schema.Resource{
11-
Read: dataSourceCurrentAccountRead,
12+
Description: "Returns the current account (owner of the token) and its users.",
13+
Read: dataSourceCurrentAccountRead,
1214
Schema: map[string]*schema.Schema{
1315
"name": {
1416
Type: schema.TypeString,

codefresh/resource_idp.go renamed to codefresh/data_idps.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ package codefresh
22

33
import (
44
"fmt"
5+
56
cfClient "github.com/codefresh-io/terraform-provider-codefresh/client"
67
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
78
)
89

910
func dataSourceIdps() *schema.Resource {
1011
return &schema.Resource{
11-
Read: dataSourceIdpRead,
12-
Schema: IdpSchema(),
12+
Description: "This data source retrieves all Identity Providers (IdPs) in the system.",
13+
Read: dataSourceIdpRead,
14+
Schema: IdpSchema(),
1315
}
1416
}
1517

codefresh/data_registry.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import (
99

1010
func dataSourceRegistry() *schema.Resource {
1111
return &schema.Resource{
12-
Read: dataSourceRegistryRead,
12+
Description: "This data source allows retrieving information on any existing registry.",
13+
Read: dataSourceRegistryRead,
1314
Schema: map[string]*schema.Schema{
1415
"name": {
1516
Type: schema.TypeString,

codefresh/data_step_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010

1111
func dataSourceStepTypes() *schema.Resource {
1212
return &schema.Resource{
13-
Read: dataSourceStepTypesRead,
13+
Description: "This data source allows to retrieve the published versions of step-types.",
14+
Read: dataSourceStepTypesRead,
1415
Schema: map[string]*schema.Schema{
1516
"name": {
1617
Type: schema.TypeString,

codefresh/data_team.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package codefresh
22

33
import (
44
"fmt"
5+
56
cfClient "github.com/codefresh-io/terraform-provider-codefresh/client"
67
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
78
)
89

910
func dataSourceTeam() *schema.Resource {
1011
return &schema.Resource{
11-
Read: dataSourceTeamRead,
12+
Description: "This data source retrieves a team by its ID or name.",
13+
Read: dataSourceTeamRead,
1214
Schema: map[string]*schema.Schema{
1315
"_id": {
1416
Type: schema.TypeString,

0 commit comments

Comments
 (0)