|
7 | 7 | ) |
8 | 8 |
|
9 | 9 | func init() { |
| 10 | + exportMysqlMysqlConfigurationHints.RequireResourceRefresh = true |
| 11 | + exportMysqlMysqlConfigurationHints.ProcessDiscoveredResourcesFn = filterMysqlConfigurations |
10 | 12 | exportMysqlMysqlBackupHints.RequireResourceRefresh = true |
11 | 13 | exportMysqlMysqlBackupHints.ProcessDiscoveredResourcesFn = filterMysqlBackups |
12 | 14 | exportMysqlMysqlDbSystemHints.ProcessDiscoveredResourcesFn = processMysqlDbSystem |
@@ -49,7 +51,37 @@ func processMysqlDbSystem(ctx *tf_export.ResourceDiscoveryContext, resources []* |
49 | 51 | return resources, nil |
50 | 52 | } |
51 | 53 |
|
| 54 | +// exclude default configurations |
| 55 | +func filterMysqlConfigurations(ctx *tf_export.ResourceDiscoveryContext, resources []*tf_export.OCIResource) ([]*tf_export.OCIResource, error) { |
| 56 | + results := []*tf_export.OCIResource{} |
| 57 | + |
| 58 | + // Filter out Mysql Backups that are automatically created. We cannot operate on "Automatic" backups. |
| 59 | + for _, configuration := range resources { |
| 60 | + configurationType, exists := configuration.SourceAttributes["type"] |
| 61 | + |
| 62 | + if exists && configurationType.(string) == "DEFAULT" { |
| 63 | + continue |
| 64 | + } |
| 65 | + |
| 66 | + results = append(results, configuration) |
| 67 | + } |
| 68 | + |
| 69 | + return results, nil |
| 70 | +} |
| 71 | + |
52 | 72 | // Hints for discovering and exporting this resource to configuration and state files |
| 73 | + |
| 74 | +var exportMysqlMysqlConfigurationHints = &tf_export.TerraformResourceHints{ |
| 75 | + ResourceClass: "oci_mysql_mysql_configuration", |
| 76 | + DatasourceClass: "oci_mysql_mysql_configurations", |
| 77 | + DatasourceItemsAttr: "configurations", |
| 78 | + ResourceAbbreviation: "mysql_configuration", |
| 79 | + RequireResourceRefresh: true, |
| 80 | + DiscoverableLifecycleStates: []string{ |
| 81 | + string(oci_mysql.ConfigurationLifecycleStateActive), |
| 82 | + }, |
| 83 | +} |
| 84 | + |
53 | 85 | var exportMysqlHeatWaveClusterHints = &tf_export.TerraformResourceHints{ |
54 | 86 | ResourceClass: "oci_mysql_heat_wave_cluster", |
55 | 87 | DatasourceClass: "oci_mysql_heat_wave_cluster", |
@@ -94,6 +126,7 @@ var exportMysqlChannelHints = &tf_export.TerraformResourceHints{ |
94 | 126 |
|
95 | 127 | var mysqlResourceGraph = tf_export.TerraformResourceGraph{ |
96 | 128 | "oci_identity_compartment": { |
| 129 | + {TerraformResourceHints: exportMysqlMysqlConfigurationHints}, |
97 | 130 | {TerraformResourceHints: exportMysqlMysqlBackupHints}, |
98 | 131 | {TerraformResourceHints: exportMysqlMysqlDbSystemHints}, |
99 | 132 | {TerraformResourceHints: exportMysqlChannelHints}, |
|
0 commit comments