-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathappsettings.go
More file actions
79 lines (69 loc) · 2.5 KB
/
appsettings.go
File metadata and controls
79 lines (69 loc) · 2.5 KB
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
74
75
76
77
78
79
package api
import (
"bytes"
"text/template"
)
// AppSettings is the structure of an app's settings.
type AppSettings struct {
// Owner is the app owner. It cannot be updated with AppSettings.Set(). See app.Transfer().
Owner string `json:"owner,omitempty"`
// App is the app name. It cannot be updated at all right now.
App string `json:"app,omitempty"`
// Created is the time that the application settings was created and cannot be updated.
Created string `json:"created,omitempty"`
// Updated is the last time the application settings was changed and cannot be updated.
Updated string `json:"updated,omitempty"`
// UUID is a unique string reflecting the application settings in its current state.
// It changes every time the application settings is changed and cannot be updated.
UUID string `json:"uuid,omitempty"`
// Routable determines if the application should be exposed by the router.
Routable *bool `json:"routable,omitempty"`
Allowlist []string `json:"allowlist,omitempty"`
Autodeploy *bool `json:"autodeploy,omitempty"`
Autorollback *bool `json:"autorollback,omitempty"`
Autoscale map[string]*Autoscale `json:"autoscale,omitempty"`
Label Labels `json:"label,omitempty"`
}
// NewRoutable returns a default value for the AppSettings.Routable field.
func NewRoutable() *bool {
b := true
return &b
}
// NewAutodeploy returns a default value for the AppSettings.NewAutodeploy field.
func NewAutodeploy() *bool {
b := true
return &b
}
// NewAutorollback returns a default value for the AppSettings.Autorollback field.
func NewAutorollback() *bool {
b := true
return &b
}
// Allowlist is the structure of POST /v2/app/<app id>/allowlist/.
type Allowlist struct {
Addresses []string `json:"addresses"`
}
// String displays the Autoscale rule in a readable format.
func (a Autoscale) String() string {
var doc bytes.Buffer
tmpl, err := template.New("autoscale").Parse(`Min Replicas: {{.Min}}
Max Replicas: {{.Max}}
CPU: {{.CPUPercent}}%`)
if err != nil {
panic(err)
}
if err := tmpl.Execute(&doc, a); err != nil {
panic(err)
}
return doc.String()
}
// Autoscales contains a hash of process types and the autoscale rules
type Autoscales map[string]*Autoscale
// Autoscale is a per proc type scaling information
type Autoscale struct {
Min int `json:"min"`
Max int `json:"max"`
CPUPercent int `json:"cpu_percent"`
}
// Labels can contain any user-defined key value
type Labels map[string]interface{}