-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
76 changed files
with
14,711 additions
and
305 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
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 |
---|---|---|
@@ -1,14 +1,144 @@ | ||
package azure | ||
|
||
import ( | ||
"regexp" | ||
|
||
"github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl" | ||
"github.com/hashicorp/terraform/helper/schema" | ||
"github.com/hashicorp/terraform/helper/validation" | ||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" | ||
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" | ||
) | ||
|
||
func ValidateDevTestLabName() schema.SchemaValidateFunc { | ||
return validation.StringMatch( | ||
regexp.MustCompile("^[A-Za-z0-9_-]+$"), | ||
"Lab Name can only include alphanumeric characters, underscores, hyphens.") | ||
func SchemaDevTestVirtualMachineInboundNatRule() *schema.Schema { | ||
return &schema.Schema{ | ||
Type: schema.TypeSet, | ||
Optional: true, | ||
// since these aren't returned from the API | ||
ForceNew: true, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"protocol": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ValidateFunc: validation.StringInSlice([]string{ | ||
string(dtl.TCP), | ||
string(dtl.UDP), | ||
}, false), | ||
}, | ||
|
||
"backend_port": { | ||
Type: schema.TypeInt, | ||
Required: true, | ||
ForceNew: true, | ||
ValidateFunc: validate.PortNumber, | ||
}, | ||
|
||
"frontend_port": { | ||
Type: schema.TypeInt, | ||
Computed: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func ExpandDevTestLabVirtualMachineNatRules(input *schema.Set) []dtl.InboundNatRule { | ||
rules := make([]dtl.InboundNatRule, 0) | ||
if input == nil { | ||
return rules | ||
} | ||
|
||
for _, val := range input.List() { | ||
v := val.(map[string]interface{}) | ||
backendPort := v["backend_port"].(int) | ||
protocol := v["protocol"].(string) | ||
|
||
rule := dtl.InboundNatRule{ | ||
TransportProtocol: dtl.TransportProtocol(protocol), | ||
BackendPort: utils.Int32(int32(backendPort)), | ||
} | ||
|
||
rules = append(rules, rule) | ||
} | ||
|
||
return rules | ||
} | ||
|
||
func ExpandDevTestLabVirtualMachineGalleryImageReference(input []interface{}, osType string) *dtl.GalleryImageReference { | ||
if len(input) == 0 { | ||
return nil | ||
} | ||
|
||
v := input[0].(map[string]interface{}) | ||
offer := v["offer"].(string) | ||
publisher := v["publisher"].(string) | ||
sku := v["sku"].(string) | ||
version := v["version"].(string) | ||
|
||
return &dtl.GalleryImageReference{ | ||
Offer: utils.String(offer), | ||
OsType: utils.String(osType), | ||
Publisher: utils.String(publisher), | ||
Sku: utils.String(sku), | ||
Version: utils.String(version), | ||
} | ||
} | ||
|
||
func SchemaDevTestVirtualMachineGalleryImageReference() *schema.Schema { | ||
return &schema.Schema{ | ||
Type: schema.TypeList, | ||
Required: true, | ||
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"offer": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
"publisher": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
"sku": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
"version": { | ||
Type: schema.TypeString, | ||
Required: true, | ||
ForceNew: true, | ||
}, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func FlattenDevTestVirtualMachineGalleryImage(input *dtl.GalleryImageReference) []interface{} { | ||
results := make([]interface{}, 0) | ||
|
||
if input != nil { | ||
output := make(map[string]interface{}, 0) | ||
|
||
if input.Offer != nil { | ||
output["offer"] = *input.Offer | ||
} | ||
|
||
if input.Publisher != nil { | ||
output["publisher"] = *input.Publisher | ||
} | ||
|
||
if input.Sku != nil { | ||
output["sku"] = *input.Sku | ||
} | ||
|
||
if input.Version != nil { | ||
output["version"] = *input.Version | ||
} | ||
|
||
results = append(results, output) | ||
} | ||
|
||
return results | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.