mirror of
https://github.com/siderolabs/talos.git
synced 2026-05-05 12:26:21 +02:00
Rework (and simplify) `DNSResolveCacheController` to use `DNSUpstream` "handle-like" resources. Depends on https://github.com/cosi-project/runtime/pull/400 Signed-off-by: Dmitriy Matrenichev <dmitry.matrenichev@siderolabs.com>
63 lines
1.9 KiB
Go
63 lines
1.9 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 network
|
|
|
|
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"
|
|
)
|
|
|
|
// DNSResolveCacheType is type of DNSResolveCache resource.
|
|
const DNSResolveCacheType = resource.Type("DNSResolveCaches.net.talos.dev")
|
|
|
|
// DNSResolveCache resource holds DNS resolver info.
|
|
type DNSResolveCache = typed.Resource[DNSResolveCacheSpec, DNSResolveCacheExtension]
|
|
|
|
// DNSResolveCacheSpec describes DNS servers status.
|
|
//
|
|
//gotagsrewrite:gen
|
|
type DNSResolveCacheSpec struct {
|
|
Status string `yaml:"status" protobuf:"1"`
|
|
}
|
|
|
|
// NewDNSResolveCache initializes a DNSResolveCache resource.
|
|
func NewDNSResolveCache(id resource.ID) *DNSResolveCache {
|
|
return typed.NewResource[DNSResolveCacheSpec, DNSResolveCacheExtension](
|
|
resource.NewMetadata(NamespaceName, DNSResolveCacheType, id, resource.VersionUndefined),
|
|
DNSResolveCacheSpec{},
|
|
)
|
|
}
|
|
|
|
// DNSResolveCacheExtension provides auxiliary methods for DNSResolveCache.
|
|
type DNSResolveCacheExtension struct{}
|
|
|
|
// ResourceDefinition implements [typed.Extension] interface.
|
|
func (DNSResolveCacheExtension) ResourceDefinition() meta.ResourceDefinitionSpec {
|
|
return meta.ResourceDefinitionSpec{
|
|
Type: DNSResolveCacheType,
|
|
Aliases: []resource.Type{},
|
|
DefaultNamespace: NamespaceName,
|
|
PrintColumns: []meta.PrintColumn{
|
|
{
|
|
Name: "Status",
|
|
JSONPath: "{.status}",
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
proto.RegisterDefaultTypes()
|
|
|
|
err := protobuf.RegisterDynamic[DNSResolveCacheSpec](DNSResolveCacheType, &DNSResolveCache{})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|