Skip to content

Commit 7ab0be1

Browse files
Add cpu burst factory attribute to Tsuru app resource (#66)
* feat: Add cpu burst factory attribute to Tsuru app resource * test: Add accept tests for cpu burst factory * feat: rename cpu burst field
1 parent dd3f389 commit 7ab0be1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

internal/provider/resource_tsuru_app.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ func resourceTsuruApplication() *schema.Resource {
5252
Description: "Plan",
5353
Required: true,
5454
},
55+
"custom_cpu_burst": {
56+
Type: schema.TypeFloat,
57+
Description: "CPU burst factory override",
58+
Optional: true,
59+
},
5560
"team_owner": {
5661
Type: schema.TypeString,
5762
Description: "Application owner",
@@ -283,6 +288,11 @@ func resourceTsuruApplicationUpdate(ctx context.Context, d *schema.ResourceData,
283288
Tags: tags,
284289
}
285290

291+
if cpu_burst, ok := d.GetOk("custom_cpu_burst"); ok {
292+
cpuBurstValue := cpu_burst.(float64)
293+
app.Planoverride.CpuBurst = &cpuBurstValue
294+
}
295+
286296
if d.HasChange("metadata") {
287297
old, new := d.GetChange("metadata")
288298
oldMetadata := metadataFromResourceData(old)
@@ -371,6 +381,10 @@ func resourceTsuruApplicationRead(ctx context.Context, d *schema.ResourceData, m
371381
d.Set("team_owner", app.TeamOwner)
372382
d.Set("cluster", app.Cluster)
373383

384+
if app.Plan.Override.CpuBurst != nil {
385+
d.Set("custom_cpu_burst", app.Plan.Override.CpuBurst)
386+
}
387+
374388
if app.Description != "" {
375389
d.Set("description", app.Description)
376390
}

internal/provider/resource_tsuru_app_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,18 @@ func TestAccResourceTsuruApp(t *testing.T) {
5555
}
5656

5757
if iterationCount == 1 {
58+
cpuBurstValue := 1.5
5859
app := &tsuru.App{
5960
Name: name,
6061
Description: "my app description",
6162
TeamOwner: "my-team",
6263
Platform: "python",
63-
Plan: tsuru.Plan{Name: "c2m4"},
64+
Plan: tsuru.Plan{
65+
Name: "c2m4",
66+
Override: tsuru.PlanOverride{
67+
CpuBurst: &cpuBurstValue,
68+
},
69+
},
6470
Cluster: "my-cluster-01",
6571
Pool: "prod",
6672
Provisioner: "kubernetes",
@@ -241,6 +247,7 @@ func TestAccResourceTsuruApp(t *testing.T) {
241247
resource.TestCheckResourceAttr(resourceName, "description", "my app description"),
242248
resource.TestCheckResourceAttr(resourceName, "platform", "python"),
243249
resource.TestCheckResourceAttr(resourceName, "plan", "c2m4"),
250+
resource.TestCheckResourceAttr(resourceName, "custom_cpu_burst", "1.5"),
244251
resource.TestCheckResourceAttr(resourceName, "team_owner", "my-team"),
245252
resource.TestCheckResourceAttr(resourceName, "pool", "prod"),
246253
resource.TestCheckResourceAttr(resourceName, "tags.0", "tagA"),
@@ -277,6 +284,7 @@ func testAccResourceTsuruApp_basic() string {
277284
description = "my app description"
278285
platform = "python"
279286
plan = "c2m4"
287+
custom_cpu_burst = "1.5"
280288
team_owner = "my-team"
281289
pool = "prod"
282290
tags = ["tagA", "tagB"]

0 commit comments

Comments
 (0)