Skip to content

Commit 86ecdde

Browse files
committed
mirror at 20220630195700
1 parent bb43e4c commit 86ecdde

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

api/client/email.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,12 @@ func (c emailClient) Send(ctx context.Context, m *api.EmailSend) (*api.Empty, er
1818
}
1919
return &res, nil
2020
}
21+
22+
func (c emailClient) List(ctx context.Context, m *api.EmailList) (*api.EmailListResult, error) {
23+
var res api.EmailListResult
24+
err := c.inv.invoke(ctx, "email.list", m, &res)
25+
if err != nil {
26+
return nil, err
27+
}
28+
return &res, nil
29+
}

api/email.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package api
33
import (
44
"context"
55
"strings"
6+
"time"
67

78
"github.com/asaskevich/govalidator"
89
"github.com/moonrhythm/validator"
910
)
1011

1112
type Email interface {
1213
Send(ctx context.Context, m *EmailSend) (*Empty, error)
14+
List(ctx context.Context, m *EmailList) (*EmailListResult, error)
1315
}
1416

1517
type EmailSend struct {
@@ -53,7 +55,28 @@ func (m *EmailSend) Valid() error {
5355
}
5456
v.Must(m.Subject != "", "subject required")
5557
v.Must(m.Body.Type.Valid(), "body.type invalid")
56-
v.Must(m.Body.Content != "", "body.content require")
58+
v.Must(m.Body.Content != "", "body.content required")
5759

5860
return WrapValidate(v)
5961
}
62+
63+
type EmailItem struct {
64+
Domain string `json:"domain" yaml:"domain"`
65+
CreatedAt time.Time `json:"createdAt" yaml:"createdAt"`
66+
}
67+
68+
type EmailList struct {
69+
Project string `json:"project" yaml:"project"`
70+
}
71+
72+
func (m *EmailList) Valid() error {
73+
v := validator.New()
74+
75+
v.Must(m.Project != "", "project required")
76+
77+
return WrapValidate(v)
78+
}
79+
80+
type EmailListResult struct {
81+
Items []*EmailItem `json:"items"`
82+
}

api/role.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var permissions = []string{
6868
"serviceaccount.key.delete",
6969
"email.*",
7070
"email.send",
71+
"email.list",
7172
}
7273

7374
func Permissions() []string {

internal/runner/runner.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,21 +382,31 @@ func (rn Runner) deployment(args ...string) error {
382382
resp, err = s.Delete(context.Background(), &req)
383383
case "deploy":
384384
var (
385-
req api.DeploymentDeploy
386-
typ string
387-
port int
385+
req api.DeploymentDeploy
386+
typ string
387+
port int
388+
minReplicas int
389+
maxReplicas int
388390
)
389391
f.StringVar(&req.Location, "location", "", "location")
390392
f.StringVar(&req.Project, "project", "", "project id")
391393
f.StringVar(&req.Name, "name", "", "deployment name")
392394
f.StringVar(&req.Image, "image", "", "docker image")
393395
f.StringVar(&typ, "type", "", "deployment type")
394396
f.IntVar(&port, "port", 0, "port")
397+
f.IntVar(&minReplicas, "minReplicas", 0, "autoscale min replicas")
398+
f.IntVar(&maxReplicas, "maxReplicas", 0, "autoscale max replicas")
395399
f.Parse(args[1:])
396400
req.Type = api.ParseDeploymentTypeString(typ)
397401
if port > 0 {
398402
req.Port = &port
399403
}
404+
if minReplicas > 0 {
405+
req.MinReplicas = &minReplicas
406+
}
407+
if maxReplicas > 0 {
408+
req.MaxReplicas = &maxReplicas
409+
}
400410
resp, err = s.Deploy(context.Background(), &req)
401411
case "set":
402412
return rn.deploymentSet(args[1:]...)

0 commit comments

Comments
 (0)