Skip to content

Commit 0bde8c4

Browse files
committed
NSOF-5653 Makefile, README.md: add Makefile and documentation for developing the repo
1 parent 6c6186a commit 0bde8c4

2 files changed

Lines changed: 76 additions & 31 deletions

File tree

Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
debug-build:
2+
go build -o ./bin/terraform_provider_pfptmeta_linux_amd64 -gcflags="all=-N -l"
3+
./bin/terraform_provider_pfptmeta_linux_amd64 --debug
4+
5+
mod-tidy:
6+
go mod tidy
7+
8+
9+
unittest:
10+
go test ./... $(if $(VERBOSE),"-v") -timeout 120m
11+
12+
13+
acc_tests:
14+
TF_ACC=1 go test ./... $(if $(VERBOSE),"-v") -run "TestAcc*" -timeout 120m
15+
16+
17+
generate:
18+
go generate -v -x
19+
20+
21+
tests: acc_tests unittest
22+
23+
24+
verify_clean: mod-tidy generate
25+
! git status -s | grep "??" || (echo "Uncommitted files found" && exit 1)
26+
git diff --stat --exit-code || (echo "Uncommitted files found" && exit 1)
27+
28+
local-release: verify_clean tests
29+
gpg --batch --import $(GPG_SECRET_PATH) && goreleaser release --rm-dist --snapshot
30+
31+
32+
release: verify_clean tests
33+
gpg --batch --import $(GPG_SECRET_PATH) && goreleaser release --rm-dist

README.md

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,74 @@
1-
# Terraform Provider Scaffolding
2-
3-
This repository is a *template* for a [Terraform](https://www.terraform.io) provider. It is intended as a starting point for creating Terraform providers, containing:
4-
5-
- A resource, and a data source (`internal/provider/`),
6-
- Examples (`examples/`) and generated documentation (`docs/`),
7-
- Miscellaneous meta files.
8-
9-
These files contain boilerplate code that you will need to edit to create your own Terraform provider. A full guide to creating Terraform providers can be found at [Writing Custom Providers](https://www.terraform.io/docs/extend/writing-custom-providers.html).
10-
11-
Please see the [GitHub template repository documentation](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template) for how to create a new repository from this template on GitHub.
12-
13-
Once you've written your provider, you'll want to [publish it on the Terraform Registry](https://www.terraform.io/docs/registry/providers/publishing.html) so that others can use it.
1+
# Terraform Provider for Proofpoint - Meta Networks
142

3+
See the [Proofpoint - Meta Networks Provider documentation](docs/index.md) to get started using the provider.
154

165
## Requirements
176

18-
- [Terraform](https://www.terraform.io/downloads.html) >= 0.13.x
19-
- [Go](https://golang.org/doc/install) >= 1.15
7+
- [Terraform](https://www.terraform.io/downloads.html) 0.12.x or higher
8+
- [Go](https://golang.org/doc/install) >= 1.13
9+
- [Goreleaser](https://goreleaser.com/install/)
2010

2111
## Building The Provider
2212

2313
1. Clone the repository
24-
1. Enter the repository directory
25-
1. Build the provider using the Go `install` command:
14+
2. Enter the repository directory
15+
3. Build the provider using the Go `install` command:
2616
```sh
2717
$ go install
2818
```
2919

30-
## Adding Dependencies
20+
## Developing the Provider
21+
22+
### Adding Dependencies
3123

3224
This provider uses [Go modules](https://github.com/golang/go/wiki/Modules).
33-
Please see the Go documentation for the most up to date information about using Go modules.
25+
Please see the Go documentation for the most up-to-date information about using Go modules.
3426

3527
To add a new dependency `github.com/author/dependency` to your Terraform provider:
3628

37-
```
38-
go get github.com/author/dependency
39-
go mod tidy
29+
```sh
30+
$ go get github.com/author/dependency
31+
$ make mod-tidy
4032
```
4133

4234
Then commit the changes to `go.mod` and `go.sum`.
4335

44-
## Using the provider
36+
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).
37+
38+
To compile and run the provider locally run:
39+
```sh
40+
$ make debug-mode
41+
```
42+
And then export the printed `TF_REATTACH_PROVIDERS` as env variable.
4543

46-
Fill this in for each provider
44+
This will compile the provider in debug mode and will allow you to execute terraform command with it.
4745

48-
## Developing the Provider
46+
### Documentation
4947

50-
If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (see [Requirements](#requirements) above).
48+
In order to generate or update documentation, run `make generate`.
5149

52-
To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.
50+
The documentation are auto-generated using the [docs generation tool](github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs)
51+
and are based on the resources descriptions in the schema and on the files in the `examples` folder
5352

54-
To generate or update documentation, run `go generate`.
53+
### Testing
5554

56-
In order to run the full suite of Acceptance tests, run `make testacc`.
55+
There are two types of tests that can be executed:
56+
- unit-tests
57+
- acceptance-tests
5758

58-
*Note:* Acceptance tests create real resources, and often cost money to run.
59+
Acceptance tests are expressed in terms of Test Cases, each using one or more Terraform configurations designed to create a set of resources under test, and then verify the actual infrastructure created.
5960

61+
*Note:* Acceptance tests create real resources, and often cost money to run, see more about it [here](https://www.terraform.io/docs/extend/testing/acceptance-tests/testcase.html)
62+
63+
In order to run the full suite of Acceptance tests:
64+
- Configure the authentication env variables or configuration file specified in [provider documentation](docs/index.md).
65+
- Execute:
6066
```sh
61-
$ make testacc
67+
$ make acc_tests
68+
```
69+
70+
In order to tun unit-tests only run
71+
```shell
72+
$ make unittest
6273
```
74+

0 commit comments

Comments
 (0)