Skip to content

Chore: Documentation Overhaul, General Cleanup #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATES/bug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Bug Report
description: File a bug report
title: "[Bug]: "
labels: ["bug", "triage"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Describe the bug in detail. What did you expect to happen? What actually happened?
value: "A bug happened!"
validations:
required: true
- type: textarea
id: version
attributes:
label: Version
description: What version of the Provider are you running?
validations:
required: true
- type: textarea
id: logs
attributes:
label: Relevant Terraform Configuration
description: Please copy and paste any relevant Terraform configurations we can use to reproduce the bug.
render: hcl
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATES/feature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Feature Request
description: Submit a feature request
title: "[Feature]: "
labels: ["enhancement"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this feature request!
- type: textarea
id: feature
attributes:
label: What would you like to be added?
description: If applicable, add a mock Terraform schema for the new resource or data source.
value: "The following feature would be great!"
validations:
required: true
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

## PR Checklist

* [ ] _I have read [CONTRIBUTING.md](https://github.com/codefresh-io/terraform-provider-codefresh/blob/master/README.md)._
* [ ] _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)._
* [ ] _I have added tests, assuming new tests are warranted_.
* [ ] _I have updated the Terraform docs in this repo, assuming any changes to the schema of Resources or Data Sources have been made._
* [ ] _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)._
* [ ] _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)._
31 changes: 16 additions & 15 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
source:
- 'client/**/*'
- 'codefresh/**/*'
- '*.go'
- '*.mod'
- '*.sum'
- "client/**/*"
- "codefresh/**/*"
- "*.go"
- "*.mod"
- "*.sum"

docs:
- README.md
- docs/**/*
- examples/**/*
- tf_modules/**/*
- CHANGELOG.md
- README.md
- docs/**/*
- templates/**/*
- examples/**/*
- tf_modules/**/*
- CHANGELOG.md

automation:
- scripts/**/*
- .github/**/*
- codefresh.yml
- .goreleaser.yml
- GNUmakefile
- scripts/**/*
- .github/**/*
- codefresh.yml
- .goreleaser.yml
- GNUmakefile
4 changes: 3 additions & 1 deletion .github/release-drafter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ categories:
label: "chore"
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
change-title-escapes: '\<*_&'
exclude-labels:
- "no-release"
version-resolver:
major:
labels:
Expand All @@ -32,4 +34,4 @@ version-resolver:
default: patch
template: |
## Changes
$CHANGES
$CHANGES
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Contributing

## Updating Provider Documentation

