mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-27 14:31: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>
79 lines
2.4 KiB
Go
79 lines
2.4 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 contains SideroLink-related resources.
|
|
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"
|
|
)
|
|
|
|
//go:generate deep-copy -type ConfigSpec -type StatusSpec -type TunnelSpec -header-file ../../../../hack/boilerplate.txt -o deep_copy.generated.go .
|
|
|
|
// ConfigType is type of Config resource.
|
|
const ConfigType = resource.Type("SiderolinkConfigs.siderolink.talos.dev")
|
|
|
|
// ConfigID the singleton config resource ID.
|
|
const ConfigID = resource.ID("siderolink")
|
|
|
|
// Config resource holds Siderolink configuration.
|
|
type Config = typed.Resource[ConfigSpec, ConfigExtension]
|
|
|
|
// ConfigSpec describes Siderolink configuration.
|
|
//
|
|
//gotagsrewrite:gen
|
|
type ConfigSpec struct {
|
|
APIEndpoint string `yaml:"apiEndpoint" protobuf:"1"`
|
|
Host string `yaml:"host" protobuf:"2"`
|
|
JoinToken string `yaml:"joinToken" protobuf:"3"`
|
|
Insecure bool `yaml:"insecure" protobuf:"4"`
|
|
Tunnel bool `yaml:"tunnel" protobuf:"5"`
|
|
}
|
|
|
|
// NewConfig initializes a Config resource.
|
|
func NewConfig(namespace resource.Namespace, id resource.ID) *Config {
|
|
return typed.NewResource[ConfigSpec, ConfigExtension](
|
|
resource.NewMetadata(namespace, ConfigType, id, resource.VersionUndefined),
|
|
ConfigSpec{},
|
|
)
|
|
}
|
|
|
|
// ConfigExtension provides auxiliary methods for Config.
|
|
type ConfigExtension struct{}
|
|
|
|
// ResourceDefinition implements [typed.Extension] interface.
|
|
func (ConfigExtension) ResourceDefinition() meta.ResourceDefinitionSpec {
|
|
return meta.ResourceDefinitionSpec{
|
|
Type: ConfigType,
|
|
Aliases: []resource.Type{},
|
|
DefaultNamespace: config.NamespaceName,
|
|
PrintColumns: []meta.PrintColumn{
|
|
{
|
|
Name: "API Endpoint",
|
|
JSONPath: `{.apiEndpoint}`,
|
|
},
|
|
{
|
|
Name: "Tunnel",
|
|
JSONPath: `{.tunnel}`,
|
|
},
|
|
},
|
|
Sensitivity: meta.Sensitive,
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
proto.RegisterDefaultTypes()
|
|
|
|
err := protobuf.RegisterDynamic[ConfigSpec](ConfigType, &Config{})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|