/
app_service_hybrid_connection.go
52 lines (41 loc) · 1.33 KB
/
app_service_hybrid_connection.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
41
42
43
44
45
46
47
48
49
50
51
52
package web
import (
"fmt"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure"
)
type AppServiceHybridConnectionResourceID struct {
ResourceGroup string
Name string
AppName string
Namespace string
}
func ParseAppServiceHybridConnectionID(input string) (*AppServiceHybridConnectionResourceID, error) {
id, err := azure.ParseAzureResourceID(input)
if err != nil {
return nil, fmt.Errorf("[ERROR] Unable to parse Hybrid Connection ID %q: %+v", input, err)
}
hybridConnection := AppServiceHybridConnectionResourceID{
ResourceGroup: id.ResourceGroup,
}
if hybridConnection.Name, err = id.PopSegment("relays"); err != nil {
return nil, err
}
if hybridConnection.AppName, err = id.PopSegment("sites"); err != nil {
return nil, err
}
if hybridConnection.Namespace, err = id.PopSegment("hybridConnectionNamespaces"); err != nil {
return nil, err
}
return &hybridConnection, nil
}
func ValidateAppServiceHybridConnectionID(i interface{}, k string) (warnings []string, errors []error) {
v, ok := i.(string)
if !ok {
errors = append(errors, fmt.Errorf("expected type of %q to be string", k))
return
}
if _, err := ParseAppServiceHybridConnectionID(v); err != nil {
errors = append(errors, fmt.Errorf("Can not parse %q as a resource id: %v", k, err))
}
return warnings, errors
}