-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
41 lines (35 loc) · 1.01 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"context"
"flag"
"fmt"
"log"
"os"
tfapstra "github.com/Juniper/terraform-provider-apstra/apstra"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
)
func main() {
var debug bool
var printVersion bool
flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.BoolVar(&printVersion, "version", false, "print version and exit")
flag.Parse()
if printVersion {
p := tfapstra.NewProvider()
mdr := provider.MetadataResponse{}
p.Metadata(context.Background(), provider.MetadataRequest{}, &mdr)
_, err := os.Stdout.WriteString(fmt.Sprintf("terraform-provider-%s %s\n", mdr.TypeName, mdr.Version))
if err != nil {
log.Fatal(err)
}
os.Exit(0)
}
err := providerserver.Serve(context.Background(), tfapstra.NewProvider, providerserver.ServeOpts{
Address: "registry.terraform.io/Juniper/apstra",
Debug: debug,
})
if err != nil {
log.Fatal(err)
}
}