terraform: fix
This commit is contained in:
parent
bbfefefe3c
commit
ce8c3c8a56
|
@ -31,6 +31,7 @@ func provider() terraform.ResourceProvider {
|
|||
"host": &schema.Schema{
|
||||
Type: schema.TypeString,
|
||||
Optional: false,
|
||||
Required: true,
|
||||
DefaultFunc: schema.EnvDefaultFunc("ROUTE_HOST", nil),
|
||||
},
|
||||
"verify_tls": &schema.Schema{
|
||||
|
|
|
@ -13,15 +13,16 @@ func routeResource() *schema.Resource {
|
|||
Create: resourceRouteCreate,
|
||||
Read: resourceRouteRead,
|
||||
Delete: resourceRouteDelete,
|
||||
Exists: resourceRouteExists,
|
||||
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"domain": {
|
||||
"host": {
|
||||
Type: schema.TypeString,
|
||||
Required: false,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
|
@ -32,7 +33,7 @@ func resourceRouteCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
cli := meta.(proto.RoutesClient)
|
||||
|
||||
rt, err := cli.Put(context.Background(), &proto.Route{
|
||||
Host: d.Get("domain").(string),
|
||||
Host: d.Get("host").(string),
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
@ -62,6 +63,17 @@ func resourceRouteDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func resourceRouteExists(d *schema.ResourceData, meta interface{}) (bool, error) {
|
||||
cli := meta.(proto.RoutesClient)
|
||||
|
||||
_, err := cli.Get(context.Background(), &proto.GetRouteRequest{Id: d.Id()})
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func resourceRouteRead(d *schema.ResourceData, meta interface{}) error {
|
||||
cli := meta.(proto.RoutesClient)
|
||||
|
||||
|
|
Loading…
Reference in New Issue