mirror of
https://github.com/siderolabs/talos.git
synced 2026-05-05 12:26:21 +02:00
Allow to set build NAME on build, propagate it down to more consumers. Expose name in `Version` resource, and use that in the dashboard next to Talos version. Fix some places where `Name` was hardcoded. Propagate Name down to UKI build. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
68 lines
1.8 KiB
Go
68 lines
1.8 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 runtime
|
|
|
|
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"
|
|
)
|
|
|
|
// VersionType is type of VersionStatus resource.
|
|
const VersionType = resource.Type("Versions.runtime.talos.dev")
|
|
|
|
// Version resource holds version of Talos.
|
|
type Version = typed.Resource[VersionSpec, VersionExtension]
|
|
|
|
// VersionSpec describes version of Talos.
|
|
//
|
|
//gotagsrewrite:gen
|
|
type VersionSpec struct {
|
|
Name string `yaml:"name" protobuf:"2"`
|
|
Version string `yaml:"version" protobuf:"1"`
|
|
}
|
|
|
|
// NewVersion initializes a VersionStatus resource.
|
|
func NewVersion() *Version {
|
|
return typed.NewResource[VersionSpec, VersionExtension](
|
|
resource.NewMetadata(NamespaceName, VersionType, "version", resource.VersionUndefined),
|
|
VersionSpec{},
|
|
)
|
|
}
|
|
|
|
// VersionExtension is auxiliary resource data for VersionStatus.
|
|
type VersionExtension struct{}
|
|
|
|
// ResourceDefinition implements meta.ResourceDefinitionProvider interface.
|
|
func (VersionExtension) ResourceDefinition() meta.ResourceDefinitionSpec {
|
|
return meta.ResourceDefinitionSpec{
|
|
Type: VersionType,
|
|
Aliases: []resource.Type{},
|
|
DefaultNamespace: NamespaceName,
|
|
PrintColumns: []meta.PrintColumn{
|
|
{
|
|
Name: "Name",
|
|
JSONPath: `{.name}`,
|
|
},
|
|
{
|
|
Name: "Version",
|
|
JSONPath: `{.version}`,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
proto.RegisterDefaultTypes()
|
|
|
|
err := protobuf.RegisterDynamic(VersionType, &Version{})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|