forked from nrgribeiro/terraform-provider-iis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: application pool with managed runtime
- Loading branch information
Showing
8 changed files
with
140 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/maxjoehnk/terraform-provider-iis | ||
module github.com/nrgribeiro/terraform-provider-iis | ||
|
||
go 1.15 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package iis | ||
|
||
import ( | ||
"context" | ||
"github.com/nrgribeiro/microsoft-iis-administration" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/diag" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
const fileNameKey = "name" | ||
const filePhysicalPathKey = "physical_path" | ||
const typeKey = "type" | ||
const parentKey = "parent" | ||
|
||
func resourceFile() *schema.Resource { | ||
return &schema.Resource{ | ||
CreateContext: resourceFileCreate, | ||
ReadContext: resourceFileRead, | ||
UpdateContext: resourceFileUpdate, | ||
DeleteContext: resourceFileDelete, | ||
|
||
Schema: map[string]*schema.Schema{ | ||
fileNameKey: { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
filePhysicalPathKey: { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
typeKey: { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
parentKey: { | ||
Type: schema.TypeString, | ||
Required: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func resourceFileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
client := m.(*iis.Client) | ||
request := createFileRequest(d) | ||
site, err := client.CreateFile(ctx, request) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
d.SetId(site.ID) | ||
return nil | ||
} | ||
|
||
func resourceFileRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
client := m.(*iis.Client) | ||
site, err := client.ReadFile(ctx, d.Id()) | ||
if err != nil { | ||
d.SetId("") | ||
return diag.FromErr(err) | ||
} | ||
if err = d.Set(nameKey, site.Name); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
if err = d.Set(physicalPathKey, site.PhysicalPath); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
if err = d.Set(typeKey, site.Type); err != nil { | ||
return diag.FromErr(err) | ||
} | ||
return nil | ||
} | ||
|
||
func resourceFileUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
return nil | ||
} | ||
|
||
func resourceFileDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { | ||
client := m.(*iis.Client) | ||
id := d.Id() | ||
err := client.DeleteFile(ctx, id) | ||
if err != nil { | ||
return diag.FromErr(err) | ||
} | ||
return nil | ||
} | ||
|
||
func createFileRequest(d *schema.ResourceData) iis.CreateFileRequest { | ||
name := d.Get(nameKey).(string) | ||
physicalPath := d.Get(physicalPathKey).(string) | ||
parentId := d.Get(parentKey).(string) | ||
typeName := d.Get(typeKey).(string) | ||
request := iis.CreateFileRequest{ | ||
Name: name, | ||
PhysicalPath: physicalPath, | ||
Parent: iis.FileParent{ | ||
Id: parentId, | ||
}, | ||
Type: typeName, | ||
} | ||
|
||
return request | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters