Terraform provider to sync config for Wiki.js
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
install
command:
$ go install # builds binary to $GOPATH/bin and does some package caching stuff
This provider uses Go 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:
$ go get github.com/author/dependency
$ go mod tidy # ensures go.mod file is in sync with source code dependencies
$ go mod vendor # downloads dependencies to 'vendor' folder
Then commit the changes to go.mod
and go.sum
.
- Resources/Data Sources go into /wikijs
- Schema such as wikijs types go into /wikijs/schema. These schema are needed to make graphql requests.
- Set WIKIJS_HOST and WIKIJS_TOKEN in env
- In root directory,
make testacc
to run acceptance tests in all */*_test.go files. - To try out on actual terraform:
- In root directory, run
make
, which builds the binary and moves it to the path that terraform looks in - in examples/test, run
terraform init && terraform plan
to view output. Change thetest.tf
file accordingly.
- In root directory, run
This provider syncs config via the Wikijs graphql API. The majority of the provider is powered by a graphql library which converts Go structs into graphql requests.
Note that when defining structs where it's variables will be used to form the request, you can use JSON tags to convert the variables from uppercase to lowercase. The necessity for this is because the variables need to be uppercase in order for the JSON encoding library to work (public vs private in Go), but need to be lowercase when sent in the graphql request. For example:
type PageRuleInput struct {
Id gqlc.String `json:"id"`
Deny gqlc.Boolean `json:"deny"`
}
If you wish to work on the provider, you'll first need Go installed on your machine (see 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. In this case, API calls will be made to the WIKIJS_HOST provided. The created resources will still ultimately be deleted if the tests exit successfully.