-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* magic module IAM support * Fixes as suggested from GoogleCloudPlatform/magic-modules#4878 * Fixed Duplicate Function Names * Fixed Incorrect New IAM function generation * Fixed Merge Function Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
a6d0210
commit ecaeaac
Showing
29 changed files
with
2,519 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// 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" | ||
|
||
func GetBigQueryTableIamPolicyCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newBigQueryTableIamAsset(d, config, expandIamPolicyBindings) | ||
} | ||
|
||
func GetBigQueryTableIamBindingCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newBigQueryTableIamAsset(d, config, expandIamRoleBindings) | ||
} | ||
|
||
func GetBigQueryTableIamMemberCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newBigQueryTableIamAsset(d, config, expandIamMemberBindings) | ||
} | ||
|
||
func MergeBigQueryTableIamPolicy(existing, incoming Asset) Asset { | ||
existing.IAMPolicy = incoming.IAMPolicy | ||
return existing | ||
} | ||
|
||
func MergeBigQueryTableIamBinding(existing, incoming Asset) Asset { | ||
return mergeIamAssets(existing, incoming, mergeAuthoritativeBindings) | ||
} | ||
|
||
func MergeBigQueryTableIamBindingDelete(existing, incoming Asset) Asset { | ||
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAuthoritativeBindings) | ||
} | ||
|
||
func MergeBigQueryTableIamMember(existing, incoming Asset) Asset { | ||
return mergeIamAssets(existing, incoming, mergeAdditiveBindings) | ||
} | ||
|
||
func MergeBigQueryTableIamMemberDelete(existing, incoming Asset) Asset { | ||
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAdditiveBindings) | ||
} | ||
|
||
func newBigQueryTableIamAsset( | ||
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, "//bigquery.googleapis.com/{{table}}") | ||
if err != nil { | ||
return []Asset{}, err | ||
} | ||
|
||
return []Asset{{ | ||
Name: name, | ||
Type: "bigquery.googleapis.com/Table", | ||
IAMPolicy: &IAMPolicy{ | ||
Bindings: bindings, | ||
}, | ||
}}, nil | ||
} | ||
|
||
func FetchBigQueryTableIamPolicy(d TerraformResourceData, config *Config) (Asset, error) { | ||
// Check if the identity field returns a value | ||
if _, ok := d.GetOk("{{table}}"); !ok { | ||
return Asset{}, ErrEmptyIdentityField | ||
} | ||
|
||
return fetchIamPolicy( | ||
BigQueryTableIamUpdaterProducer, | ||
d, | ||
config, | ||
"//bigquery.googleapis.com/{{table}}", | ||
"bigquery.googleapis.com/Table", | ||
) | ||
} |
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,89 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// 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" | ||
|
||
func GetBinaryAuthorizationAttestorIamPolicyCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newBinaryAuthorizationAttestorIamAsset(d, config, expandIamPolicyBindings) | ||
} | ||
|
||
func GetBinaryAuthorizationAttestorIamBindingCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newBinaryAuthorizationAttestorIamAsset(d, config, expandIamRoleBindings) | ||
} | ||
|
||
func GetBinaryAuthorizationAttestorIamMemberCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newBinaryAuthorizationAttestorIamAsset(d, config, expandIamMemberBindings) | ||
} | ||
|
||
func MergeBinaryAuthorizationAttestorIamPolicy(existing, incoming Asset) Asset { | ||
existing.IAMPolicy = incoming.IAMPolicy | ||
return existing | ||
} | ||
|
||
func MergeBinaryAuthorizationAttestorIamBinding(existing, incoming Asset) Asset { | ||
return mergeIamAssets(existing, incoming, mergeAuthoritativeBindings) | ||
} | ||
|
||
func MergeBinaryAuthorizationAttestorIamBindingDelete(existing, incoming Asset) Asset { | ||
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAuthoritativeBindings) | ||
} | ||
|
||
func MergeBinaryAuthorizationAttestorIamMember(existing, incoming Asset) Asset { | ||
return mergeIamAssets(existing, incoming, mergeAdditiveBindings) | ||
} | ||
|
||
func MergeBinaryAuthorizationAttestorIamMemberDelete(existing, incoming Asset) Asset { | ||
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAdditiveBindings) | ||
} | ||
|
||
func newBinaryAuthorizationAttestorIamAsset( | ||
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, "//binaryauthorization.googleapis.com/{{attestor}}") | ||
if err != nil { | ||
return []Asset{}, err | ||
} | ||
|
||
return []Asset{{ | ||
Name: name, | ||
Type: "binaryauthorization.googleapis.com/Attestor", | ||
IAMPolicy: &IAMPolicy{ | ||
Bindings: bindings, | ||
}, | ||
}}, nil | ||
} | ||
|
||
func FetchBinaryAuthorizationAttestorIamPolicy(d TerraformResourceData, config *Config) (Asset, error) { | ||
// Check if the identity field returns a value | ||
if _, ok := d.GetOk("{{attestor}}"); !ok { | ||
return Asset{}, ErrEmptyIdentityField | ||
} | ||
|
||
return fetchIamPolicy( | ||
BinaryAuthorizationAttestorIamUpdaterProducer, | ||
d, | ||
config, | ||
"//binaryauthorization.googleapis.com/{{attestor}}", | ||
"binaryauthorization.googleapis.com/Attestor", | ||
) | ||
} |
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,89 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// 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" | ||
|
||
func GetCloudFunctionsCloudFunctionIamPolicyCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newCloudFunctionsCloudFunctionIamAsset(d, config, expandIamPolicyBindings) | ||
} | ||
|
||
func GetCloudFunctionsCloudFunctionIamBindingCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newCloudFunctionsCloudFunctionIamAsset(d, config, expandIamRoleBindings) | ||
} | ||
|
||
func GetCloudFunctionsCloudFunctionIamMemberCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newCloudFunctionsCloudFunctionIamAsset(d, config, expandIamMemberBindings) | ||
} | ||
|
||
func MergeCloudFunctionsCloudFunctionIamPolicy(existing, incoming Asset) Asset { | ||
existing.IAMPolicy = incoming.IAMPolicy | ||
return existing | ||
} | ||
|
||
func MergeCloudFunctionsCloudFunctionIamBinding(existing, incoming Asset) Asset { | ||
return mergeIamAssets(existing, incoming, mergeAuthoritativeBindings) | ||
} | ||
|
||
func MergeCloudFunctionsCloudFunctionIamBindingDelete(existing, incoming Asset) Asset { | ||
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAuthoritativeBindings) | ||
} | ||
|
||
func MergeCloudFunctionsCloudFunctionIamMember(existing, incoming Asset) Asset { | ||
return mergeIamAssets(existing, incoming, mergeAdditiveBindings) | ||
} | ||
|
||
func MergeCloudFunctionsCloudFunctionIamMemberDelete(existing, incoming Asset) Asset { | ||
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAdditiveBindings) | ||
} | ||
|
||
func newCloudFunctionsCloudFunctionIamAsset( | ||
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, "//cloudfunctions.googleapis.com/{{cloudfunction}}") | ||
if err != nil { | ||
return []Asset{}, err | ||
} | ||
|
||
return []Asset{{ | ||
Name: name, | ||
Type: "cloudfunctions.googleapis.com/CloudFunction", | ||
IAMPolicy: &IAMPolicy{ | ||
Bindings: bindings, | ||
}, | ||
}}, nil | ||
} | ||
|
||
func FetchCloudFunctionsCloudFunctionIamPolicy(d TerraformResourceData, config *Config) (Asset, error) { | ||
// Check if the identity field returns a value | ||
if _, ok := d.GetOk("{{cloudfunction}}"); !ok { | ||
return Asset{}, ErrEmptyIdentityField | ||
} | ||
|
||
return fetchIamPolicy( | ||
CloudFunctionsCloudFunctionIamUpdaterProducer, | ||
d, | ||
config, | ||
"//cloudfunctions.googleapis.com/{{cloudfunction}}", | ||
"cloudfunctions.googleapis.com/CloudFunction", | ||
) | ||
} |
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,89 @@ | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE *** | ||
// | ||
// ---------------------------------------------------------------------------- | ||
// | ||
// 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" | ||
|
||
func GetCloudRunServiceIamPolicyCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newCloudRunServiceIamAsset(d, config, expandIamPolicyBindings) | ||
} | ||
|
||
func GetCloudRunServiceIamBindingCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newCloudRunServiceIamAsset(d, config, expandIamRoleBindings) | ||
} | ||
|
||
func GetCloudRunServiceIamMemberCaiObject(d TerraformResourceData, config *Config) ([]Asset, error) { | ||
return newCloudRunServiceIamAsset(d, config, expandIamMemberBindings) | ||
} | ||
|
||
func MergeCloudRunServiceIamPolicy(existing, incoming Asset) Asset { | ||
existing.IAMPolicy = incoming.IAMPolicy | ||
return existing | ||
} | ||
|
||
func MergeCloudRunServiceIamBinding(existing, incoming Asset) Asset { | ||
return mergeIamAssets(existing, incoming, mergeAuthoritativeBindings) | ||
} | ||
|
||
func MergeCloudRunServiceIamBindingDelete(existing, incoming Asset) Asset { | ||
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAuthoritativeBindings) | ||
} | ||
|
||
func MergeCloudRunServiceIamMember(existing, incoming Asset) Asset { | ||
return mergeIamAssets(existing, incoming, mergeAdditiveBindings) | ||
} | ||
|
||
func MergeCloudRunServiceIamMemberDelete(existing, incoming Asset) Asset { | ||
return mergeDeleteIamAssets(existing, incoming, mergeDeleteAdditiveBindings) | ||
} | ||
|
||
func newCloudRunServiceIamAsset( | ||
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, "//cloudrun.googleapis.com/{{service}}") | ||
if err != nil { | ||
return []Asset{}, err | ||
} | ||
|
||
return []Asset{{ | ||
Name: name, | ||
Type: "cloudrun.googleapis.com/Service", | ||
IAMPolicy: &IAMPolicy{ | ||
Bindings: bindings, | ||
}, | ||
}}, nil | ||
} | ||
|
||
func FetchCloudRunServiceIamPolicy(d TerraformResourceData, config *Config) (Asset, error) { | ||
// Check if the identity field returns a value | ||
if _, ok := d.GetOk("{{service}}"); !ok { | ||
return Asset{}, ErrEmptyIdentityField | ||
} | ||
|
||
return fetchIamPolicy( | ||
CloudRunServiceIamUpdaterProducer, | ||
d, | ||
config, | ||
"//cloudrun.googleapis.com/{{service}}", | ||
"cloudrun.googleapis.com/Service", | ||
) | ||
} |
Oops, something went wrong.