forked from databricks/terraform-provider-databricks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
59 lines (48 loc) · 1.33 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/databricks/terraform-provider-databricks/common"
"github.com/databricks/terraform-provider-databricks/exporter"
"github.com/databricks/terraform-provider-databricks/internal/providers"
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server"
)
const startMessageFormat = `Databricks Terraform Provider
Version %s
https://registry.terraform.io/providers/databricks/databricks/latest/docs
`
func main() {
log.SetFlags(0)
if len(os.Args) > 1 && os.Args[1] == "version" {
fmt.Println(common.Version())
return
}
if len(os.Args) > 1 && os.Args[1] == "exporter" {
if err := exporter.Run(os.Args...); err != nil {
log.Printf("[ERROR] %s", err.Error())
os.Exit(1)
}
return
}
log.Printf(startMessageFormat, common.Version())
ctx := context.Background()
providerServer, err := providers.GetProviderServer(ctx)
if err != nil {
log.Fatal(err)
}
var serveOpts []tf6server.ServeOpt
if len(os.Args) > 1 && os.Args[1] == "debug" { // debug mode
serveOpts = append(serveOpts, tf6server.WithManagedDebug())
}
err = tf6server.Serve(
"registry.terraform.io/databricks/databricks",
func() tfprotov6.ProviderServer { return providerServer },
serveOpts...,
)
if err != nil {
log.Fatal(err)
}
}