terraformterraform0.12+terraform-provider

How can I specify my own Terraform provider as a source to generate documentation


I am currently attempting to generate the documentation for my Terraform provider, but it always tries to get "registry.terraform.io/hashicorp/pterodactyl v0.0.1". My provider is already on the registry, but I don't know how to specify the origin. I set the name as a command arg, but it still has the wrong version and "creator". I attempted to change the url in the main.go, in my go.mod, I searched through GitHub repos using tfplugindocs as well as forks of the hashicorp repo for their example hashicups provider.

The error:

Error executing command: unable to generate website: error exporting provider schema from Terraform: unable to run terraform init on provider: exit status 1

Error: Incompatible provider version

Provider registry.terraform.io/hashicorp/pterodactyl v0.0.1 does not have a
package available for your current platform, windows_386.

Provider releases are separate from Terraform CLI releases, so not all
providers are available for all platforms. Other versions of this provider
may have different platforms supported.

My main.go is

package main

import (
    "context"
    "flag"
    "log"

    "github.com/hashicorp/terraform-plugin-framework/providerserver"

    "terraform-provider-pterodactyl/internal/provider"
)

// Run "go generate" to format example terraform files and generate the docs for the registry/website

// If you do not have terraform installed, you can remove the formatting command, but its suggested to
// ensure the documentation is formatted properly.
//go:generate terraform fmt -recursive ./examples/

// Run the docs generation tool, check its repository for more information on how it works and how docs
// can be customized.
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate -provider-name pterodactyl

var (
    // these will be set by the goreleaser configuration
    // to appropriate values for the compiled binary.
    version string = "dev"
)

func main() {
    var debug bool

    flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
    flag.Parse()

    opts := providerserver.ServeOpts{
        Address: "registry.terraform.io/Luiggi33/pterodactyl",
        Debug:   debug,
    }

    err := providerserver.Serve(context.Background(), provider.New(version), opts)

    if err != nil {
        log.Fatal(err.Error())
    }
}

If any other files are needed, I can provide them


Solution

  • As pointed out by @MartinAtkins, https://github.com/hashicorp/terraform-plugin-docs/issues/141 solves this.

    You just need have the same arch for golang and Terraform (in my case amd64)