Files
orchard/internal/command/logs/vm.go
T
Grigory EntinandNikolay Edigaryev c12f93a90a Fixed logs gluing the lines together. (#87)
* Fixed logs gluing the lines.

* .golangci.yml: disable "depguard" linter

---------

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
2023-06-04 09:42:02 +00:00

39 lines
588 B
Go

package logs
import (
"fmt"
"github.com/cirruslabs/orchard/pkg/client"
"github.com/spf13/cobra"
)
func newLogsVMCommand() *cobra.Command {
command := &cobra.Command{
Use: "vm NAME",
Short: "Retrieve VM logs",
RunE: runLogsVM,
Args: cobra.ExactArgs(1),
}
return command
}
func runLogsVM(cmd *cobra.Command, args []string) error {
name := args[0]
client, err := client.New()
if err != nil {
return err
}
lines, err := client.VMs().Logs(cmd.Context(), name)
if err != nil {
return err
}
for _, line := range lines {
fmt.Println(line)
}
return nil
}