-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.go
45 lines (36 loc) · 843 Bytes
/
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
package main
import (
"flag"
"fmt"
"os"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"github.com/joho/godotenv"
"github.com/twilio/terraform-provider-twilio/twilio"
)
func main() {
var debugMode bool
flag.BoolVar(&debugMode, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse()
if fileExists("./conf/.env") {
err := godotenv.Load(`./conf/.env`)
if err != nil {
_ = fmt.Errorf("error on loading env %s", err)
os.Exit(-1)
}
}
opts := &plugin.ServeOpts{
ProviderFunc: twilio.Provider,
}
if debugMode {
opts.Debug = debugMode
opts.ProviderAddr = "registry.terraform.io/twilio/twilio"
}
plugin.Serve(opts)
}
func fileExists(filename string) bool {
info, err := os.Stat(filename)
if os.IsNotExist(err) {
return false
}
return !info.IsDir()
}