-
Notifications
You must be signed in to change notification settings - Fork 67
/
schema_static_worker_pool.go
73 lines (59 loc) · 1.85 KB
/
schema_static_worker_pool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package octopusdeploy
import (
"context"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workerpools"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func expandStaticWorkerPool(d *schema.ResourceData) *workerpools.StaticWorkerPool {
name := d.Get("name").(string)
dynamicWorkerPool := workerpools.NewStaticWorkerPool(name)
dynamicWorkerPool.ID = d.Id()
if v, ok := d.GetOk("can_add_workers"); ok {
dynamicWorkerPool.CanAddWorkers = v.(bool)
}
if v, ok := d.GetOk("description"); ok {
dynamicWorkerPool.Description = v.(string)
}
if v, ok := d.GetOk("is_default"); ok {
dynamicWorkerPool.IsDefault = v.(bool)
}
if v, ok := d.GetOk("sort_order"); ok {
dynamicWorkerPool.SortOrder = v.(int)
}
if v, ok := d.GetOk("space_id"); ok {
dynamicWorkerPool.SpaceID = v.(string)
}
return dynamicWorkerPool
}
func getStaticWorkerPoolSchema() map[string]*schema.Schema {
return map[string]*schema.Schema{
"can_add_workers": {
Computed: true,
Type: schema.TypeBool,
},
"description": getDescriptionSchema("static worker pool"),
"id": getIDSchema(),
"is_default": {
Optional: true,
Type: schema.TypeBool,
},
"name": getNameSchema(true),
"sort_order": {
Computed: true,
Description: "The order number to sort a dynamic worker pool.",
Optional: true,
Type: schema.TypeInt,
},
"space_id": getSpaceIDSchema(),
}
}
func setStaticWorkerPool(ctx context.Context, d *schema.ResourceData, staticWorkerPool *workerpools.StaticWorkerPool) error {
d.Set("can_add_workers", staticWorkerPool.CanAddWorkers)
d.Set("description", staticWorkerPool.Description)
d.Set("is_default", staticWorkerPool.IsDefault)
d.Set("name", staticWorkerPool.Name)
d.Set("space_id", staticWorkerPool.SpaceID)
d.Set("sort_order", staticWorkerPool.SortOrder)
d.SetId(staticWorkerPool.GetID())
return nil
}