Skip to content

Commit

Permalink
mirror at 20220630195700
Browse files Browse the repository at this point in the history
  • Loading branch information
acoshift committed Jun 30, 2022
1 parent bb43e4c commit 86ecdde
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
9 changes: 9 additions & 0 deletions api/client/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ func (c emailClient) Send(ctx context.Context, m *api.EmailSend) (*api.Empty, er
}
return &res, nil
}

func (c emailClient) List(ctx context.Context, m *api.EmailList) (*api.EmailListResult, error) {
var res api.EmailListResult
err := c.inv.invoke(ctx, "email.list", m, &res)
if err != nil {
return nil, err
}
return &res, nil
}
25 changes: 24 additions & 1 deletion api/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package api
import (
"context"
"strings"
"time"

"github.com/asaskevich/govalidator"
"github.com/moonrhythm/validator"
)

type Email interface {
Send(ctx context.Context, m *EmailSend) (*Empty, error)
List(ctx context.Context, m *EmailList) (*EmailListResult, error)
}

type EmailSend struct {
Expand Down Expand Up @@ -53,7 +55,28 @@ func (m *EmailSend) Valid() error {
}
v.Must(m.Subject != "", "subject required")
v.Must(m.Body.Type.Valid(), "body.type invalid")
v.Must(m.Body.Content != "", "body.content require")
v.Must(m.Body.Content != "", "body.content required")

return WrapValidate(v)
}

type EmailItem struct {
Domain string `json:"domain" yaml:"domain"`
CreatedAt time.Time `json:"createdAt" yaml:"createdAt"`
}

type EmailList struct {
Project string `json:"project" yaml:"project"`
}

func (m *EmailList) Valid() error {
v := validator.New()

v.Must(m.Project != "", "project required")

return WrapValidate(v)
}

type EmailListResult struct {
Items []*EmailItem `json:"items"`
}
1 change: 1 addition & 0 deletions api/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var permissions = []string{
"serviceaccount.key.delete",
"email.*",
"email.send",
"email.list",
}

func Permissions() []string {
Expand Down
16 changes: 13 additions & 3 deletions internal/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,21 +382,31 @@ func (rn Runner) deployment(args ...string) error {
resp, err = s.Delete(context.Background(), &req)
case "deploy":
var (
req api.DeploymentDeploy
typ string
port int
req api.DeploymentDeploy
typ string
port int
minReplicas int
maxReplicas int
)
f.StringVar(&req.Location, "location", "", "location")
f.StringVar(&req.Project, "project", "", "project id")
f.StringVar(&req.Name, "name", "", "deployment name")
f.StringVar(&req.Image, "image", "", "docker image")
f.StringVar(&typ, "type", "", "deployment type")
f.IntVar(&port, "port", 0, "port")
f.IntVar(&minReplicas, "minReplicas", 0, "autoscale min replicas")
f.IntVar(&maxReplicas, "maxReplicas", 0, "autoscale max replicas")
f.Parse(args[1:])
req.Type = api.ParseDeploymentTypeString(typ)
if port > 0 {
req.Port = &port
}
if minReplicas > 0 {
req.MinReplicas = &minReplicas
}
if maxReplicas > 0 {
req.MaxReplicas = &maxReplicas
}
resp, err = s.Deploy(context.Background(), &req)
case "set":
return rn.deploymentSet(args[1:]...)
Expand Down

0 comments on commit 86ecdde

Please sign in to comment.