Skip to content

Conversation

@WassimKallel
Copy link
Contributor

Scope

  • Added initial provider
  • Intended to be published as Think-iT-Labs/dirhash in Terraform registry
  • Templates for provider documentation were also added

Usage

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
}

@WassimKallel WassimKallel linked an issue Aug 29, 2022 that may be closed by this pull request
@WassimKallel WassimKallel self-assigned this Aug 29, 2022
Copy link

@NabilHouidi NabilHouidi left a comment

Choose a reason for hiding this comment

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

there's code that might cause a runtime panic

@WassimKallel WassimKallel force-pushed the 1-feat-add-initial-provider branch from 27d3a2c to 25676bf Compare September 5, 2022 00:30
ret = append(ret, "")
continue
if v != nil {
ret = append(ret, v.(string))

Choose a reason for hiding this comment

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

are we really sure that only interface of type string can reach here? failing that the code will panic.
example from go playground:

package main

import "fmt"

func main() {
	var d interface{}
	d = 45
	fmt.Println(d.(string))
}

when running the code above it panics:

panic: interface conversion: interface {} is int, not string

goroutine 1 [running]:
main.main()
	/tmp/sandbox615016875/prog.go:10 +0x2e

Program exited.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we are @NabilHouidi Terraform generates it that way based on the schema

docs/index.md Outdated
## Data Source "dirhash_sha256"

## Example Usage
As noted above, the Dirhash provider can calculate the checksum of a directory,

Choose a reason for hiding this comment

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

there's still a calculate here

Copy link
Member

@Nazdroth Nazdroth left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

@NabilHouidi NabilHouidi left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@WassimKallel WassimKallel merged commit 18b65a6 into main Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Add initial provider

5 participants