mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-27 06:21:11 +01:00
Add a new resource, `SiderolinkStatus`, which combines the following info: - The Siderolink API endpoint without the query parameters or fragments (potentially sensitive info due to the join token) - The status of the Siderolink connection This resource is not set as sensitive, so it can be retrieved by the users with `os:operator` role (e.g., using `talosctl dashboard` through Omni). Make use of this resource in the dashboard to display the status of the Siderolink connection. Additionally, rework the status columns in the dashboard to: - Display a Linux terminal compatible "tick" or a "cross" prefix for statuses in addition to the red/green color coding. - Move and combine some statuses to save rows and make them more even. Closes siderolabs/talos#8643. Signed-off-by: Utku Ozdemir <utku.ozdemir@siderolabs.com>
74 lines
2.1 KiB
Go
74 lines
2.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 siderolink
|
|
|
|
import (
|
|
"github.com/cosi-project/runtime/pkg/resource"
|
|
"github.com/cosi-project/runtime/pkg/resource/meta"
|
|
"github.com/cosi-project/runtime/pkg/resource/protobuf"
|
|
"github.com/cosi-project/runtime/pkg/resource/typed"
|
|
|
|
"github.com/siderolabs/talos/pkg/machinery/proto"
|
|
"github.com/siderolabs/talos/pkg/machinery/resources/config"
|
|
)
|
|
|
|
// StatusType is the type of Status resource.
|
|
const StatusType = resource.Type("SiderolinkStatuses.siderolink.talos.dev")
|
|
|
|
// StatusID the singleton status resource ID.
|
|
const StatusID = resource.ID("siderolink-status")
|
|
|
|
// Status resource holds Siderolink status.
|
|
type Status = typed.Resource[StatusSpec, StatusExtension]
|
|
|
|
// StatusSpec describes Siderolink status.
|
|
//
|
|
//gotagsrewrite:gen
|
|
type StatusSpec struct {
|
|
// Host is the Siderolink target host.
|
|
Host string `yaml:"host" protobuf:"1"`
|
|
// Connected is the status of the Siderolink GRPC connection.
|
|
Connected bool `yaml:"connected" protobuf:"2"`
|
|
}
|
|
|
|
// NewStatus initializes a Status resource.
|
|
func NewStatus() *Status {
|
|
return typed.NewResource[StatusSpec, StatusExtension](
|
|
resource.NewMetadata(config.NamespaceName, StatusType, StatusID, resource.VersionUndefined),
|
|
StatusSpec{},
|
|
)
|
|
}
|
|
|
|
// StatusExtension provides auxiliary methods for Status.
|
|
type StatusExtension struct{}
|
|
|
|
// ResourceDefinition implements [typed.Extension] interface.
|
|
func (StatusExtension) ResourceDefinition() meta.ResourceDefinitionSpec {
|
|
return meta.ResourceDefinitionSpec{
|
|
Type: StatusType,
|
|
Aliases: []resource.Type{},
|
|
DefaultNamespace: config.NamespaceName,
|
|
PrintColumns: []meta.PrintColumn{
|
|
{
|
|
Name: "Host",
|
|
JSONPath: `{.host}`,
|
|
},
|
|
{
|
|
Name: "Connected",
|
|
JSONPath: `{.connected}`,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
proto.RegisterDefaultTypes()
|
|
|
|
err := protobuf.RegisterDynamic[StatusSpec](StatusType, &Status{})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|