forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
child_id.go
35 lines (27 loc) · 989 Bytes
/
child_id.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
package validate
import (
"fmt"
"github.com/kevinklinger/terraform-provider-azurerm/v2/internal/services/keyvault/parse"
)
func KeyVaultChildID(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 warnings, errors
}
if _, err := parse.ParseNestedItemID(v); err != nil {
errors = append(errors, fmt.Errorf("can not parse %q as a Key Vault Child resource id: %v", k, err))
}
return warnings, errors
}
func KeyVaultChildIDWithOptionalVersion(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 warnings, errors
}
if _, err := parse.ParseOptionallyVersionedNestedItemID(v); err != nil {
errors = append(errors, fmt.Errorf("can not parse %q as a Key Vault Child resource id: %v", k, err))
}
return warnings, errors
}