Skip to content
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
40 changes: 0 additions & 40 deletions .github/workflows/add-content-to-project.yml

This file was deleted.

83 changes: 24 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,29 @@
# Terraform Provider Scaffolding (Terraform Plugin SDK)
# Dirhash
Computing the checksum of a directory made easy.

_This template repository is built on the [Terraform Plugin SDK](https://github.com/hashicorp/terraform-plugin-sdk). The template repository built on the [Terraform Plugin Framework](https://github.com/hashicorp/terraform-plugin-framework) can be found at [terraform-provider-scaffolding-framework](https://github.com/hashicorp/terraform-provider-scaffolding-framework). See [Which SDK Should I Use?](https://www.terraform.io/docs/plugin/which-sdk.html) in the Terraform documentation for additional information._
## Dirhash Provider
Dirhash was created to compute the checksum of a directory,
a useful provider if you try to make Terraform react and make changes
based on whether changes have been made inside a directory or not.

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:

- A resource, and a data source (`internal/provider/`),
- Examples (`examples/`) and generated documentation (`docs/`),
- Miscellaneous meta files.

These files contain boilerplate code that you will need to edit to create your own Terraform provider. Tutorials for creating Terraform providers can be found on the [HashiCorp Learn](https://learn.hashicorp.com/collections/terraform/providers) platform.

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.

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.


## Requirements

- [Terraform](https://www.terraform.io/downloads.html) >= 0.13.x
- [Go](https://golang.org/doc/install) >= 1.18

## Building The Provider

1. Clone the repository
1. Enter the repository directory
1. Build the provider using the Go `install` command:
```sh
$ go install
```

## Adding Dependencies

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

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

### Usage
As noted above, the Dirhash provider can compute the checksum of a directory,
the data_source `dirhash_sha256` can be used to retrieve the SHA256 of a directory.
For example:
```terraform
provider "dirhash" {}
```
go get github.com/author/dependency
go mod tidy
```

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

## Using the provider

Fill this in for each provider

## Developing the Provider

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

To compile the provider, run `go install`. This will build the provider and put the provider binary in the `$GOPATH/bin` directory.

To generate or update documentation, run `go generate`.

In order to run the full suite of Acceptance tests, run `make testacc`.

*Note:* Acceptance tests create real resources, and often cost money to run.

```sh
$ make testacc
```terraform
data "dirhash_sha256" "example" {
directory = "/path/to/directory"
ignore = [
"glob_pattern_1/*",
"glob_pattern_2/*"
]
}
output "directory_sha256_checksum" {
description = "the Output SHA256 Checksum for the directory"
value = data.dirhash_sha256.example.checksum
}
```
32 changes: 0 additions & 32 deletions docs/data-sources/data_source.md

This file was deleted.

46 changes: 46 additions & 0 deletions docs/data-sources/sha256.md
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: "dirhash_sha256 Data Source - terraform-provider-dirhash"
subcategory: ""
description: |-
Compute SHA256 checksum of a given directory
---

# dirhash_sha256 (Data Source)

Compute SHA256 checksum of a given directory

## Example Usage

```terraform
data "dirhash_sha256" "example" {
directory = "/path/to/directory"
ignore = [
"glob_pattern_1/*",
"glob_pattern_2/*"
]
}

output "directory_sha256_checksum" {
description = "the Output SHA256 Checksum for the directory"
value = data.dirhash_sha256.example.checksum
}
```

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

### Required

- `directory` (String) Directory to hash.

### Optional

- `ignore` (List of String) List of ignored glob patterns.

### Read-Only

- `checksum` (String) Directory SHA 256 Checksum
- `id` (String) The ID of this resource.


36 changes: 25 additions & 11 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "scaffolding Provider"
subcategory: ""
page_title: "Provider: Dirhash"
description: |-

Compute checksum for a given directory
---

# scaffolding Provider
# Dirhash Provider

Dirhash was created to compute the checksum of a directory,
a useful provider if you try to make Terraform react and make changes
based on whether changes have been made inside a directory or not.

## Data Source "dirhash_sha256"

## Example Usage
As noted above, the Dirhash provider can compute the checksum of a directory,
the data_source `dirhash_sha256` can be used to retrieve the SHA256 of a directory.

For example:

```terraform
provider "scaffolding" {
# example configuration here
}
provider "dirhash" {}
```
```terraform
data "dirhash_sha256" "example" {
directory = "/path/to/directory"
ignore = [
"glob_pattern_1/*",
"glob_pattern_2/*"
]
}

<!-- schema generated by tfplugindocs -->
## Schema
output "directory_sha256_checksum" {
description = "the Output SHA256 Checksum for the directory"
value = data.dirhash_sha256.example.checksum
}
```
32 changes: 0 additions & 32 deletions docs/resources/resource.md

This file was deleted.

12 changes: 12 additions & 0 deletions examples/data-sources/dirhash_sha256/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
data "dirhash_sha256" "example" {
directory = "/path/to/directory"
ignore = [
"glob_pattern_1/*",
"glob_pattern_2/*"
]
}

output "directory_sha256_checksum" {
description = "the Output SHA256 Checksum for the directory"
value = data.dirhash_sha256.example.checksum
}
3 changes: 0 additions & 3 deletions examples/data-sources/scaffolding_data_source/data-source.tf

This file was deleted.

4 changes: 1 addition & 3 deletions examples/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
provider "scaffolding" {
# example configuration here
}
provider "dirhash" {}
3 changes: 0 additions & 3 deletions examples/resources/scaffolding_resource/resource.tf

This file was deleted.

11 changes: 7 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/hashicorp/terraform-provider-scaffolding
module github.com/Think-iT-Labs/terraform-provider-dirhash

go 1.18

require (
github.com/Think-iT-Labs/dirhash v0.0.0-20220829165605-3bdeb9ee2c90
github.com/hashicorp/terraform-plugin-docs v0.13.0
Comment on lines +1 to 7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind reminder to run go mod tidy, just in case there are extra dependencies ;)

github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.21.0
)

Expand All @@ -16,7 +16,7 @@ require (
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/bmatcuk/doublestar v1.3.4 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.8 // indirect
Expand All @@ -36,6 +36,7 @@ require (
github.com/hashicorp/terraform-exec v0.17.2 // indirect
github.com/hashicorp/terraform-json v0.14.0 // indirect
github.com/hashicorp/terraform-plugin-go v0.14.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.7.0 // indirect
github.com/hashicorp/terraform-registry-address v0.0.0-20220623143253-7d51757b572c // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
Expand All @@ -53,14 +54,16 @@ require (
github.com/posener/complete v1.2.3 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
github.com/zclconf/go-cty v1.10.0 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
Expand Down
Loading