Skip to content

Commit feb823a

Browse files
committed
refactor: shift up cost field
Signed-off-by: thxCode <[email protected]>
1 parent 258aabb commit feb823a

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

byteset/resource_pipeline.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ type ResourcePipelineDestination struct {
4141
ConnMax types.Int64 `tfsdk:"conn_max"`
4242
BatchCap types.Int64 `tfsdk:"batch_cap"`
4343
Salt types.String `tfsdk:"salt"`
44-
Cost types.String `tfsdk:"cost"`
4544
}
4645

4746
func (r ResourcePipelineDestination) Reflect(ctx context.Context) (pipeline.Destination, error) {
@@ -58,6 +57,7 @@ type ResourcePipeline struct {
5857
Source ResourcePipelineSource `tfsdk:"source"`
5958
Destination ResourcePipelineDestination `tfsdk:"destination"`
6059
Timeouts timeouts.Value `tfsdk:"timeouts"`
60+
Cost types.String `tfsdk:"cost"`
6161
}
6262

6363
func (r ResourcePipeline) Corrupted() bool {
@@ -170,16 +170,16 @@ choose from local/remote SQL file or database.
170170
Description: `The salt assist calculating the destination database has changed
171171
but the address not, like the database Terraform Managed Resource ID.`,
172172
},
173-
"cost": schema.StringAttribute{
174-
Computed: true,
175-
Description: `The time consumption of this transfer.`,
176-
},
177173
},
178174
},
179175
"timeouts": timeouts.Attributes(ctx, timeouts.Opts{
180176
Create: true,
181177
Update: true,
182178
}),
179+
"cost": schema.StringAttribute{
180+
Computed: true,
181+
Description: `The time spent on this transfer.`,
182+
},
183183
},
184184
}
185185
}
@@ -242,7 +242,7 @@ func (r ResourcePipeline) Create(ctx context.Context, req resource.CreateRequest
242242

243243
return
244244
}
245-
plan.Destination.Cost = types.StringValue(time.Since(start).String())
245+
plan.Cost = types.StringValue(time.Since(start).String())
246246

247247
plan.Read(
248248
ctx,

byteset/resource_pipeline_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ INSERT INTO company (name, age, address, salary) VALUES ('James', 24, 'Houston',
8080
),
8181
resource.TestCheckResourceAttr(resourceName, "destination.address", basicDst),
8282
resource.TestCheckResourceAttr(resourceName, "destination.conn_max", "1"),
83-
resource.TestCheckResourceAttrSet(resourceName, "destination.cost"),
83+
resource.TestCheckResourceAttrSet(resourceName, "cost"),
8484
),
8585
},
8686
},
@@ -151,7 +151,7 @@ INSERT INTO company (name, age, address, salary) VALUES ('James', 24, 'Houston',
151151
resource.TestCheckResourceAttr(resourceName, "source.address", basicSrc),
152152
resource.TestCheckResourceAttr(resourceName, "destination.address", basicDst),
153153
resource.TestCheckResourceAttr(resourceName, "destination.conn_max", "10"),
154-
resource.TestCheckResourceAttrSet(resourceName, "destination.cost"),
154+
resource.TestCheckResourceAttrSet(resourceName, "cost"),
155155
),
156156
},
157157
},
@@ -210,7 +210,7 @@ func TestAccResourcePipeline_file_to_mysql(t *testing.T) {
210210
resource.TestCheckResourceAttr(resourceName, "source.address", basicSrc),
211211
resource.TestCheckResourceAttr(resourceName, "destination.address", basicDst),
212212
resource.TestCheckResourceAttr(resourceName, "destination.conn_max", "5"),
213-
resource.TestCheckResourceAttrSet(resourceName, "destination.cost"),
213+
resource.TestCheckResourceAttrSet(resourceName, "cost"),
214214
),
215215
},
216216
{
@@ -219,7 +219,7 @@ func TestAccResourcePipeline_file_to_mysql(t *testing.T) {
219219
resource.TestCheckResourceAttr(resourceName, "source.address", fkSrc),
220220
resource.TestCheckResourceAttr(resourceName, "destination.address", fkDst),
221221
resource.TestCheckResourceAttr(resourceName, "destination.conn_max", "5"),
222-
resource.TestCheckResourceAttrSet(resourceName, "destination.cost"),
222+
resource.TestCheckResourceAttrSet(resourceName, "cost"),
223223
),
224224
},
225225
{
@@ -228,7 +228,7 @@ func TestAccResourcePipeline_file_to_mysql(t *testing.T) {
228228
resource.TestCheckResourceAttr(resourceName, "source.address", largeSrc),
229229
resource.TestCheckResourceAttr(resourceName, "destination.address", largeDst),
230230
resource.TestCheckResourceAttr(resourceName, "destination.conn_max", "5"),
231-
resource.TestCheckResourceAttrSet(resourceName, "destination.cost"),
231+
resource.TestCheckResourceAttrSet(resourceName, "cost"),
232232
),
233233
},
234234
},
@@ -288,7 +288,7 @@ func TestAccResourcePipeline_file_to_postgres(t *testing.T) {
288288
resource.TestCheckResourceAttr(resourceName, "source.address", basicSrc),
289289
resource.TestCheckResourceAttr(resourceName, "destination.address", basicDst),
290290
resource.TestCheckResourceAttr(resourceName, "destination.conn_max", "10"),
291-
resource.TestCheckResourceAttrSet(resourceName, "destination.cost"),
291+
resource.TestCheckResourceAttrSet(resourceName, "cost"),
292292
),
293293
},
294294
{
@@ -297,7 +297,7 @@ func TestAccResourcePipeline_file_to_postgres(t *testing.T) {
297297
resource.TestCheckResourceAttr(resourceName, "source.address", fkSrc),
298298
resource.TestCheckResourceAttr(resourceName, "destination.address", fkDst),
299299
resource.TestCheckResourceAttr(resourceName, "destination.conn_max", "10"),
300-
resource.TestCheckResourceAttrSet(resourceName, "destination.cost"),
300+
resource.TestCheckResourceAttrSet(resourceName, "cost"),
301301
),
302302
},
303303
{
@@ -306,7 +306,7 @@ func TestAccResourcePipeline_file_to_postgres(t *testing.T) {
306306
resource.TestCheckResourceAttr(resourceName, "source.address", largeSrc),
307307
resource.TestCheckResourceAttr(resourceName, "destination.address", largeDst),
308308
resource.TestCheckResourceAttr(resourceName, "destination.conn_max", "10"),
309-
resource.TestCheckResourceAttrSet(resourceName, "destination.cost"),
309+
resource.TestCheckResourceAttrSet(resourceName, "cost"),
310310
),
311311
},
312312
},

docs/resources/pipeline.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ resource "byteset_pipeline" "example" {
3939

4040
### Read-Only
4141

42+
- `cost` (String) The time spent on this transfer.
4243
- `id` (String) The ID of this resource.
4344

4445
<a id="nestedatt--destination"></a>
@@ -62,10 +63,6 @@ Optional:
6263
- `salt` (String) The salt assist calculating the destination database has changed
6364
but the address not, like the database Terraform Managed Resource ID.
6465

65-
Read-Only:
66-
67-
- `cost` (String) The time consumption of this transfer.
68-
6966

7067
<a id="nestedatt--source"></a>
7168
### Nested Schema for `source`

0 commit comments

Comments
 (0)