Support startup/shutdown scripts (#33)

* Support `startup`/`shutdown` scripts

Fixes #26

* Fixed Go modules after rebase

* Fixes after rebase
This commit is contained in:
Fedor Korotkov
2023-03-14 22:15:54 +04:00
committed by GitHub
parent 47fef47d1c
commit 3ecf98c039
12 changed files with 528 additions and 174 deletions
+19
View File
@@ -103,3 +103,22 @@ func (service *VMsService) PortForward(ctx context.Context, name string, port ui
return service.client.wsRequest(ctx, fmt.Sprintf("vms/%s/port-forward", name),
map[string]string{"port": strconv.FormatUint(uint64(port), 10)})
}
func (service *VMsService) StreamEvents(name string) *EventStreamer {
return NewEventStreamer(service.client, fmt.Sprintf("vms/%s/events", name))
}
func (service *VMsService) Logs(ctx context.Context, name string) (lines []string, err error) {
var events []v1.Event
err = service.client.request(ctx, http.MethodGet, fmt.Sprintf("vms/%s/events", name),
nil, &events, nil)
if err != nil {
return
}
for _, event := range events {
if event.Kind == v1.EventKindLogLine {
lines = append(lines, event.Payload)
}
}
return
}