The documentation is generated using [tfplugindocs](https://github.com/hashicorp/terraform-plugin-docs).

`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:

```bash
make docs
```

## Submitting a PR

1. Fork the repo
2. Create a PR from your fork against the `master` branch
3. Add labels to your PR (see: [Labels](.github/release-drafter.yaml))

### PR Requirements

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)
2. Ensure that `make docs` has been run and the changes have been committed.
3. Ensure that `make fmt` has been run and the changes have been committed.

### Adding Yourself to the Contributors List

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).

For example: `@all-contributors please add @mitchellh for code`.
27 changes: 7 additions & 20 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ NAMESPACE=app
BINARY=terraform-provider-${PKG_NAME}
VERSION=0.2.1
OS_ARCH=darwin_amd64
TFPLUGINDOCS_VERSION=v0.14.1

default: build

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

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

fmt:
@echo "==> Fixing source code with gofmt..."
Expand Down Expand Up @@ -59,22 +59,9 @@ vet:
exit 1; \
fi

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

website-lint:
@echo "==> Checking website against linters..."
@misspell -error -source=text website/

website-test:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

.PHONY: build test testacc vet fmt fmtcheck lint tools test-compile website website-lint website-test
.PHONY: build test testacc vet fmt fmtcheck lint tools test-compile docs
73 changes: 39 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,43 @@
# Terraform provider for Codefresh
# Terraform Provider for Codefresh

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

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.
Terraform Registry: [registry.terraform.io/providers/codefresh-io/codefresh](https://registry.terraform.io/providers/codefresh-io/codefresh/latest)

## Requirements

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

## Download Provider
Download and extract terraform-provider-codefresh from [releases](https://github.com/codefresh-io/terraform-provider-codefresh/releases)

## Building the Provider
## Download the Provider

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

## Using the Provider

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).

### for terraform 0.12:
- _~/.terraform.d/plugins/linux\_amd64_
- _./terraform.d/plugins/linux\_amd64_. The relative path in your Terraform project.
In `versions.tf`:

### for terraform 0.13 follow [required providers](https://www.terraform.io/docs/configuration/provider-requirements.html):
```bash
# OS is linux|windows|darwin, ARCH is amd64|arm|x86
PLUGIN_DIR=~/.terraform.d/plugins/codefresh.io/app/codefresh/0.1.0/<OS_ARCH>
mkdir -p ${PLUGIN_DIR}
cp terraform-provider-codefresh ${PLUGIN_DIR}/
```

add [required_providers block](https://www.terraform.io/docs/configuration/provider-requirements.html#requiring-providers)
```terraform
terraform {

required_providers {
codefresh = {
version = "0.1.0"
source = "codefresh.io/app/codefresh"
version = "x.y.z" # Optional but recommended; replace with latest semantic version
source = "codefresh.io/codefresh"
}
}
}
```

## Building the Provider Locally

## [Documentation](./docs)
```sh
make install
```

## [Examples](./examples)
## [Provider Documentation](./docs)

The documentation is generated using [tfplugindocs](https://github.com/hashicorp/terraform-plugin-docs).

See: [CONTRIBUTING.md](./CONTRIBUTING.md#documentation)

## To configure Codefresh provider:

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

## Testing the Provider

**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.

```bash
export TF_ACC="test"
export CODEFRESH_API_KEY=[YOUR API TOKEN]
go test -v ./...
make testacc
```

## Contributors

[![All Contributors](https://img.shields.io/github/all-contributors/codefresh-io/terraform-provider-aws?color=ee8449&style=flat-square)](#contributors)


<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

## Acknowledgements

_This provider was initialized by [LightStep](https://lightstep.com/)_.

## License

Copyright 2023 Codefresh.
Expand Down
4 changes: 3 additions & 1 deletion codefresh/data_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package codefresh

import (
"fmt"

cfClient "github.com/codefresh-io/terraform-provider-codefresh/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceAccount() *schema.Resource {
return &schema.Resource{
Read: dataSourceAccountRead,
Description: "This data source retrieves an account by _id or name.",
Read: dataSourceAccountRead,
Schema: map[string]*schema.Schema{
"_id": {
Type: schema.TypeString,
Expand Down
3 changes: 2 additions & 1 deletion codefresh/data_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (

func dataSourceContext() *schema.Resource {
return &schema.Resource{
Read: dataSourceContextRead,
Description: "This data source allows to retrieve information on any defined context.",
Read: dataSourceContextRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Expand Down
4 changes: 3 additions & 1 deletion codefresh/data_current_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package codefresh

import (
"fmt"

cfClient "github.com/codefresh-io/terraform-provider-codefresh/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceCurrentAccount() *schema.Resource {
return &schema.Resource{
Read: dataSourceCurrentAccountRead,
Description: "Returns the current account (owner of the token) and its users.",
Read: dataSourceCurrentAccountRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Expand Down
6 changes: 4 additions & 2 deletions codefresh/resource_idp.go → codefresh/data_idps.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package codefresh

import (
"fmt"

cfClient "github.com/codefresh-io/terraform-provider-codefresh/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceIdps() *schema.Resource {
return &schema.Resource{
Read: dataSourceIdpRead,
Schema: IdpSchema(),
Description: "This data source retrieves all Identity Providers (IdPs) in the system.",
Read: dataSourceIdpRead,
Schema: IdpSchema(),
}
}

Expand Down
3 changes: 2 additions & 1 deletion codefresh/data_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (

func dataSourceRegistry() *schema.Resource {
return &schema.Resource{
Read: dataSourceRegistryRead,
Description: "This data source allows retrieving information on any existing registry.",
Read: dataSourceRegistryRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Expand Down
3 changes: 2 additions & 1 deletion codefresh/data_step_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (

func dataSourceStepTypes() *schema.Resource {
return &schema.Resource{
Read: dataSourceStepTypesRead,
Description: "This data source allows to retrieve the published versions of step-types.",
Read: dataSourceStepTypesRead,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Expand Down
4 changes: 3 additions & 1 deletion codefresh/data_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package codefresh

import (
"fmt"

cfClient "github.com/codefresh-io/terraform-provider-codefresh/client"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceTeam() *schema.Resource {
return &schema.Resource{
Read: dataSourceTeamRead,
Description: "This data source retrieves a team by its ID or name.",
Read: dataSourceTeamRead,
Schema: map[string]*schema.Schema{
"_id": {
Type: schema.TypeString,
Expand Down
Loading