Andrey Smirnov 8b245b8f26
feat: implement new image service APIs
These new APIs only support one2one proxying, so they don't have any
hacks, and look as regular gRPC APIs.

Old APIs are deprecated, but still supported.

Implement client-side multiplexing in `talosctl`, provide fallback to
old APIs for legacy Talos versions.

New APIs include removing an image, importing an image.

Extracted from #12392

Co-authored-by: Laura Brehm <laurabrehm@hey.com>
Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
2026-02-02 15:55:56 +04:00

39 lines
1.1 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// Package machine contains the machine service API definitions.
package machine
import (
fmt "fmt"
"github.com/dustin/go-humanize"
)
// Fmt formats the pull progress status into a human-readable string.
func (s *ImageServicePullLayerProgress) Fmt() string {
switch s.GetStatus() {
case ImageServicePullLayerProgress_DOWNLOADING:
return fmt.Sprintf("downloading layer %s/%s (%.1f%%)",
humanize.IBytes(uint64(s.GetOffset())),
humanize.IBytes(uint64(s.GetTotal())),
float64(s.GetOffset())/float64(s.GetTotal())*100.0,
)
case ImageServicePullLayerProgress_DOWNLOAD_COMPLETE:
return "layer download complete"
case ImageServicePullLayerProgress_EXTRACTING:
return fmt.Sprintf("extracting layer (%s)", s.Elapsed.AsDuration())
case ImageServicePullLayerProgress_EXTRACT_COMPLETE:
return "layer pull complete"
case ImageServicePullLayerProgress_ALREADY_EXISTS:
return "layer already exists"
}
return ""
}