Skip to content

Commit

Permalink
fix(function): fix missing fields in read (#2369)
Browse files Browse the repository at this point in the history
  • Loading branch information
jremy42 authored Jan 22, 2024
1 parent 92c3c50 commit b24596e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/resources/function.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ In addition to all arguments above, the following attributes are exported:

~> **Important:** Functions' IDs are [regional](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{region}/{id}`, e.g. `fr-par/11111111-1111-1111-1111-111111111111`

- `namespace_id` - The namespace ID the function is associated with.
- `domain_name` - The native domain name of the function
- `organization_id` - The organization ID the function is associated with.
- `cpu_limit` - The CPU limit in mCPU for your function. More infos on resources [here](https://developers.scaleway.com/en/products/functions/api/#functions)
Expand Down
4 changes: 2 additions & 2 deletions docs/resources/function_cron.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ The following arguments are required:
- `args` - (Required) The key-value mapping to define arguments that will be passed to your function’s event object
during
- `name` - (Optional) The name of the cron. If not provided, the name is generated.
- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions)
in where the job was created.

## Attributes Reference

Expand All @@ -61,8 +63,6 @@ In addition to all arguments above, the following attributes are exported:

~> **Important:** Function CRONs' IDs are [regional](../guides/regions_and_zones.md#resource-ids), which means they are of the form `{region}/{id}`, e.g. `fr-par/11111111-1111-1111-1111-111111111111`

- `region` - (Defaults to [provider](../index.md#region) `region`) The [region](../guides/regions_and_zones.md#regions)
in where the job was created.
- `status` - The cron status.

## Import
Expand Down
10 changes: 6 additions & 4 deletions scaleway/resource_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ func resourceScalewayFunction() *schema.Resource {
SchemaVersion: 0,
Schema: map[string]*schema.Schema{
"namespace_id": {
Type: schema.TypeString,
Description: "The namespace ID associated with this function",
Required: true,
ForceNew: true,
Type: schema.TypeString,
Description: "The namespace ID associated with this function",
Required: true,
ForceNew: true,
DiffSuppressFunc: diffSuppressFuncLocality,
},
"name": {
Type: schema.TypeString,
Expand Down Expand Up @@ -293,6 +294,7 @@ func resourceScalewayFunctionRead(ctx context.Context, d *schema.ResourceData, m
_ = d.Set("timeout", f.Timeout.Seconds)
_ = d.Set("domain_name", f.DomainName)
_ = d.Set("http_option", f.HTTPOption)
_ = d.Set("namespace_id", f.NamespaceID)

return diags
}
Expand Down
2 changes: 1 addition & 1 deletion scaleway/resource_function_cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func resourceScalewayFunctionCronRead(ctx context.Context, d *schema.ResourceDat

_ = d.Set("args", args)
_ = d.Set("status", cron.Status)

_ = d.Set("region", region.String())
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions scaleway/resource_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func TestAccScalewayFunction_Basic(t *testing.T) {
resource.TestCheckResourceAttr("scaleway_function.main", "runtime", "node14"),
resource.TestCheckResourceAttr("scaleway_function.main", "privacy", "private"),
resource.TestCheckResourceAttr("scaleway_function.main", "handler", "handler.handle"),
resource.TestCheckResourceAttrSet("scaleway_function.main", "namespace_id"),
resource.TestCheckResourceAttrSet("scaleway_function.main", "region"),
),
},
},
Expand Down

0 comments on commit b24596e

Please sign in to comment.