8
8
"github.com/hashicorp/terraform-plugin-framework/datasource"
9
9
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
10
10
"github.com/hashicorp/terraform-plugin-framework/types"
11
+ "github.com/joescharf/dbsnapper/v2/storage"
11
12
)
12
13
13
14
// Ensure the implementation satisfies the expected interfaces.
@@ -88,6 +89,16 @@ func (d *TargetsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest
88
89
Description : "The size of the source database in bytes" ,
89
90
Computed : true ,
90
91
},
92
+ "storage_profile" : schema.SingleNestedAttribute {
93
+ Description : "Storage provider configuration for Snapshots" ,
94
+ Optional : true ,
95
+ Attributes : map [string ]schema.Attribute {
96
+ "id" : schema.StringAttribute {
97
+ Description : "The unique identifier for the storage profile" ,
98
+ Optional : true ,
99
+ },
100
+ },
101
+ },
91
102
},
92
103
},
93
104
@@ -103,6 +114,16 @@ func (d *TargetsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest
103
114
Description : "The query used to sanitize the snapshot" ,
104
115
Computed : true ,
105
116
},
117
+ "storage_profile" : schema.SingleNestedAttribute {
118
+ Description : "Storage provider configuration for Sanitized Snapshots" ,
119
+ Optional : true ,
120
+ Attributes : map [string ]schema.Attribute {
121
+ "id" : schema.StringAttribute {
122
+ Description : "The unique identifier for the storage profile" ,
123
+ Optional : true ,
124
+ },
125
+ },
126
+ },
106
127
},
107
128
},
108
129
"share" : schema.SingleNestedAttribute {
@@ -135,6 +156,14 @@ func (d *TargetsDataSource) Read(ctx context.Context, req datasource.ReadRequest
135
156
// }
136
157
for _ , target := range targets {
137
158
idstr := target .ID .String ()
159
+ snapStorageProfile := ""
160
+ sanStorageProfile := ""
161
+ if target .Snapshot .StorageProfile != (storage.StorageProfile {}) {
162
+ snapStorageProfile = target .Snapshot .StorageProfile .ID .String ()
163
+ }
164
+ if target .Sanitize .StorageProfile != nil {
165
+ sanStorageProfile = target .Sanitize .StorageProfile .ID .String ()
166
+ }
138
167
targetState := TargetResourceModel {
139
168
140
169
ID : types .StringValue (idstr ),
@@ -145,10 +174,16 @@ func (d *TargetsDataSource) Read(ctx context.Context, req datasource.ReadRequest
145
174
SrcURL : types .StringValue (target .Snapshot .SrcURL ),
146
175
DstURL : types .StringValue (target .Snapshot .DstURL ),
147
176
// SrcBytes: types.Int64Value(target.Snapshot.SrcBytes),
177
+ StorageProfile : & targetStorageProfileModel {
178
+ ID : types .StringValue (snapStorageProfile ),
179
+ },
148
180
},
149
181
Sanitize : & targetSanitizeModel {
150
182
DstURL : types .StringValue (target .Sanitize .DstURL ),
151
183
Query : types .StringValue (target .Sanitize .Query ),
184
+ StorageProfile : & targetStorageProfileModel {
185
+ ID : types .StringValue (sanStorageProfile ),
186
+ },
152
187
},
153
188
}
154
189
// Share
0 commit comments