diff --git a/go.mod b/go.mod index 7093cac67..2f4be35b5 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/hashicorp/hcl/v2 v2.19.1 github.com/hashicorp/terraform-json v0.17.1 github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 - github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231214173619-de9d44dfc615 + github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231214195243-744b4294446c github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.8.3 diff --git a/go.sum b/go.sum index 3e0bfdc7a..27cb81139 100644 --- a/go.sum +++ b/go.sum @@ -169,8 +169,8 @@ github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwU github.com/hashicorp/terraform-plugin-mux v0.8.0 h1:WCTP66mZ+iIaIrCNJnjPEYnVjawTshnDJu12BcXK1EI= github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 h1:wcOKYwPI9IorAJEBLzgclh3xVolO7ZorYd6U1vnok14= github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0/go.mod h1:qH/34G25Ugdj5FcM95cSoXzUgIbgfhVLXCcEcYaMwq8= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231214173619-de9d44dfc615 h1:ngdaMU5Ri9AF5hYFig+uxzw8Gx1Yp4JIE4B8lXv0r3Y= -github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231214173619-de9d44dfc615/go.mod h1:dx77gcRRy0m78zTwl0a49dtr3czHIqIZGnT9zMEKEJ0= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231214195243-744b4294446c h1:QS+Mvi8oVUSCNzFx0cTn3RZx1qF4RalbnBpQHyMSP/w= +github.com/hashicorp/terraform-provider-google-beta v1.20.1-0.20231214195243-744b4294446c/go.mod h1:dx77gcRRy0m78zTwl0a49dtr3czHIqIZGnT9zMEKEJ0= github.com/hashicorp/terraform-registry-address v0.2.2 h1:lPQBg403El8PPicg/qONZJDC6YlgCVbWDtNmmZKtBno= github.com/hashicorp/terraform-registry-address v0.2.2/go.mod h1:LtwNbCihUoUZ3RYriyS2wF/lGPB6gF9ICLRtuDk7hSo= github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= diff --git a/tfplan2cai/converters/google/resources/services/logging/logging_folder_settings.go b/tfplan2cai/converters/google/resources/services/logging/logging_folder_settings.go new file mode 100644 index 000000000..03d8811d5 --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/logging/logging_folder_settings.go @@ -0,0 +1,89 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 logging + +import ( + "reflect" + + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +const LoggingFolderSettingsAssetType string = "logging.googleapis.com/FolderSettings" + +func ResourceConverterLoggingFolderSettings() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: LoggingFolderSettingsAssetType, + Convert: GetLoggingFolderSettingsCaiObject, + } +} + +func GetLoggingFolderSettingsCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//logging.googleapis.com/folders/{{folder}}/settings") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetLoggingFolderSettingsApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: LoggingFolderSettingsAssetType, + Resource: &cai.AssetResource{ + Version: "v2", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/logging/v2/rest", + DiscoveryName: "FolderSettings", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetLoggingFolderSettingsApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + kmsKeyNameProp, err := expandLoggingFolderSettingsKmsKeyName(d.Get("kms_key_name"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("kms_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(kmsKeyNameProp)) && (ok || !reflect.DeepEqual(v, kmsKeyNameProp)) { + obj["kmsKeyName"] = kmsKeyNameProp + } + storageLocationProp, err := expandLoggingFolderSettingsStorageLocation(d.Get("storage_location"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("storage_location"); !tpgresource.IsEmptyValue(reflect.ValueOf(storageLocationProp)) && (ok || !reflect.DeepEqual(v, storageLocationProp)) { + obj["storageLocation"] = storageLocationProp + } + disableDefaultSinkProp, err := expandLoggingFolderSettingsDisableDefaultSink(d.Get("disable_default_sink"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("disable_default_sink"); !tpgresource.IsEmptyValue(reflect.ValueOf(disableDefaultSinkProp)) && (ok || !reflect.DeepEqual(v, disableDefaultSinkProp)) { + obj["disableDefaultSink"] = disableDefaultSinkProp + } + + return obj, nil +} + +func expandLoggingFolderSettingsKmsKeyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandLoggingFolderSettingsStorageLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandLoggingFolderSettingsDisableDefaultSink(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} diff --git a/tfplan2cai/converters/google/resources/services/logging/logging_organization_settings.go b/tfplan2cai/converters/google/resources/services/logging/logging_organization_settings.go new file mode 100644 index 000000000..44fef4bb6 --- /dev/null +++ b/tfplan2cai/converters/google/resources/services/logging/logging_organization_settings.go @@ -0,0 +1,89 @@ +// ---------------------------------------------------------------------------- +// +// *** 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 logging + +import ( + "reflect" + + "github.com/GoogleCloudPlatform/terraform-google-conversion/v5/tfplan2cai/converters/google/resources/cai" + "github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource" + transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport" +) + +const LoggingOrganizationSettingsAssetType string = "logging.googleapis.com/OrganizationSettings" + +func ResourceConverterLoggingOrganizationSettings() cai.ResourceConverter { + return cai.ResourceConverter{ + AssetType: LoggingOrganizationSettingsAssetType, + Convert: GetLoggingOrganizationSettingsCaiObject, + } +} + +func GetLoggingOrganizationSettingsCaiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) ([]cai.Asset, error) { + name, err := cai.AssetName(d, config, "//logging.googleapis.com/organizations/{{organization}}/settings") + if err != nil { + return []cai.Asset{}, err + } + if obj, err := GetLoggingOrganizationSettingsApiObject(d, config); err == nil { + return []cai.Asset{{ + Name: name, + Type: LoggingOrganizationSettingsAssetType, + Resource: &cai.AssetResource{ + Version: "v2", + DiscoveryDocumentURI: "https://www.googleapis.com/discovery/v1/apis/logging/v2/rest", + DiscoveryName: "OrganizationSettings", + Data: obj, + }, + }}, nil + } else { + return []cai.Asset{}, err + } +} + +func GetLoggingOrganizationSettingsApiObject(d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]interface{}, error) { + obj := make(map[string]interface{}) + kmsKeyNameProp, err := expandLoggingOrganizationSettingsKmsKeyName(d.Get("kms_key_name"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("kms_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(kmsKeyNameProp)) && (ok || !reflect.DeepEqual(v, kmsKeyNameProp)) { + obj["kmsKeyName"] = kmsKeyNameProp + } + storageLocationProp, err := expandLoggingOrganizationSettingsStorageLocation(d.Get("storage_location"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("storage_location"); !tpgresource.IsEmptyValue(reflect.ValueOf(storageLocationProp)) && (ok || !reflect.DeepEqual(v, storageLocationProp)) { + obj["storageLocation"] = storageLocationProp + } + disableDefaultSinkProp, err := expandLoggingOrganizationSettingsDisableDefaultSink(d.Get("disable_default_sink"), d, config) + if err != nil { + return nil, err + } else if v, ok := d.GetOkExists("disable_default_sink"); !tpgresource.IsEmptyValue(reflect.ValueOf(disableDefaultSinkProp)) && (ok || !reflect.DeepEqual(v, disableDefaultSinkProp)) { + obj["disableDefaultSink"] = disableDefaultSinkProp + } + + return obj, nil +} + +func expandLoggingOrganizationSettingsKmsKeyName(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandLoggingOrganizationSettingsStorageLocation(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandLoggingOrganizationSettingsDisableDefaultSink(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +}