Skip to content

Commit de7c366

Browse files
authored
Merge pull request #170 from hashicorp/bendbennett/issues-112
Migrate to terraform-plugin-framework
2 parents d280bc8 + 2bc334a commit de7c366

32 files changed

+2111
-517
lines changed

.github/CONTRIBUTING.md

Lines changed: 99 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,129 @@
1-
# Contributing to `terraform-provider-archive`
1+
# Contributing
22

3-
**First:** if you're unsure or afraid of _anything_, just ask or submit the issue describing the problem you're aiming to solve.
3+
Thank you for investing your time and energy by contributing to our project: please ensure you are familiar
4+
with the [HashiCorp Code of Conduct](https://github.com/hashicorp/.github/blob/master/CODE_OF_CONDUCT.md).
45

5-
The `archive` provider is a HashiCorp *standard library* provider, which means we consider it part of the core Terraform experience. Our priority is stability and correctness, and any bug fix or feature has to be considered in the context of this provider's many users and the wider Terraform ecosystem.
6-
This is great as your contribution can have a big positive impact, but we have to assess potential negative impact too.
6+
This provider is a HashiCorp **utility provider**, which means any bug fix and feature
7+
has to be considered in the context of the thousands/millions of configurations in which this provider is used.
8+
This is great as your contribution can have a big positive impact, but we have to assess potential negative impact too
9+
(e.g. breaking existing configurations). _Stability over features_.
710

8-
To provide some safety to the Terraform ecosystem, we strictly follow [semantic versioning](https://semver.org/) and any changes that could be considered as breaking will only be released as part of a major release.
11+
To provide some safety to the wider provider ecosystem, we strictly follow
12+
[semantic versioning](https://semver.org/) and HashiCorp's own
13+
[versioning specification](https://www.terraform.io/plugin/sdkv2/best-practices/versioning#versioning-specification).
14+
Any changes that could be considered as breaking will only be included as part of a major release.
15+
In case multiple breaking changes need to happen, we will group them in the next upcoming major release.
916

10-
## Table of Contents
17+
## Asking Questions
1118

12-
- [I just have a question](#i-just-have-a-question)
13-
- [I want to report a vulnerability](#i-want-to-report-a-vulnerability)
14-
- [New Issue](#new-issue)
15-
- [New Pull Request](#new-pull-request)
19+
For questions, curiosity, or if still unsure what you are dealing with,
20+
please see the HashiCorp [Terraform Providers Discuss](https://discuss.hashicorp.com/c/terraform-providers/31)
21+
forum.
1622

17-
## I just have a question
23+
## Reporting Vulnerabilities
1824

19-
> **Note:** We use GitHub for tracking bugs and feature requests only.
25+
Please disclose security vulnerabilities responsibly by following the
26+
[HashiCorp Vulnerability Reporting guidelines](https://www.hashicorp.com/security#vulnerability-reporting).
2027

21-
For questions, please see relevant channels at https://www.terraform.io/community.html
28+
## Understanding the design
2229

23-
## I want to report a vulnerability
30+
Before proceeding with raising issues or submitting pull requests, it will probably help to familiarise yourself with
31+
the [design principles](../DESIGN.md) of this provider. This will aid your proposals, and help understand
32+
why we took certain decisions during development.
2433

25-
Please disclose security vulnerabilities responsibly by following the procedure
26-
described at https://www.hashicorp.com/security#vulnerability-reporting
34+
## Raising Issues
2735

28-
## New Issue
29-
30-
We welcome issues of all kinds including feature requests, bug reports or documentation suggestions. Below are guidelines for well-formed issues of each type.
36+
We welcome issues of all kinds including feature requests, bug reports or documentation suggestions.
37+
Below are guidelines for well-formed issues of each type.
3138

3239
### Bug Reports
3340

34-
- **Test against latest release**: Make sure you test against the latest avaiable version of both Terraform and the provider.
35-
It is possible we already fixed the bug you're experiencing.
36-
37-
- **Search for duplicates**: It's helpful to keep bug reports consolidated to one thread, so do a quick search on existing bug reports to check if anybody else has reported the same thing. You can scope searches by the label `bug` to help narrow things down.
38-
39-
- **Include steps to reproduce**: Provide steps to reproduce the issue, along with code examples (both HCL and Go, where applicable) and/or real code, so we can try to reproduce it. Without this, it makes it much harder (sometimes impossible) to fix the issue.
41+
* [ ] **Test against latest release**: Make sure you test against the latest available version of Terraform and the provider.
42+
It is possible we may have already fixed the bug you're experiencing.
43+
* [ ] **Search for duplicates**: It's helpful to keep bug reports consolidated to one thread, so do a quick search
44+
on existing bug reports to check if anybody else has reported the same thing.
45+
You can scope searches by the label `bug` to help narrow things down.
46+
* [ ] **Include steps to reproduce**: Provide steps to reproduce the issue, along with code examples and/or real code,
47+
so we can try to reproduce it. Without this, it makes it much harder (sometimes impossible) to fix the issue.
4048

4149
### Feature Requests
4250

43-
- **Search for possible duplicate requests**: It's helpful to keep requests consolidated to one thread, so do a quick search on existing requests to check if anybody else has reported the same thing. You can scope searches by the label `enhancement` to help narrow things down.
44-
45-
- **Include a use case description**: In addition to describing the behavior of the feature you'd like to see added, it's helpful to also lay out the reason why the feature would be important and how it would benefit the wider Terraform ecosystem. Use case in context of 1 provider is good, wider context of more providers is better.
51+
* [ ] **Search for possible duplicate requests**: It's helpful to keep requests consolidated to one thread,
52+
so do a quick search on existing requests to check if anybody else has reported the same thing.
53+
You can scope searches by the label `enhancement` to help narrow things down.
54+
* [ ] **Include a use case description**: In addition to describing the behavior of the feature you'd like to see added,
55+
it's helpful to also make a case for why the feature would be important and how it would benefit
56+
the provider and, potentially, the wider Terraform ecosystem.
4657

4758
## New Pull Request
4859

4960
Thank you for contributing!
5061

51-
We are happy to review pull requests without associated issues, but we highly recommend starting by describing and discussing your problem or feature and attaching use cases to an issue first before raising a pull request.
62+
We are happy to review pull requests without associated issues,
63+
but we **highly recommend** starting by describing and discussing
64+
your problem or feature and attaching use cases to an issue first
65+
before raising a pull request.
66+
67+
* [ ] **Early validation of idea and implementation plan**: provider development is complicated enough that there
68+
are often several ways to implement something, each of which has different implications and tradeoffs.
69+
Working through a plan of attack with the team before you dive into implementation will help ensure that you're
70+
working in the right direction.
71+
* [ ] **Tests**: It may go without saying, but every new patch should be covered by tests wherever possible.
72+
For bug-fixes, tests to prove the fix is valid. For features, tests to exercise the new code paths.
73+
* [ ] **Go Modules**: We use [Go Modules](https://github.com/golang/go/wiki/Modules) to manage and version our dependencies.
74+
Please make sure that you reflect dependency changes in your pull requests appropriately
75+
(e.g. `go get`, `go mod tidy` or other commands).
76+
Refer to the [dependency updates](#dependency-updates) section for more information about how
77+
this project maintains existing dependencies.
78+
* [ ] **Changelog**: Refer to the [changelog](#changelog) section for more information about how to create changelog entries.
79+
80+
### Dependency Updates
81+
82+
Dependency management is performed by [Dependabot](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates).
83+
Where possible, dependency updates should occur through that system to ensure all Go module files are appropriately
84+
updated and to prevent duplicated effort of concurrent update submissions.
85+
Once available, updates are expected to be verified and merged to prevent latent technical debt.
86+
87+
### Changelog
88+
89+
HashiCorp’s open-source projects have always maintained user-friendly, readable `CHANGELOG`s that allow
90+
practitioners and developers to tell at a glance whether a release should have any effect on them,
91+
and to gauge the risk of an upgrade.
92+
93+
We follow Terraform Plugin
94+
[changelog specifications](https://www.terraform.io/plugin/sdkv2/best-practices/versioning#changelog-specification).
95+
96+
#### Entry format
97+
98+
Entries that are specific to _resources_ or _data sources_, they should look like:
99+
100+
```markdown
101+
* resource/RESOURCE_NAME: ENTRY DESCRIPTION ([#PR_NUMBER](PR_URL)).
102+
103+
* data-source/DATA-SOURCE_NAME: ENTRY DESCRIPTION ([#PR_NUMBER](PR_URL)).
104+
```
52105

53-
- **Early validation of idea and implementation plan**: Terraform's SDK is complicated enough that there are often several ways to implement something, each of which has different implications and tradeoffs. Working through a plan of attack with the team before you dive into implementation will help ensure that you're working in the right direction.
106+
#### Which changes should appear in the `CHANGELOG`?
54107

55-
- **Acceptance Tests**: It may go without saying, but every new patch should be covered by tests wherever possible.
108+
The `CHANGELOG` is intended to show developer-impacting changes to the codebase for a particular version.
109+
If every change or commit to the code resulted in an entry, the `CHANGELOG` would become less useful for developers.
110+
The lists below are general guidelines to decide whether a change should have an entry.
56111

57-
- **Go Modules**: We use [Go Modules](https://github.com/golang/go/wiki/Modules) to manage and version all our dependencies. Please make sure that you reflect dependency changes in your pull requests appropriately (e.g. `go get`, `go mod tidy` or other commands). Where possible it is better to raise a separate pull request with just dependency changes as it's easier to review such PR(s).
112+
##### Changes that _should not_ have a `CHANGELOG` entry
58113

59-
### Cosmetic changes, code formatting, and typos
114+
* Documentation updates
115+
* Testing updates
116+
* Code refactoring
60117

61-
In general we do not accept PRs containing only the following changes:
118+
##### Changes that _may_ have a `CHANGELOG` entry
62119

63-
- Correcting spelling or typos
64-
- Code formatting, including whitespace
65-
- Other cosmetic changes that do not affect functionality
66-
67-
While we appreciate the effort that goes into preparing PRs, there is always a tradeoff between benefit and cost. The costs involved in accepting such contributions include the time taken for thorough review, the noise created in the git history, and the increased number of GitHub notifications that maintainers must attend to.
120+
* Dependency updates: If the update contains relevant bug fixes or enhancements that affect developers,
121+
those should be called out.
68122

69-
#### Exceptions
123+
##### Changes that _should_ have a `CHANGELOG` entry
70124

71-
We belive that one should "leave the campsite cleaner than you found it", so you are welcome to clean up cosmetic issues in the neighbourhood when submitting a patch that makes functional changes or fixes.
125+
* Major features
126+
* Bug fixes
127+
* Enhancements
128+
* Deprecations
129+
* Breaking changes and removals

.github/SUPPORT.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Support
22

3-
Terraform is a mature project with a growing community. There are active, dedicated people willing to help you through various mediums.
4-
5-
Take a look at those mediums listed at https://www.terraform.io/community.html
3+
* Project [README](../README.md).
4+
* Official [Documentation](https://registry.terraform.io/providers/hashicorp/archive/latest/docs).
5+
* Provider [Discussion forums](https://discuss.hashicorp.com/c/terraform-providers/31).
6+
* Terraform [Community](https://www.terraform.io/community.html).

.github/workflows/test.yml

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -28,49 +28,61 @@ jobs:
2828
go-version-file: 'go.mod'
2929
id: go
3030

31-
- name: Go fmt
32-
run: |
33-
make fmt
31+
- name: Run linters
32+
uses: golangci/golangci-lint-action@0ad9a0988b3973e851ab0a07adf248ec2e100376 # v3.3.1
33+
with:
34+
version: latest
3435

35-
- name: Go vet
36-
run: |
37-
make vet
36+
- name: Generate
37+
run: make generate
3838

39-
- name: Build
39+
- name: Confirm no diff
4040
run: |
41-
go build -v .
41+
git diff --compact-summary --exit-code || \
42+
(echo "*** Unexpected differences after code generation. Run 'make generate' and commit."; exit 1)
4243
44+
- name: Build
45+
run: make build
46+
4347

44-
# run acceptance tests in a matrix with Terraform core versions
48+
# run acceptance tests in a matrix with Terraform core versions
4549
test:
46-
name: Matrix Test
50+
name: 'Acc. Tests (OS: ${{ matrix.os }} / TF: ${{ matrix.terraform }})'
4751
needs: build
4852
runs-on: ${{ matrix.os }}
4953
timeout-minutes: 15
5054
strategy:
5155
fail-fast: false
5256
matrix:
53-
os: [macos-latest, windows-latest, ubuntu-latest]
57+
os:
58+
- macos-latest
59+
- windows-latest
60+
- ubuntu-latest
5461
terraform:
55-
- '0.12.31'
56-
- '0.13.7'
57-
- '0.14.11'
58-
- '0.15.1'
62+
- '0.12.*'
63+
- '0.13.*'
64+
- '0.14.*'
65+
- '0.15.*'
66+
- '1.0.*'
67+
- '1.1.*'
68+
- '1.2.*'
69+
- '1.3.*'
5970
steps:
6071

61-
- name: Check out code into the Go module directory
62-
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
72+
- name: Check out code
73+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
6374

64-
- name: Set up Go
65-
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
66-
with:
67-
go-version-file: 'go.mod'
68-
id: go
75+
- name: Setup Go
76+
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
77+
with:
78+
go-version-file: 'go.mod'
79+
check-latest: true
6980

70-
- name: TF acceptance tests
71-
timeout-minutes: 10
72-
env:
73-
TF_ACC: "1"
74-
TF_ACC_TERRAFORM_VERSION: ${{ matrix.terraform }}
75-
run: |
76-
go test -v -cover ./internal/provider/
81+
- name: Setup Terraform ${{ matrix.terraform }}
82+
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
83+
with:
84+
terraform_version: ${{ matrix.terraform }}
85+
terraform_wrapper: false
86+
87+
- name: Run acceptance test
88+
run: make testacc

.golangci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
linters:
2+
# Default linters enabled
3+
# See: https://golangci-lint.run/usage/linters/#enabled-by-default-linters
4+
5+
# Additional linters enabled
6+
enable:
7+
- durationcheck
8+
- exportloopref
9+
- godot
10+
- gofmt
11+
- makezero
12+
- misspell
13+
- nilerr
14+
- predeclared
15+
- tenv
16+
- unconvert
17+
- unparam
18+
19+
issues:
20+
max-issues-per-linter: 0
21+
max-same-issues: 0

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.3.0 (unreleased)
2+
3+
NOTES:
4+
5+
* Provider has been re-written using the new [`terraform-plugin-framework`](https://www.terraform.io/plugin/framework) ([#170](https://github.com/hashicorp/terraform-provider-archive/pull/170)).
6+
17
## 2.2.0 (May 04, 2021)
28

39
ENHANCEMENTS:

DESIGN.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Archive Provider Design
2+
3+
The Archive Provider offers focussed functionality specifically geared towards archiving files. Specifically,
4+
the provider data source generates zip archives of individual or multiple files.
5+
6+
Below we have a collection of _Goals_ and _Patterns_: they represent the guiding principles applied during the
7+
development of this provider. Some are in place, others are ongoing processes, others are still just inspirational.
8+
9+
## Goals
10+
11+
* [_Stability over features_](.github/CONTRIBUTING.md)
12+
* Provide data source for generating zip archives.
13+
14+
General to development:
15+
16+
* **Avoid repetition**: the entities managed can sometimes require similar pieces of logic and/or schema to be realised.
17+
When this happens it's important to keep the code shared in communal sections, so to avoid having to modify code in
18+
multiple places when they start changing.
19+
* **Test expectations as well as bugs**: While it's typical to write tests to exercise a new functionality, it's key to
20+
also provide tests for issues that get identified and fixed, so to prove resolution as well as avoid regression.
21+
* **Automate boring tasks**: Processes that are manual, repetitive and can be automated, should be. In addition to be a
22+
time-saving practice, this ensures consistency and reduces human error (ex. static code analysis).
23+
* **Semantic versioning**: Adhering to HashiCorp's own
24+
[Versioning Specification](https://www.terraform.io/plugin/sdkv2/best-practices/versioning#versioning-specification)
25+
ensures we provide a consistent practitioner experience, and a clear process to deprecation and decommission.

GNUmakefile

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,25 @@
1-
TEST?=$$(go list ./...)
2-
GOFMT_FILES?=$$(find . -name '*.go')
3-
PKG_NAME=archive
4-
51
default: build
62

7-
build: fmtcheck
8-
go install
3+
build:
4+
go build -v ./...
95

10-
test: fmtcheck
11-
go test -i $(TEST) || exit 1
12-
echo $(TEST) | \
13-
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
6+
install: build
7+
go install -v ./...
148

15-
testacc: fmtcheck
16-
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
9+
# See https://golangci-lint.run/
10+
lint:
11+
golangci-lint run
1712

18-
vet:
19-
@echo "go vet ."
20-
@go vet $$(go list ./...) ; if [ $$? -eq 1 ]; then \
21-
echo ""; \
22-
echo "Vet found suspicious constructs. Please check the reported constructs"; \
23-
echo "and fix them if necessary before submitting the code for review."; \
24-
exit 1; \
25-
fi
13+
generate:
14+
go generate ./...
2615

2716
fmt:
28-
gofmt -w $(GOFMT_FILES)
29-
30-
fmtcheck:
31-
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
32-
33-
errcheck:
34-
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
17+
gofmt -s -w -e .
3518

19+
test:
20+
go test -v -cover -timeout=120s -parallel=4 ./...
3621

37-
test-compile:
38-
@if [ "$(TEST)" = "./..." ]; then \
39-
echo "ERROR: Set TEST to a specific package. For example,"; \
40-
echo " make test-compile TEST=./$(PKG_NAME)"; \
41-
exit 1; \
42-
fi
43-
go test -c $(TEST) $(TESTARGS)
22+
testacc:
23+
TF_ACC=1 go test -v -cover -timeout 120m ./...
4424

45-
.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile
25+
.PHONY: build install lint generate fmt test testacc

0 commit comments

Comments
 (0)