/
iap_tunnel_instance_iam.go
123 lines (104 loc) · 4.13 KB
/
iap_tunnel_instance_iam.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** Type: MMv1 ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google
import "fmt"
// Provide a separate asset type constant so we don't have to worry about name conflicts between IAM and non-IAM converter files
const IapTunnelInstanceIAMAssetType string = "iap.googleapis.com/TunnelInstance"
func resourceConverterIapTunnelInstanceIamPolicy() ResourceConverter {
return ResourceConverter{
AssetType: IapTunnelInstanceIAMAssetType,
Convert: GetIapTunnelInstanceIamPolicyCaiObject,
MergeCreateUpdate: MergeIapTunnelInstanceIamPolicy,
}
}
func resourceConverterIapTunnelInstanceIamBinding() ResourceConverter {
return ResourceConverter{
AssetType: IapTunnelInstanceIAMAssetType,
Convert: GetIapTunnelInstanceIamBindingCaiObject,
FetchFullResource: FetchIapTunnelInstanceIamPolicy,
MergeCreateUpdate: MergeIapTunnelInstanceIamBinding,
MergeDelete: MergeIapTunnelInstanceIamBindingDelete,
}
}
func resourceConverterIapTunnelInstanceIamMember() ResourceConverter {
return ResourceConverter{
AssetType: IapTunnelInstanceIAMAssetType,
Convert: GetIapTunnelInstanceIamMemberCaiObject,
FetchFullResource: FetchIapTunnelInstanceIamPolicy,
MergeCreateUpdate: MergeIapTunnelInstanceIamMember,
MergeDelete: MergeIapTunnelInstanceIamMemberDelete,
}
}
func GetIapTunnelInstanceIamPolicyCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) {
return newIapTunnelInstanceIamAsset(d, config, expandIamPolicyBindings)
}
func GetIapTunnelInstanceIamBindingCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) {
return newIapTunnelInstanceIamAsset(d, config, expandIamRoleBindings)
}
func GetIapTunnelInstanceIamMemberCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) {
return newIapTunnelInstanceIamAsset(d, config, expandIamMemberBindings)
}
func MergeIapTunnelInstanceIamPolicy(existing, incoming Asset) Asset {
existing.IAMPolicy = incoming.IAMPolicy
return existing
}
func MergeIapTunnelInstanceIamBinding(existing, incoming Asset) Asset {
return mergeIamAssets(existing, incoming, mergeAuthoritativeBindings)
}
func MergeIapTunnelInstanceIamBindingDelete(existing, incoming Asset) Asset {
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAuthoritativeBindings)
}
func MergeIapTunnelInstanceIamMember(existing, incoming Asset) Asset {
return mergeIamAssets(existing, incoming, mergeAdditiveBindings)
}
func MergeIapTunnelInstanceIamMemberDelete(existing, incoming Asset) Asset {
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAdditiveBindings)
}
func newIapTunnelInstanceIamAsset(
d TerraformResourceData,
config *Config,
expandBindings func(d TerraformResourceData) ([]IAMBinding, error),
) ([]Asset, error) {
bindings, err := expandBindings(d)
if err != nil {
return []Asset{}, fmt.Errorf("expanding bindings: %v", err)
}
name, err := assetName(d, config, "//iap.googleapis.com/projects/{{project}}/iap_tunnel/zones/{{zone}}/instances/{{instance}}")
if err != nil {
return []Asset{}, err
}
return []Asset{{
Name: name,
Type: IapTunnelInstanceIAMAssetType,
IAMPolicy: &IAMPolicy{
Bindings: bindings,
},
}}, nil
}
func FetchIapTunnelInstanceIamPolicy(d TerraformResourceData, config *Config) (Asset, error) {
// Check if the identity field returns a value
if _, ok := d.GetOk("zone"); !ok {
return Asset{}, ErrEmptyIdentityField
}
if _, ok := d.GetOk("instance"); !ok {
return Asset{}, ErrEmptyIdentityField
}
return fetchIamPolicy(
IapTunnelInstanceIamUpdaterProducer,
d,
config,
"//iap.googleapis.com/projects/{{project}}/iap_tunnel/zones/{{zone}}/instances/{{instance}}",
IapTunnelInstanceIAMAssetType,
)
}