Skip to content

Commit 99680b0

Browse files
refactor: rename autoscaling to scheduling
1 parent d19bea1 commit 99680b0

File tree

5 files changed

+73
-73
lines changed

5 files changed

+73
-73
lines changed

docs/data-sources/workspace_preset.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ Required:
5454

5555
Optional:
5656

57-
- `autoscaling` (Block List, Max: 1) Configuration block that defines autoscaling behavior for prebuilds. Use this to automatically adjust the number of prebuild instances based on a schedule. (see [below for nested schema](#nestedblock--prebuilds--autoscaling))
57+
- `scheduling` (Block List, Max: 1) Configuration block that defines scheduling behavior for prebuilds. Use this to automatically adjust the number of prebuild instances based on a schedule. (see [below for nested schema](#nestedblock--prebuilds--scheduling))
5858
- `expiration_policy` (Block Set, Max: 1) Configuration block that defines TTL (time-to-live) behavior for prebuilds. Use this to automatically invalidate and delete prebuilds after a certain period, ensuring they stay up-to-date. (see [below for nested schema](#nestedblock--prebuilds--expiration_policy))
5959

60-
<a id="nestedblock--prebuilds--autoscaling"></a>
61-
### Nested Schema for `prebuilds.autoscaling`
60+
<a id="nestedblock--prebuilds--scheduling"></a>
61+
### Nested Schema for `prebuilds.scheduling`
6262

6363
Required:
6464

65-
- `schedule` (Block List, Min: 1) One or more schedule blocks that define when to scale the number of prebuild instances. (see [below for nested schema](#nestedblock--prebuilds--autoscaling--schedule))
66-
- `timezone` (String) The timezone to use for the autoscaling schedule (e.g., "UTC", "America/New_York").
65+
- `schedule` (Block List, Min: 1) One or more schedule blocks that define when to scale the number of prebuild instances. (see [below for nested schema](#nestedblock--prebuilds--scheduling--schedule))
66+
- `timezone` (String) The timezone to use for the scheduling schedule (e.g., "UTC", "America/New_York").
6767
Timezone must be a valid timezone in the IANA timezone database.
6868
See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list of valid timezone identifiers and https://www.iana.org/time-zones for the official IANA timezone database.
6969

70-
<a id="nestedblock--prebuilds--autoscaling--schedule"></a>
71-
### Nested Schema for `prebuilds.autoscaling.schedule`
70+
<a id="nestedblock--prebuilds--scheduling--schedule"></a>
71+
### Nested Schema for `prebuilds.scheduling.schedule`
7272

7373
Required:
7474

integration/integration_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ func TestIntegration(t *testing.T) {
9090
// TODO (sasswart): the cli doesn't support presets yet.
9191
// once it does, the value for workspace_parameter.value
9292
// will be the preset value.
93-
"workspace_parameter.value": `param value`,
94-
"workspace_parameter.icon": `param icon`,
95-
"workspace_preset.name": `preset`,
96-
"workspace_preset.parameters.param": `preset param value`,
97-
"workspace_preset.prebuilds.instances": `1`,
98-
"workspace_preset.prebuilds.expiration_policy.ttl": `86400`,
99-
"workspace_preset.prebuilds.autoscaling.timezone": `UTC`,
100-
"workspace_preset.prebuilds.autoscaling.schedule0.cron": `\* 8-18 \* \* 1-5`,
101-
"workspace_preset.prebuilds.autoscaling.schedule0.instances": `3`,
102-
"workspace_preset.prebuilds.autoscaling.schedule1.cron": `\* 8-14 \* \* 6`,
103-
"workspace_preset.prebuilds.autoscaling.schedule1.instances": `1`,
93+
"workspace_parameter.value": `param value`,
94+
"workspace_parameter.icon": `param icon`,
95+
"workspace_preset.name": `preset`,
96+
"workspace_preset.parameters.param": `preset param value`,
97+
"workspace_preset.prebuilds.instances": `1`,
98+
"workspace_preset.prebuilds.expiration_policy.ttl": `86400`,
99+
"workspace_preset.prebuilds.scheduling.timezone": `UTC`,
100+
"workspace_preset.prebuilds.scheduling.schedule0.cron": `\* 8-18 \* \* 1-5`,
101+
"workspace_preset.prebuilds.scheduling.schedule0.instances": `3`,
102+
"workspace_preset.prebuilds.scheduling.schedule1.cron": `\* 8-14 \* \* 6`,
103+
"workspace_preset.prebuilds.scheduling.schedule1.instances": `1`,
104104
},
105105
},
106106
{

integration/test-data-source/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ data "coder_workspace_preset" "preset" {
3030
expiration_policy {
3131
ttl = 86400
3232
}
33-
autoscaling {
33+
scheduling {
3434
timezone = "UTC"
3535
schedule {
3636
cron = "* 8-18 * * 1-5"
@@ -67,11 +67,11 @@ locals {
6767
"workspace_preset.parameters.param" : data.coder_workspace_preset.preset.parameters.param,
6868
"workspace_preset.prebuilds.instances" : tostring(one(data.coder_workspace_preset.preset.prebuilds).instances),
6969
"workspace_preset.prebuilds.expiration_policy.ttl" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).expiration_policy).ttl),
70-
"workspace_preset.prebuilds.autoscaling.timezone" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).autoscaling).timezone),
71-
"workspace_preset.prebuilds.autoscaling.schedule0.cron" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).autoscaling).schedule[0].cron),
72-
"workspace_preset.prebuilds.autoscaling.schedule0.instances" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).autoscaling).schedule[0].instances),
73-
"workspace_preset.prebuilds.autoscaling.schedule1.cron" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).autoscaling).schedule[1].cron),
74-
"workspace_preset.prebuilds.autoscaling.schedule1.instances" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).autoscaling).schedule[1].instances),
70+
"workspace_preset.prebuilds.scheduling.timezone" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).scheduling).timezone),
71+
"workspace_preset.prebuilds.scheduling.schedule0.cron" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).scheduling).schedule[0].cron),
72+
"workspace_preset.prebuilds.scheduling.schedule0.instances" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).scheduling).schedule[0].instances),
73+
"workspace_preset.prebuilds.scheduling.schedule1.cron" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).scheduling).schedule[1].cron),
74+
"workspace_preset.prebuilds.scheduling.schedule1.instances" : tostring(one(one(data.coder_workspace_preset.preset.prebuilds).scheduling).schedule[1].instances),
7575
}
7676
}
7777

