mirror of
https://github.com/siderolabs/talos.git
synced 2026-05-05 12:26:21 +02:00
This PR does those things: - It allows API calls `MetaWrite` and `MetaRead` in maintenance mode. - SystemInformation resource now waits for available META - SystemInformation resource now overwrites UUID from META if there is an override - META now supports "UUID override" and "unique token" keys - ProvisionRequest now includes unique token and Talos version For #7694 Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
68 lines
2.2 KiB
Go
68 lines
2.2 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"
|
|
)
|
|
|
|
const (
|
|
// UniqueMachineTokenType is type of [UniqueMachineToken] resource.
|
|
UniqueMachineTokenType = resource.Type("UniqueMachineTokens.runtime.talos.dev")
|
|
|
|
// UniqueMachineTokenID is the ID of [UniqueMachineToken] resource.
|
|
UniqueMachineTokenID = resource.ID("unique-machine-token")
|
|
)
|
|
|
|
// UniqueMachineToken resource appears when all meta keys are loaded.
|
|
type UniqueMachineToken = typed.Resource[UniqueMachineTokenSpec, UniqueMachineTokenExtension]
|
|
|
|
// UniqueMachineTokenSpec is the spec for the machine unique token. Token can be empty if machine wasn't assigned any.
|
|
//
|
|
//gotagsrewrite:gen
|
|
type UniqueMachineTokenSpec struct {
|
|
Token string `yaml:"token" protobuf:"1"`
|
|
}
|
|
|
|
// NewUniqueMachineToken initializes a [UniqueMachineToken] resource.
|
|
func NewUniqueMachineToken() *UniqueMachineToken {
|
|
return typed.NewResource[UniqueMachineTokenSpec, UniqueMachineTokenExtension](
|
|
resource.NewMetadata(NamespaceName, UniqueMachineTokenType, UniqueMachineTokenID, resource.VersionUndefined),
|
|
UniqueMachineTokenSpec{},
|
|
)
|
|
}
|
|
|
|
// UniqueMachineTokenExtension is auxiliary resource data for [UniqueMachineToken].
|
|
type UniqueMachineTokenExtension struct{}
|
|
|
|
// ResourceDefinition implements [meta.ResourceDefinitionProvider] interface.
|
|
func (UniqueMachineTokenExtension) ResourceDefinition() meta.ResourceDefinitionSpec {
|
|
return meta.ResourceDefinitionSpec{
|
|
Type: UniqueMachineTokenType,
|
|
Aliases: []resource.Type{},
|
|
DefaultNamespace: NamespaceName,
|
|
PrintColumns: []meta.PrintColumn{
|
|
{
|
|
Name: "Token",
|
|
JSONPath: `{.token}`,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
proto.RegisterDefaultTypes()
|
|
|
|
err := protobuf.RegisterDynamic[UniqueMachineTokenSpec](UniqueMachineTokenType, &UniqueMachineToken{})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|