-
Notifications
You must be signed in to change notification settings - Fork 452
/
maintenance_root.go
60 lines (48 loc) · 2.05 KB
/
maintenance_root.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 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 secrets
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/crypto/x509"
"github.com/siderolabs/talos/pkg/machinery/proto"
)
// MaintenanceRootType is type of MaintenanceRoot secret resource.
const MaintenanceRootType = resource.Type("MaintenanceRootSecrets.secrets.talos.dev")
// MaintenanceRootID is the Resource ID for MaintenanceRoot.
const MaintenanceRootID = resource.ID("maintenance")
// MaintenanceRoot contains root secrets for the maintenance service.
type MaintenanceRoot = typed.Resource[MaintenanceRootSpec, MaintenanceRootExtension]
// MaintenanceRootSpec describes maintenance service CA.
//
//gotagsrewrite:gen
type MaintenanceRootSpec struct {
CA *x509.PEMEncodedCertificateAndKey `yaml:"ca" protobuf:"1"`
}
// NewMaintenanceRoot initializes a MaintenanceRoot resource.
func NewMaintenanceRoot(id resource.ID) *MaintenanceRoot {
return typed.NewResource[MaintenanceRootSpec, MaintenanceRootExtension](
resource.NewMetadata(NamespaceName, MaintenanceRootType, id, resource.VersionUndefined),
MaintenanceRootSpec{},
)
}
// MaintenanceRootExtension provides auxiliary methods for MaintenanceRoot.
type MaintenanceRootExtension struct{}
// ResourceDefinition implements meta.ResourceDefinitionProvider interface.
func (MaintenanceRootExtension) ResourceDefinition() meta.ResourceDefinitionSpec {
return meta.ResourceDefinitionSpec{
Type: MaintenanceRootType,
Aliases: []resource.Type{},
DefaultNamespace: NamespaceName,
Sensitivity: meta.Sensitive,
}
}
func init() {
proto.RegisterDefaultTypes()
if err := protobuf.RegisterDynamic[MaintenanceRootSpec](MaintenanceRootType, &MaintenanceRoot{}); err != nil {
panic(err)
}
}