mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-28 12:03:33 +00:00
logs: stream corrosion logs with 'uc machine logs corrosion' from container instead of journal (fixes #392)
This commit is contained in:
@@ -10,31 +10,11 @@ import (
|
||||
"github.com/psviderski/uncloud/pkg/api"
|
||||
)
|
||||
|
||||
const (
|
||||
UnitUncloud = "uncloud"
|
||||
UnitDocker = "docker"
|
||||
UnitCorrosion = "uncloud-corrosion"
|
||||
)
|
||||
|
||||
func ValidUnit(unit string) bool {
|
||||
switch unit {
|
||||
case UnitUncloud:
|
||||
case UnitDocker:
|
||||
case UnitCorrosion:
|
||||
default:
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
const journalctl = "journalctl"
|
||||
|
||||
var commandContext = exec.CommandContext // allow override for test
|
||||
|
||||
func logs(ctx context.Context, unit string, opts api.ServiceLogsOptions) (io.ReadCloser, func() error, error) {
|
||||
if !ValidUnit(unit) {
|
||||
return nil, nil, fmt.Errorf("journal logs: invalid unit: %s", unit)
|
||||
}
|
||||
args := []string{"-u", unit, "--no-hostname"}
|
||||
args = append(args, "-n")
|
||||
if opts.Tail > -1 {
|
||||
|
||||
Reference in New Issue
Block a user