mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-23 04:18:47 +00:00
feat: Add Terraform provider main entry point with schema definition and resource/data source registration
- Add main function with plugin.Serve to initialize Terraform provider plugin - Add Provider function returning schema.Provider with api_url and api_key configuration - Add api_url schema with TELECOM_API_URL environment variable fallback to http://localhost:8000 - Add api_key schema with TELECOM_API_KEY environment variable, marked as sensitive and optional - Register resources: telecom_subscriber and
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
||||||
|
"github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
plugin.Serve(&plugin.ServeOpts{
|
||||||
|
ProviderFunc: Provider,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func Provider() *schema.Provider {
|
||||||
|
return &schema.Provider{
|
||||||
|
Schema: map[string]*schema.Schema{
|
||||||
|
"api_url": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Required: true,
|
||||||
|
DefaultFunc: schema.EnvDefaultFunc("TELECOM_API_URL", "http://localhost:8000"),
|
||||||
|
Description: "The base URL of the Telecom API server.",
|
||||||
|
},
|
||||||
|
"api_key": {
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Sensitive: true,
|
||||||
|
DefaultFunc: schema.EnvDefaultFunc("TELECOM_API_KEY", nil),
|
||||||
|
Description: "API key for authenticating with the Telecom API.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ResourcesMap: map[string]*schema.Resource{
|
||||||
|
"telecom_subscriber": resourceSubscriber(),
|
||||||
|
"telecom_rating_plan": resourceRatingPlan(),
|
||||||
|
},
|
||||||
|
DataSourcesMap: map[string]*schema.Resource{
|
||||||
|
"telecom_subscriber": dataSourceSubscriber(),
|
||||||
|
"telecom_system_stats": dataSourceSystemStats(),
|
||||||
|
},
|
||||||
|
ConfigureContextFunc: providerConfigure,
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user