Skip to content

Commit d209523

Browse files
authored
feat(server_type): return included traffic (#680)
1 parent b88b4dc commit d209523

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

internal/e2etests/servertype/data_source_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ func TestAccHcloudDataSourceServerTypeTest(t *testing.T) {
3838
resource.TestCheckResourceAttr(stByName.TFID(), "cores", "1"),
3939
resource.TestCheckResourceAttr(stByName.TFID(), "memory", "2"),
4040
resource.TestCheckResourceAttr(stByName.TFID(), "architecture", "x86"),
41+
resource.TestCheckResourceAttr(stByName.TFID(), "included_traffic", "21990232555520"),
4142

4243
resource.TestCheckResourceAttr(stByID.TFID(), "id", "1"),
4344
resource.TestCheckResourceAttr(stByID.TFID(), "name", "cx11"),
4445
resource.TestCheckResourceAttr(stByID.TFID(), "description", "CX11"),
4546
resource.TestCheckResourceAttr(stByID.TFID(), "cores", "1"),
4647
resource.TestCheckResourceAttr(stByID.TFID(), "memory", "2"),
4748
resource.TestCheckResourceAttr(stByID.TFID(), "architecture", "x86"),
49+
resource.TestCheckResourceAttr(stByID.TFID(), "included_traffic", "21990232555520"),
4850
),
4951
},
5052
},

internal/servertype/data_source.go

+14-9
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func getCommonDataSchema() map[string]*schema.Schema {
6464
Type: schema.TypeString,
6565
Computed: true,
6666
},
67+
"included_traffic": {
68+
Type: schema.TypeInt,
69+
Computed: true,
70+
},
6771
}
6872
}
6973

@@ -152,15 +156,16 @@ func setServerTypeSchema(d *schema.ResourceData, t *hcloud.ServerType) {
152156

153157
func getServerTypeAttributes(t *hcloud.ServerType) map[string]interface{} {
154158
return map[string]interface{}{
155-
"id": t.ID,
156-
"name": t.Name,
157-
"description": t.Description,
158-
"cores": t.Cores,
159-
"memory": t.Memory,
160-
"disk": t.Disk,
161-
"storage_type": t.StorageType,
162-
"cpu_type": t.CPUType,
163-
"architecture": t.Architecture,
159+
"id": t.ID,
160+
"name": t.Name,
161+
"description": t.Description,
162+
"cores": t.Cores,
163+
"memory": t.Memory,
164+
"disk": t.Disk,
165+
"storage_type": t.StorageType,
166+
"cpu_type": t.CPUType,
167+
"architecture": t.Architecture,
168+
"included_traffic": t.IncludedTraffic,
164169
}
165170
}
166171

website/docs/d/server_type.html.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ data "hcloud_server_type" "ds_2" {
3030
- `memory` - (int) Memory a Server of this type will have in GB.
3131
- `disk` - (int) Disk size a Server of this type will have in GB.
3232
- `architecture` - (string) Architecture of the server_type.
33+
- `included_traffic` - (int) Free traffic per month in bytes.

0 commit comments

Comments
 (0)