Skip to content

Commit 17b4aad

Browse files
committed
feat(services): Add pause and resume commands
1 parent 4cb16c3 commit 17b4aad

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

pkg/koyeb/services.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ func NewServiceCmd() *cobra.Command {
124124
}
125125
serviceCmd.AddCommand(deleteServiceCmd)
126126

127+
pauseServiceCmd := &cobra.Command{
128+
Use: "pause NAME",
129+
Short: "Pause service",
130+
Args: cobra.ExactArgs(1),
131+
RunE: h.Pause,
132+
}
133+
serviceCmd.AddCommand(pauseServiceCmd)
134+
135+
resumeServiceCmd := &cobra.Command{
136+
Use: "resume NAME",
137+
Short: "Resume service",
138+
Args: cobra.ExactArgs(1),
139+
RunE: h.Resume,
140+
}
141+
serviceCmd.AddCommand(resumeServiceCmd)
142+
127143
return serviceCmd
128144
}
129145

pkg/koyeb/services_pause.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package koyeb
2+
3+
import (
4+
log "github.com/sirupsen/logrus"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
func (h *ServiceHandler) Pause(cmd *cobra.Command, args []string) error {
9+
_, resp, err := h.client.ServicesApi.PauseService(h.ctx, h.ResolveServiceArgs(args[0])).Execute()
10+
if err != nil {
11+
fatalApiError(err, resp)
12+
}
13+
log.Infof("Service %s pausing.", args[0])
14+
return nil
15+
}

pkg/koyeb/services_resume.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package koyeb
2+
3+
import (
4+
log "github.com/sirupsen/logrus"
5+
"github.com/spf13/cobra"
6+
)
7+
8+
func (h *ServiceHandler) Resume(cmd *cobra.Command, args []string) error {
9+
_, resp, err := h.client.ServicesApi.ResumeService(h.ctx, h.ResolveServiceArgs(args[0])).Execute()
10+
if err != nil {
11+
fatalApiError(err, resp)
12+
}
13+
log.Infof("Service %s resuming.", args[0])
14+
return nil
15+
}

0 commit comments

Comments
 (0)