-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathmain.go
40 lines (31 loc) · 1000 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
package main
import (
"github.com/dikhan/terraform-provider-openapi/v3/openapi"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"log"
"os"
)
const ProviderName = "instaclustr"
func main() {
providerHost := os.Getenv("IC_API_URL") //needed to target locally run API to generate docs for testing/preview
if len(providerHost) == 0 {
providerHost = "https://api.instaclustr.com"
}
providerOpenAPIURL := providerHost + "/cluster-management/v2/swagger-for-terraform.yaml"
p := openapi.ProviderOpenAPI{ProviderName: ProviderName}
serviceProviderConfig := &openapi.ServiceConfigV1{
SwaggerURL: providerOpenAPIURL,
}
provider, err := p.CreateSchemaProviderFromServiceConfiguration(serviceProviderConfig)
if err != nil {
log.Fatalf("[ERROR] Failed to initialize the terraform provider: %s", err)
}
plugin.Serve(
&plugin.ServeOpts{
ProviderFunc: func() *schema.Provider {
return provider
},
},
)
}