Skip to content

Commit d1d79dd

Browse files
committed
featcontroller-sdk): add autodeploy flag,force deploy,manage app perms,cmd use ptype
1 parent 133cdf5 commit d1d79dd

26 files changed

Lines changed: 280 additions & 226 deletions

api/appsettings.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type AppSettings struct {
2121
// Routable determines if the application should be exposed by the router.
2222
Routable *bool `json:"routable,omitempty"`
2323
Allowlist []string `json:"allowlist,omitempty"`
24+
Autodeploy *bool `json:"autodeploy,omitempty"`
2425
Autorollback *bool `json:"autorollback,omitempty"`
2526
Autoscale map[string]*Autoscale `json:"autoscale,omitempty"`
2627
Label Labels `json:"label,omitempty"`
@@ -32,6 +33,12 @@ func NewRoutable() *bool {
3233
return &b
3334
}
3435

36+
// NewAutodeploy returns a default value for the AppSettings.NewAutodeploy field.
37+
func NewAutodeploy() *bool {
38+
b := true
39+
return &b
40+
}
41+
3542
// NewAutorollback returns a default value for the AppSettings.Autorollback field.
3643
func NewAutorollback() *bool {
3744
b := true

api/certs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import "github.com/drycc/controller-sdk-go/pkg/time"
88
type Cert struct {
99
Updated string `json:"updated,omitempty"`
1010
Created string `json:"created,omitempty"`
11+
App string `json:"app"`
1112
Name string `json:"name"`
1213
CommonName string `json:"common_name"`
1314
Expires time.Time `json:"expires"`

api/domains.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package api
22

33
// Domain is the structure of the domain object.
44
type Domain struct {
5-
App string `json:"app"`
6-
Created string `json:"created"`
7-
Domain string `json:"domain"`
8-
Owner string `json:"owner"`
9-
ProcfileType string `json:"procfile_type"`
10-
Updated string `json:"updated"`
5+
App string `json:"app"`
6+
Created string `json:"created"`
7+
Domain string `json:"domain"`
8+
Owner string `json:"owner"`
9+
Ptype string `json:"ptype"`
10+
Updated string `json:"updated"`
1111
}
1212

1313
// Domains defines a collection of domain objects.
@@ -19,6 +19,6 @@ func (d Domains) Less(i, j int) bool { return d[i].Domain < d[j].Domain }
1919

2020
// DomainCreateRequest is the structure of POST /v2/app/<app id>/domains/.
2121
type DomainCreateRequest struct {
22-
Domain string `json:"domain"`
23-
ProcfileType string `json:"procfile_type"`
22+
Domain string `json:"domain"`
23+
Ptype string `json:"ptype"`
2424
}

api/perms.go

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
package api
22

3-
// PermCodeResponse is the definition of GET /v2/perms/codes/.
4-
type PermCodeResponse struct {
5-
Codename string `json:"codename"`
6-
Description string `json:"description"`
7-
}
8-
93
// UserPermResponse is the definition of GET /v2/perms/rules/.
104
type UserPermResponse struct {
11-
ID uint64 `json:"id"`
12-
Codename string `json:"codename"`
13-
Uniqueid string `json:"uniqueid"`
14-
Username string `json:"username"`
5+
App string `json:"app"`
6+
Username string `json:"username"`
7+
Permissions []string `json:"permissions"`
158
}
169

1710
// UserPermRequest is the definition of a requst on /v2/perms/rules/.
1811
type UserPermRequest struct {
19-
Codename string `json:"codename"`
20-
Uniqueid string `json:"uniqueid"`
21-
Username string `json:"username"`
12+
Username string `json:"username"`
13+
Permissions string `json:"permissions"`
2214
}

api/ps.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type Command struct {
3333

3434
// PodType holds pods of the same type.
3535
type PodType struct {
36-
Type string
36+
Ptype string
3737
PodsList PodsList
3838
}
3939

@@ -54,7 +54,7 @@ type Types struct {
5454

5555
func (p PodTypes) Len() int { return len(p) }
5656
func (p PodTypes) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
57-
func (p PodTypes) Less(i, j int) bool { return p[i].Type < p[j].Type }
57+
func (p PodTypes) Less(i, j int) bool { return p[i].Ptype < p[j].Ptype }
5858

5959
// ContainerState defines a container state.
6060
type ContainerState struct {

api/ps_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func TestPodTypesSorted(t *testing.T) {
3535
expectedPodTypes := []string{"clock", "web", "worker"}
3636

3737
for i, podType := range podTypes {
38-
if expectedPodTypes[i] != podType.Type {
39-
t.Errorf("Expected pod types to be sorted %v, Got %v at index %v", expectedPodTypes[i], podType.Type, i)
38+
if expectedPodTypes[i] != podType.Ptype {
39+
t.Errorf("Expected pod types to be sorted %v, Got %v at index %v", expectedPodTypes[i], podType.Ptype, i)
4040
}
4141
}
4242
}

api/releases.go

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,30 @@ package api
22

33
// Release is the definition of the release object.
44
type Release struct {
5-
App string `json:"app"`
6-
State string `json:"state"`
7-
Build string `json:"build,omitempty"`
8-
Config string `json:"config"`
9-
Created string `json:"created"`
10-
Owner string `json:"owner"`
11-
Summary string `json:"summary"`
12-
Exception string `json:"exception"`
13-
Updated string `json:"updated"`
14-
UUID string `json:"uuid"`
15-
Version int `json:"version"`
5+
App string `json:"app"`
6+
State string `json:"state"`
7+
Build string `json:"build,omitempty"`
8+
Config string `json:"config"`
9+
Created string `json:"created"`
10+
Owner string `json:"owner"`
11+
Summary string `json:"summary"`
12+
Exception string `json:"exception"`
13+
Conditions []Condition `json:"conditions"`
14+
Updated string `json:"updated"`
15+
UUID string `json:"uuid"`
16+
Version int `json:"version"`
1617
}
1718

1819
// ReleaseRollback is the defenition of POST /v2/apps/<app id>/releases/.
1920
type ReleaseRollback struct {
20-
Version int `json:"version"`
21+
Version int `json:"version"`
22+
Ptypes string `json:"ptypes"`
23+
}
24+
25+
type Condition struct {
26+
State string `json:"state"`
27+
Action string `json:"action"`
28+
Ptypes []string `json:"ptypes"`
29+
Exception string `json:"exception"`
30+
Created string `json:"created"`
2131
}

api/routes.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Route struct {
1414
// It changes every time the application settings is changed and cannot be updated.
1515
UUID string `json:"uuid,omitempty"`
1616
Name string `json:"name,omitempty"`
17-
Type string `json:"procfile_type,omitempty"`
17+
Ptype string `json:"ptype,omitempty"`
1818
Kind string `json:"kind,omitempty"`
1919
Port int `json:"port,omitempty"`
2020
ParentRefs []ParentRef `json:"parent_refs,omitempty"`
@@ -30,10 +30,10 @@ type Routes []Route
3030

3131
// RouteCreateRequest is the structure of POST /v2/app/<app id>/routes/.
3232
type RouteCreateRequest struct {
33-
Name string `json:"name,omitempty"`
34-
Type string `json:"procfile_type,omitempty"`
35-
Port int `json:"port,omitempty"`
36-
Kind string `json:"kind,omitempty"`
33+
Name string `json:"name,omitempty"`
34+
Ptype string `json:"ptype,omitempty"`
35+
Port int `json:"port,omitempty"`
36+
Kind string `json:"kind,omitempty"`
3737
}
3838

3939
// RouteAttackRequest is the structure of PATCH /v2/apps/(?P<id>{})/routes/(?P<name>{})/attach/?$.
@@ -51,7 +51,7 @@ type RouteDetackRequest struct {
5151
// RouteRule is the structure of GET RESPONSE /v2/apps/(?P<id>{})/routes/(?P<name>{})/rules/?$.
5252
type RouteRule struct {
5353
Name string `json:"name,omitempty"`
54-
Type string `json:"procfile_type,omitempty"`
54+
Ptype string `json:"ptype,omitempty"`
5555
Kind string `json:"kind,omitempty"`
5656
Rules interface{} `json:"rules,omitempty"`
5757
}

api/services.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package api
22

33
// Service is the structure of the service object.
44
type Service struct {
5-
Domain string `json:"domain"`
6-
ProcfileType string `json:"procfile_type"`
7-
Ports []Port `json:"ports"`
5+
Domain string `json:"domain"`
6+
Ptype string `json:"ptype"`
7+
Ports []Port `json:"ports"`
88
}
99

1010
type Port struct {
@@ -19,19 +19,19 @@ type Services []Service
1919

2020
func (s Services) Len() int { return len(s) }
2121
func (s Services) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
22-
func (s Services) Less(i, j int) bool { return s[i].ProcfileType < s[j].ProcfileType }
22+
func (s Services) Less(i, j int) bool { return s[i].Ptype < s[j].Ptype }
2323

2424
// ServiceCreateUpdateRequest is the structure of POST /v2/app/<app id>/services/.
2525
type ServiceCreateUpdateRequest struct {
26-
ProcfileType string `json:"procfile_type"`
27-
Port int `json:"port"`
28-
Protocol string `json:"protocol"`
29-
TargetPort int `json:"target_port"`
26+
Ptype string `json:"ptype"`
27+
Port int `json:"port"`
28+
Protocol string `json:"protocol"`
29+
TargetPort int `json:"target_port"`
3030
}
3131

3232
// ServiceDeleteRequest is the structure of DELETE /v2/app/<app id>/services/.
3333
type ServiceDeleteRequest struct {
34-
ProcfileType string `json:"procfile_type"`
35-
Port int `json:"port"`
36-
Protocol string `json:"protocol"`
34+
Ptype string `json:"ptype"`
35+
Port int `json:"port"`
36+
Protocol string `json:"protocol"`
3737
}

appsettings/appsettings_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const appSettingsFixture string = `
1717
"owner": "test",
1818
"app": "example-go",
1919
"routable": true,
20+
"autodeploy": true,
2021
"autorollback": true,
2122
"allowlist": ["1.2.3.4", "0.0.0.0/0"],
2223
"autoscale": {"cmd": {"min": 3, "max": 8, "cpu_percent": 40}},
@@ -32,6 +33,7 @@ const appSettingsUnsetFixture string = `
3233
"owner": "test",
3334
"app": "unset-test",
3435
"routable": true,
36+
"autodeploy": true,
3537
"autorollback": true,
3638
"allowlist": ["1.2.3.4", "0.0.0.0/0"],
3739
"autoscale": {"cmd": {"min": 3, "max": 8, "cpu_percent": 40}},
@@ -41,8 +43,8 @@ const appSettingsUnsetFixture string = `
4143
"uuid": "de1bf5b5-4a72-4f94-a10c-d2a3741cdf75"
4244
}
4345
`
44-
const appSettingsSetExpected string = `{"routable":true,"allowlist":["1.2.3.4","0.0.0.0/0"],"autorollback":true,"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/drycc/controller-sdk-go","team":"drycc"}}`
45-
const appSettingsUnsetExpected string = `{"routable":true,"allowlist":["1.2.3.4","0.0.0.0/0"],"autorollback":true,"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/drycc/controller-sdk-go","team":"drycc"}}`
46+
const appSettingsSetExpected string = `{"routable":true,"allowlist":["1.2.3.4","0.0.0.0/0"],"autodeploy":true,"autorollback":true,"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/drycc/controller-sdk-go","team":"drycc"}}`
47+
const appSettingsUnsetExpected string = `{"routable":true,"allowlist":["1.2.3.4","0.0.0.0/0"],"autodeploy":true,"autorollback":true,"autoscale":{"cmd":{"min":3,"max":8,"cpu_percent":40}},"label":{"git_repo":"https://github.com/drycc/controller-sdk-go","team":"drycc"}}`
4648

4749
type fakeHTTPServer struct{}
4850

@@ -117,6 +119,7 @@ func TestAppSettingsSet(t *testing.T) {
117119
Owner: "test",
118120
App: "example-go",
119121
Routable: api.NewRoutable(),
122+
Autodeploy: api.NewAutodeploy(),
120123
Autorollback: api.NewAutorollback(),
121124
Allowlist: []string{"1.2.3.4", "0.0.0.0/0"},
122125
Autoscale: map[string]*api.Autoscale{
@@ -137,6 +140,7 @@ func TestAppSettingsSet(t *testing.T) {
137140

138141
appSettingsVars := api.AppSettings{
139142
Routable: api.NewRoutable(),
143+
Autodeploy: api.NewAutodeploy(),
140144
Autorollback: api.NewAutorollback(),
141145
Allowlist: []string{"1.2.3.4", "0.0.0.0/0"},
142146
Autoscale: map[string]*api.Autoscale{
@@ -179,6 +183,7 @@ func TestAppSettingsUnset(t *testing.T) {
179183
Owner: "test",
180184
App: "unset-test",
181185
Routable: api.NewRoutable(),
186+
Autodeploy: api.NewAutodeploy(),
182187
Autorollback: api.NewAutorollback(),
183188
Allowlist: []string{"1.2.3.4", "0.0.0.0/0"},
184189
Autoscale: map[string]*api.Autoscale{
@@ -199,6 +204,7 @@ func TestAppSettingsUnset(t *testing.T) {
199204

200205
appSettingsVars := api.AppSettings{
201206
Routable: api.NewRoutable(),
207+
Autodeploy: api.NewAutodeploy(),
202208
Autorollback: api.NewAutorollback(),
203209
Allowlist: []string{"1.2.3.4", "0.0.0.0/0"},
204210
Autoscale: map[string]*api.Autoscale{
@@ -241,6 +247,7 @@ func TestAppSettingsList(t *testing.T) {
241247
Owner: "test",
242248
App: "example-go",
243249
Routable: api.NewRoutable(),
250+
Autodeploy: api.NewAutodeploy(),
244251
Autorollback: api.NewAutorollback(),
245252
Allowlist: []string{"1.2.3.4", "0.0.0.0/0"},
246253
Autoscale: map[string]*api.Autoscale{

0 commit comments

Comments
 (0)