Skip to content

Commit dfe2bae

Browse files
authored
fix(function): timeout type (#1478)
1 parent 3208f12 commit dfe2bae

File tree

4 files changed

+576
-6
lines changed

4 files changed

+576
-6
lines changed

docs/resources/function.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ resource scaleway_function main {
4242
runtime = "go118"
4343
handler = "Handle"
4444
privacy = "private"
45-
zip_file = "function.zip"
46-
zip_hash = filesha256("function.zip")
47-
deploy = true
45+
timeout = 10
46+
zip_file = "function.zip"
47+
zip_hash = filesha256("function.zip")
48+
deploy = true
4849
}
4950
```
5051

51-
5252
## Arguments Reference
5353

5454
The following arguments are supported:

scaleway/resource_function.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func resourceScalewayFunction() *schema.Resource {
9898
Description: "Handler of the function. Depends on the runtime https://developers.scaleway.com/en/products/functions/api/#create-a-function",
9999
},
100100
"timeout": {
101-
Type: schema.TypeString,
101+
Type: schema.TypeInt,
102102
Computed: true,
103103
Description: "Holds the max duration (in seconds) the function is allowed for responding to a request",
104104
Optional: true,
@@ -266,7 +266,7 @@ func resourceScalewayFunctionRead(ctx context.Context, d *schema.ResourceData, m
266266
_ = d.Set("name", f.Name)
267267
_ = d.Set("privacy", f.Privacy.String())
268268
_ = d.Set("region", f.Region.String())
269-
_ = d.Set("timeout", flattenDuration(f.Timeout.ToTimeDuration()))
269+
_ = d.Set("timeout", f.Timeout.Seconds)
270270
_ = d.Set("domain_name", f.DomainName)
271271

272272
return diags

scaleway/resource_function_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,41 @@ func TestAccScalewayFunction_Basic(t *testing.T) {
7878
})
7979
}
8080

81+
func TestAccScalewayFunction_Timeout(t *testing.T) {
82+
tt := NewTestTools(t)
83+
defer tt.Cleanup()
84+
85+
resource.ParallelTest(t, resource.TestCase{
86+
PreCheck: func() { testAccPreCheck(t) },
87+
ProviderFactories: tt.ProviderFactories,
88+
CheckDestroy: testAccCheckScalewayFunctionDestroy(tt),
89+
Steps: []resource.TestStep{
90+
{
91+
Config: `
92+
resource scaleway_function_namespace main {}
93+
94+
resource scaleway_function main {
95+
name = "foobar"
96+
namespace_id = scaleway_function_namespace.main.id
97+
runtime = "node14"
98+
privacy = "private"
99+
handler = "handler.handle"
100+
timeout = 10
101+
}
102+
`,
103+
Check: resource.ComposeTestCheckFunc(
104+
testAccCheckScalewayFunctionExists(tt, "scaleway_function.main"),
105+
resource.TestCheckResourceAttr("scaleway_function.main", "name", "foobar"),
106+
resource.TestCheckResourceAttr("scaleway_function.main", "runtime", "node14"),
107+
resource.TestCheckResourceAttr("scaleway_function.main", "privacy", "private"),
108+
resource.TestCheckResourceAttr("scaleway_function.main", "handler", "handler.handle"),
109+
resource.TestCheckResourceAttr("scaleway_function.main", "timeout", "10"),
110+
),
111+
},
112+
},
113+
})
114+
}
115+
81116
func TestAccScalewayFunction_NoName(t *testing.T) {
82117
tt := NewTestTools(t)
83118
defer tt.Cleanup()

0 commit comments

Comments
 (0)