provider/workspace_preset.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ type WorkspacePrebuild struct {
3636
// for utilities that parse our terraform output using this type. To remain compatible
3737
// with those cases, we use a slice here.
3838
ExpirationPolicy []ExpirationPolicy `mapstructure:"expiration_policy"`
39-
Autoscaling []Autoscaling `mapstructure:"autoscaling"`
39+
Scheduling []Scheduling `mapstructure:"scheduling"`
4040
}
4141

4242
type ExpirationPolicy struct {
4343
TTL int `mapstructure:"ttl"`
4444
}
4545

46-
type Autoscaling struct {
46+
type Scheduling struct {
4747
Timezone string `mapstructure:"timezone"`
4848
Schedule []Schedule `mapstructure:"schedule"`
4949
}
@@ -70,7 +70,7 @@ func workspacePresetDataSource() *schema.Resource {
7070
return diag.Errorf("decode workspace preset: %s", err)
7171
}
7272

73-
// Validate schedule overlaps if autoscaling is configured
73+
// Validate schedule overlaps if scheduling is configured
7474
err = validateSchedules(rd)
7575
if err != nil {
7676
return diag.Errorf("schedules overlap with each other: %s", err)
@@ -143,16 +143,16 @@ func workspacePresetDataSource() *schema.Resource {
143143
},
144144
},
145145
},
146-
"autoscaling": {
146+
"scheduling": {
147147
Type: schema.TypeList,
148-
Description: "Configuration block that defines autoscaling behavior for prebuilds. Use this to automatically adjust the number of prebuild instances based on a schedule.",
148+
Description: "Configuration block that defines scheduling behavior for prebuilds. Use this to automatically adjust the number of prebuild instances based on a schedule.",
149149
Optional: true,
150150
MaxItems: 1,
151151
Elem: &schema.Resource{
152152
Schema: map[string]*schema.Schema{
153153
"timezone": {
154154
Type: schema.TypeString,
155-
Description: `The timezone to use for the autoscaling schedule (e.g., "UTC", "America/New_York").
155+
Description: `The timezone to use for the scheduling schedule (e.g., "UTC", "America/New_York").
156156
Timezone must be a valid timezone in the IANA timezone database.
157157
See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete list of valid timezone identifiers and https://www.iana.org/time-zones for the official IANA timezone database.`,
158158
Required: true,
@@ -213,7 +213,7 @@ See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for a complete
213213
}
214214

215215
// validatePrebuildsCronSpec ensures that the minute field is set to *.
216-
// This is required because autoscaling schedules represent continuous time ranges,
216+
// This is required because scheduling schedules represent continuous time ranges,
217217
// and we want the schedule to cover entire hours rather than specific minute intervals.
218218
func validatePrebuildsCronSpec(spec string) error {
219219
parts := strings.Fields(spec)
@@ -227,7 +227,7 @@ func validatePrebuildsCronSpec(spec string) error {
227227
return nil
228228
}
229229

230-
// validateSchedules checks if any of the configured autoscaling schedules overlap with each other.
230+
// validateSchedules checks if any of the configured scheduling schedules overlap with each other.
231231
// It returns an error if overlaps are found, nil otherwise.
232232
func validateSchedules(rd *schema.ResourceData) error {
233233
// TypeSet from schema definition
@@ -243,22 +243,22 @@ func validateSchedules(rd *schema.ResourceData) error {
243243
}
244244

245245
// TypeList from schema definition
246-
autoscalingBlocks, ok := prebuild["autoscaling"].([]interface{})
246+
schedulingBlocks, ok := prebuild["scheduling"].([]interface{})
247247
if !ok {
248-
return fmt.Errorf("invalid autoscaling configuration: expected []interface{}")
248+
return fmt.Errorf("invalid scheduling configuration: expected []interface{}")
249249
}
250-
if len(autoscalingBlocks) == 0 {
250+
if len(schedulingBlocks) == 0 {
251251
return nil
252252
}
253253

254254
// Each element of TypeList with Elem: &schema.Resource{} should be map[string]interface{}
255-
autoscalingBlock, ok := autoscalingBlocks[0].(map[string]interface{})
255+
schedulingBlock, ok := schedulingBlocks[0].(map[string]interface{})
256256
if !ok {
257-
return fmt.Errorf("invalid autoscaling configuration: expected map[string]interface{}")
257+
return fmt.Errorf("invalid scheduling configuration: expected map[string]interface{}")
258258
}
259259

260260
// TypeList from schema definition
261-
scheduleBlocks, ok := autoscalingBlock["schedule"].([]interface{})
261+
scheduleBlocks, ok := schedulingBlock["schedule"].([]interface{})
262262
if !ok {
263263
return fmt.Errorf("invalid schedule configuration: expected []interface{}")
264264
}

0 commit comments

Comments
 (0)