Skip to content

Commit bb43e4c

Browse files
committed
mirror at 20220620151948
1 parent 8021841 commit bb43e4c

22 files changed

+339
-93
lines changed

api/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Interface interface {
1313
PullSecret() PullSecret
1414
WorkloadIdentity() WorkloadIdentity
1515
ServiceAccount() ServiceAccount
16+
Email() Email
1617
Collector() Collector
1718
Deployer() Deployer
1819
}

api/client/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ func (c *Client) WorkloadIdentity() api.WorkloadIdentity {
105105
return workloadIdentityClient{c}
106106
}
107107

108+
func (c *Client) Email() api.Email {
109+
return emailClient{c}
110+
}
111+
108112
func (c *Client) Collector() api.Collector {
109113
return collectorClient{c}
110114
}

api/client/domain.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,12 @@ func (c domainClient) Delete(ctx context.Context, m *api.DomainDelete) (*api.Emp
4545
}
4646
return &res, nil
4747
}
48+
49+
func (c domainClient) PurgeCache(ctx context.Context, m *api.DomainGet) (*api.Empty, error) {
50+
var res api.Empty
51+
err := c.inv.invoke(ctx, "domain.purgeCache", m, &res)
52+
if err != nil {
53+
return nil, err
54+
}
55+
return &res, nil
56+
}

api/client/email.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package client
2+
3+
import (
4+
"context"
5+
6+
"github.com/deploys-app/deploys/api"
7+
)
8+
9+
type emailClient struct {
10+
inv invoker
11+
}
12+
13+
func (c emailClient) Send(ctx context.Context, m *api.EmailSend) (*api.Empty, error) {
14+
var res api.Empty
15+
err := c.inv.invoke(ctx, "email.send", m, &res)
16+
if err != nil {
17+
return nil, err
18+
}
19+
return &res, nil
20+
}

api/constraint.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ const (
2525
const (
2626
DeploymentMinReplicas = 1
2727
DeploymentMaxReplicas = 20
28+
DiskMaxSize = 100
2829
)

api/disk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (m *DiskCreate) Valid() error {
3939
v.Mustf(cnt >= MinNameLength && cnt <= MaxNameLength, "name must have length between %d-%d characters", MinNameLength, MaxNameLength)
4040
}
4141
v.Must(m.Size >= 1, "minimum disk size 1 Gi")
42-
v.Must(m.Size <= 20, "maximum disk size 20 Gi")
42+
v.Mustf(m.Size <= DiskMaxSize, "maximum disk size %d Gi", DiskMaxSize)
4343

4444
return WrapValidate(v)
4545
}

api/domain.go

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ type Domain interface {
1414
Get(ctx context.Context, m *DomainGet) (*DomainItem, error)
1515
List(ctx context.Context, m *DomainList) (*DomainListResult, error)
1616
Delete(ctx context.Context, m *DomainDelete) (*Empty, error)
17+
PurgeCache(ctx context.Context, m *DomainGet) (*Empty, error)
1718
}
1819

1920
type DomainCreate struct {
2021
Project string `json:"project" yaml:"project"`
2122
Location string `json:"location" yaml:"location"`
2223
Domain string `json:"domain" yaml:"domain"`
23-
Plan DomainPlan `json:"plan" yaml:"plan"`
24+
Type DomainType `json:"type" yaml:"type"`
2425
}
2526

