mirror of
https://github.com/siderolabs/talos.git
synced 2025-09-16 19:31:13 +02:00
Fixes #4420 No functional changes, just moving packages around. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
41 lines
985 B
Go
41 lines
985 B
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 kubespan
|
|
|
|
import "fmt"
|
|
|
|
//go:generate stringer -type=PeerState -linecomment
|
|
|
|
// PeerState is KubeSpan peer current state.
|
|
type PeerState int
|
|
|
|
// MarshalText implements encoding.TextMarshaler.
|
|
func (v PeerState) MarshalText() ([]byte, error) {
|
|
return []byte(v.String()), nil
|
|
}
|
|
|
|
// UnmarshalText implements encoding.TextUnmarshaler.
|
|
func (v *PeerState) UnmarshalText(b []byte) error {
|
|
switch string(b) {
|
|
case "unknown":
|
|
*v = PeerStateUnknown
|
|
case "up":
|
|
*v = PeerStateUp
|
|
case "down":
|
|
*v = PeerStateDown
|
|
default:
|
|
return fmt.Errorf("unsupported value for PeerState: %q", string(b))
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// PeerState constants.
|
|
const (
|
|
PeerStateUnknown PeerState = iota // unknown
|
|
PeerStateUp // up
|
|
PeerStateDown // down
|
|
)
|