feat(logs): update 'uc logs' command to support filtering by service/container

This commit is contained in:
Pasha Sviderski
2026-04-22 11:23:21 +10:00
parent cb72f67560
commit 2045819735
8 changed files with 203 additions and 56 deletions
+1 -20
View File
@@ -256,26 +256,7 @@ func (cli *Client) InspectContainer(
return api.MachineServiceContainer{}, fmt.Errorf("inspect service: %w", err)
}
prefixMatchCandidates := []api.MachineServiceContainer{}
for _, c := range append(svc.Containers, svc.HookContainers...) {
if c.Container.ID == containerNameOrID ||
c.Container.Name == containerNameOrID {
return c, nil
}
if strings.HasPrefix(c.Container.ID, containerNameOrID) {
prefixMatchCandidates = append(prefixMatchCandidates, c)
}
}
if len(prefixMatchCandidates) == 1 {
return prefixMatchCandidates[0], nil
} else if len(prefixMatchCandidates) > 1 {
return api.MachineServiceContainer{}, fmt.Errorf(
"multiple containers found with ID prefix '%s'", containerNameOrID)
}
return api.MachineServiceContainer{}, api.ErrNotFound
return svc.FindContainer(containerNameOrID)
}
// StartContainer starts the specified container within the service.