2627
func (m *DomainCreate) Valid() error {
@@ -35,16 +36,14 @@ func (m *DomainCreate) Valid() error {
3536
}
3637

3738
type DomainGet struct {
38-
Project string `json:"project" yaml:"project"`
39-
Location string `json:"location" yaml:"location"`
40-
Domain string `json:"domain" yaml:"domain"`
39+
Project string `json:"project" yaml:"project"`
40+
Domain string `json:"domain" yaml:"domain"`
4141
}
4242

4343
func (m *DomainGet) Valid() error {
4444
v := validator.New()
4545

4646
v.Must(m.Project != "", "project required")
47-
v.Must(m.Location != "", "location required")
4847
v.Must(govalidator.IsDNSName(m.Domain), "domain invalid")
4948

5049
return WrapValidate(v)
@@ -84,25 +83,51 @@ type DomainItem struct {
8483
Project string `json:"project" yaml:"project"`
8584
Location string `json:"location" yaml:"location"`
8685
Domain string `json:"domain" yaml:"domain"`
87-
Plan DomainPlan `json:"plan" yaml:"plan"`
86+
Type DomainType `json:"type" yaml:"type"`
8887
Verification DomainVerification `json:"verification" yaml:"verification"`
88+
DNSConfig DomainDNSConfig `json:"dnsConfig" yaml:"dnsConfig"`
89+
Status DomainStatus `json:"status" yaml:"status"`
8990
CreatedAt time.Time `json:"createdAt" yaml:"createdAt"`
91+
CreatedBy string `json:"createdBy" yaml:"createdBy"`
9092
}
9193

9294
type DomainVerification struct {
95+
Ownership DomainVerificationOwnership `json:"ownership"`
96+
SSL DomainVerificationSSL `json:"ssl"`
97+
}
98+
99+
type DomainVerificationOwnership struct {
100+
Type string `json:"type"`
101+
Name string `json:"name"`
102+
Value string `json:"value"`
103+
Errors []string `json:"errors"`
104+
}
105+
106+
type DomainVerificationSSL struct {
107+
Records []DomainVerificationSSLRecord `json:"records"`
108+
Errors []string `json:"errors"`
109+
}
110+
111+
type DomainVerificationSSLRecord struct {
112+
TxtName string `json:"txtName"`
113+
TxtValue string `json:"txtValue"`
114+
}
115+
116+
type DomainDNSConfig struct {
117+
IPv4 []string `json:"ipv4" yaml:"ipv4"`
118+
IPv6 []string `json:"ipv6" yaml:"ipv6"`
119+
CName []string `json:"cname" yaml:"cname"`
93120
}
94121

95122
type DomainDelete struct {
96-
Project string `json:"project" yaml:"project"`
97-
Location string `json:"location" yaml:"location"`
98-
Domain string `json:"domain" yaml:"domain"`
123+
Project string `json:"project" yaml:"project"`
124+
Domain string `json:"domain" yaml:"domain"`
99125
}
100126

101127
func (m *DomainDelete) Valid() error {
102128
v := validator.New()
103129

104130
v.Must(m.Project != "", "project required")
105-
v.Must(m.Location != "", "location required")
106131
v.Must(govalidator.IsDNSName(m.Domain), "domain invalid")
107132

108133
return WrapValidate(v)

api/domainplan.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

api/domainplan_string.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

api/domainstatus.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package api
2+
3+
import "encoding/json"
4+
5+
//go:generate stringer -type=DomainStatus -linecomment
6+
type DomainStatus int
7+
8+
const (
9+
DomainStatusPending DomainStatus = iota // pending
10+
DomainStatusSuccess // success
11+
DomainStatusError // error
12+
DomainStatusVerify // verify
13+
)
14+
15+
var allDomainStatus = []DomainStatus{
16+
DomainStatusPending,
17+
DomainStatusSuccess,
18+
DomainStatusError,
19+
DomainStatusVerify,
20+
}
21+
22+
func parseDomainStatus(s string) DomainStatus {
23+
for _, x := range allDomainStatus {
24+
if x.String() == s {
25+
return x
26+
}
27+
}
28+
return DomainStatusPending
29+
}
30+
31+
func (s DomainStatus) MarshalJSON() ([]byte, error) {
32+
return json.Marshal(s.String())
33+
}
34+
35+
func (s *DomainStatus) UnmarshalJSON(b []byte) error {
36+
var t string
37+
err := json.Unmarshal(b, &t)
38+
if err != nil {
39+
return err
40+
}
41+
42+
*s = parseDomainStatus(t)
43+
return nil
44+
}
45+
46+
func (s DomainStatus) MarshalYAML() (interface{}, error) {
47+
return s.String(), nil
48+
}
49+
50+
func (s *DomainStatus) UnmarshalYAML(unmarshal func(interface{}) error) error {
51+
var t string
52+
err := unmarshal(&t)
53+
if err != nil {
54+
return err
55+
}
56+
*s = parseDomainStatus(t)
57+
return nil
58+
}

0 commit comments

Comments
 (0)