chore: update gen and COSI runtime

No actual changes, adapting to use new APIs.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
This commit is contained in:
Andrey Smirnov 2023-09-21 14:42:16 +04:00
parent 29b201d619
commit a52d3cda3b
No known key found for this signature in database
GPG Key ID: FE042E3D4085A811
156 changed files with 514 additions and 490 deletions

View File

@ -10,7 +10,7 @@ import (
"os"
"runtime"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
@ -71,7 +71,7 @@ var rootCmd = &cobra.Command{
},
}
prof.Input.SystemExtensions = slices.Map(
prof.Input.SystemExtensions = xslices.Map(
cmdFlags.SystemExtensionImages,
func(imageRef string) profile.ContainerAsset {
return profile.ContainerAsset{

View File

@ -14,7 +14,7 @@ import (
"text/tabwriter"
"github.com/dustin/go-humanize"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/spf13/cobra"
"github.com/siderolabs/talos/pkg/cli"
@ -55,11 +55,11 @@ func showCluster(cluster provision.Cluster) error {
fmt.Fprintf(w, "NAME\t%s\n", cluster.Info().ClusterName)
fmt.Fprintf(w, "NETWORK NAME\t%s\n", cluster.Info().Network.Name)
cidrs := slices.Map(cluster.Info().Network.CIDRs, netip.Prefix.String)
cidrs := xslices.Map(cluster.Info().Network.CIDRs, netip.Prefix.String)
fmt.Fprintf(w, "NETWORK CIDR\t%s\n", strings.Join(cidrs, ","))
gateways := slices.Map(cluster.Info().Network.GatewayAddrs, netip.Addr.String)
gateways := xslices.Map(cluster.Info().Network.GatewayAddrs, netip.Addr.String)
fmt.Fprintf(w, "NETWORK GATEWAY\t%s\n", strings.Join(gateways, ","))
fmt.Fprintf(w, "NETWORK MTU\t%d\n", cluster.Info().Network.MTU)
@ -93,7 +93,7 @@ func showCluster(cluster provision.Cluster) error {
disk = humanize.Bytes(node.DiskSize)
}
ips := slices.Map(node.IPs, netip.Addr.String)
ips := xslices.Map(node.IPs, netip.Addr.String)
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\n",
node.Name,

View File

@ -9,10 +9,11 @@ import (
"net/url"
"os"
"path/filepath"
"slices"
"strings"
"github.com/hashicorp/go-multierror"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
sideronet "github.com/siderolabs/net"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
@ -277,7 +278,7 @@ func validateFlags() error {
var err error
for _, outputType := range genConfigCmdFlags.outputTypes {
if !slices.Contains(allOutputTypes, func(t string) bool {
if !slices.ContainsFunc(allOutputTypes, func(t string) bool {
return t == outputType
}) {
err = multierror.Append(err, fmt.Errorf("invalid output type: %q", outputType))
@ -288,7 +289,7 @@ func validateFlags() error {
}
func writeConfigBundle(configBundle *bundle.Bundle, outputPaths configOutputPaths, commentsFlags encoder.CommentsFlags) error {
outputTypesSet := slices.ToSet(genConfigCmdFlags.outputTypes)
outputTypesSet := xslices.ToSet(genConfigCmdFlags.outputTypes)
if _, ok := outputTypesSet[controlPlaneOutputType]; ok {
data, err := configBundle.Serialize(commentsFlags, machine.TypeControlPlane)

View File

@ -7,7 +7,7 @@ package mgmt
import (
"fmt"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-loadbalancer/loadbalancer"
"github.com/spf13/cobra"
"go.uber.org/zap"
@ -33,7 +33,7 @@ var loadbalancerLaunchCmd = &cobra.Command{
lb := loadbalancer.TCP{Logger: makeLogger()}
for _, port := range loadbalancerLaunchCmdFlags.ports {
upstreams := slices.Map(loadbalancerLaunchCmdFlags.upstreams, func(upstream string) string {
upstreams := xslices.Map(loadbalancerLaunchCmdFlags.upstreams, func(upstream string) string {
return fmt.Sprintf("%s:%d", upstream, port)
})

View File

@ -14,7 +14,7 @@ import (
"text/tabwriter"
"github.com/dustin/go-humanize"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/spf13/cobra"
snapshot "go.etcd.io/etcd/etcdutl/v3/snapshot"
"google.golang.org/grpc/codes"
@ -98,7 +98,7 @@ var etcdAlarmListCmd = &cobra.Command{
cli.Warning("%s", err)
}
return displayAlarms(slices.Map(response.Messages, func(v *machine.EtcdAlarm) alarmMessage {
return displayAlarms(xslices.Map(response.Messages, func(v *machine.EtcdAlarm) alarmMessage {
return v
}))
})
@ -120,7 +120,7 @@ var etcdAlarmDisarmCmd = &cobra.Command{
cli.Warning("%s", err)
}
return displayAlarms(slices.Map(response.Messages, func(v *machine.EtcdAlarmDisarm) alarmMessage {
return displayAlarms(xslices.Map(response.Messages, func(v *machine.EtcdAlarmDisarm) alarmMessage {
return v
}))
})

View File

@ -13,7 +13,7 @@ import (
"text/tabwriter"
"time"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/spf13/cobra"
"github.com/siderolabs/talos/cmd/talosctl/pkg/talos/helpers"
@ -100,7 +100,7 @@ var eventsCmd = &cobra.Command{
msg.GetStage().String(),
fmt.Sprintf("ready: %v, unmet conditions: %v",
msg.GetStatus().Ready,
slices.Map(msg.GetStatus().GetUnmetConditions(),
xslices.Map(msg.GetStatus().GetUnmetConditions(),
func(c *machine.MachineStatusEvent_MachineStatus_UnmetCondition) string {
return c.Name
},

View File

@ -239,7 +239,7 @@ func completeResourceDefinition(withAliases bool) ([]string, cobra.ShellCompDire
return err
}
for iter := safe.IteratorFromList(items); iter.Next(); {
for iter := items.Iterator(); iter.Next(); {
if withAliases {
result = append(result, iter.Value().TypedSpec().Aliases...)
}
@ -296,9 +296,7 @@ func CompleteNodes(*cobra.Command, []string, string) ([]string, cobra.ShellCompD
return err
}
it := safe.IteratorFromList(items)
for it.Next() {
for it := items.Iterator(); it.Next(); {
if hostname := it.Value().TypedSpec().Hostname; hostname != "" {
nodes = append(nodes, hostname)
}

View File

@ -13,7 +13,7 @@ import (
"sync"
criconstants "github.com/containerd/containerd/pkg/cri/constants"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/spf13/cobra"
"google.golang.org/grpc/codes"
@ -136,7 +136,7 @@ func (slicer *lineSlicer) chopper(r io.Reader, hostname string) {
for scanner.Scan() {
line := scanner.Bytes()
line = slices.Copy(line, len(line))
line = xslices.CopyN(line, len(line))
slicer.respCh <- &common.Data{
Metadata: &common.Metadata{

View File

@ -8,12 +8,12 @@ import (
"context"
"fmt"
"io"
"slices"
"sort"
"strings"
criconstants "github.com/containerd/containerd/pkg/cri/constants"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"

View File

@ -14,7 +14,7 @@ import (
"time"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/grpc/peer"
@ -152,7 +152,7 @@ func init() {
return machine.UpgradeRequest_RebootMode_value[rebootModes[i]] < machine.UpgradeRequest_RebootMode_value[rebootModes[j]]
})
rebootModes = slices.Map(rebootModes, strings.ToLower)
rebootModes = xslices.Map(rebootModes, strings.ToLower)
upgradeCmd.Flags().StringVarP(&upgradeCmdFlags.upgradeImage, "image", "i",
fmt.Sprintf("%s/%s/installer:%s", images.Registry, images.Username, version.Trim(version.Tag)),

28
go.mod
View File

@ -1,6 +1,6 @@
module github.com/siderolabs/talos
go 1.21
go 1.21.1
replace (
// Use nested module.
@ -38,7 +38,7 @@ require (
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v1.3.0
github.com/coreos/go-iptables v0.7.0
github.com/cosi-project/runtime v0.3.1
github.com/cosi-project/runtime v0.3.9
github.com/docker/distribution v2.8.2+incompatible
github.com/docker/docker v24.0.5+incompatible
github.com/docker/go-connections v0.4.0
@ -94,7 +94,7 @@ require (
github.com/siderolabs/crypto v0.4.1
github.com/siderolabs/discovery-api v0.1.3
github.com/siderolabs/discovery-client v0.1.5
github.com/siderolabs/gen v0.4.5
github.com/siderolabs/gen v0.4.7
github.com/siderolabs/go-blockdevice v0.4.6
github.com/siderolabs/go-circular v0.1.0
github.com/siderolabs/go-cmd v0.1.1
@ -127,16 +127,16 @@ require (
go.etcd.io/etcd/client/pkg/v3 v3.5.9
go.etcd.io/etcd/client/v3 v3.5.9
go.etcd.io/etcd/etcdutl/v3 v3.5.9
go.uber.org/zap v1.25.0
go.uber.org/zap v1.26.0
go4.org/netipx v0.0.0-20230728184502-ec4c8b891b28
golang.org/x/net v0.14.0
golang.org/x/net v0.15.0
golang.org/x/sync v0.3.0
golang.org/x/sys v0.11.0
golang.org/x/term v0.11.0
golang.org/x/text v0.12.0
golang.org/x/sys v0.12.0
golang.org/x/term v0.12.0
golang.org/x/text v0.13.0
golang.org/x/time v0.3.0
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6
google.golang.org/grpc v1.58.0
google.golang.org/grpc v1.58.1
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/klog/v2 v2.100.1
@ -153,7 +153,7 @@ require (
github.com/Microsoft/hcsshim v0.9.9 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f // indirect
github.com/ProtonMail/gopenpgp/v2 v2.7.2 // indirect
github.com/ProtonMail/gopenpgp/v2 v2.7.3 // indirect
github.com/adrg/xdg v0.4.0 // indirect
github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2 // indirect
github.com/aws/aws-sdk-go-v2 v1.21.0 // indirect
@ -210,7 +210,7 @@ require (
github.com/gorilla/mux v1.8.0 // indirect
github.com/gosuri/uilive v0.0.4 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-envparse v0.1.0
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
@ -292,15 +292,15 @@ require (
go.opentelemetry.io/otel/trace v1.10.0 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/crypto v0.13.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/tools v0.11.0 // indirect
golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect
golang.zx2c4.com/wireguard v0.0.0-20230325221338-052af4a8072b // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect

52
go.sum
View File

@ -92,8 +92,8 @@ github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 h1:KLq8BE0KwC
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f h1:tCbYj7/299ekTTXpdwKYF8eBlsYsDVoggDAuAjoK66k=
github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f/go.mod h1:gcr0kNtGBqin9zDW9GOHcVntrwnjrK+qdJ06mWYBybw=
github.com/ProtonMail/gopenpgp/v2 v2.7.2 h1:mIwxSUPezxNYq0RA5106VPWyKC+Ly3FvBUnBJh/7GWw=
github.com/ProtonMail/gopenpgp/v2 v2.7.2/go.mod h1:IhkNEDaxec6NyzSI0PlxapinnwPVIESk8/76da3Ct3g=
github.com/ProtonMail/gopenpgp/v2 v2.7.3 h1:AJu1OI/1UWVYZl6QcCLKGu9OTngS2r52618uGlje84I=
github.com/ProtonMail/gopenpgp/v2 v2.7.3/go.mod h1:IhkNEDaxec6NyzSI0PlxapinnwPVIESk8/76da3Ct3g=
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
@ -331,8 +331,8 @@ github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosi-project/runtime v0.3.1 h1:dRGKOlEDKjvuC+VIG4N2Z5iAftaqgS1h3ttmvbK4nMk=
github.com/cosi-project/runtime v0.3.1/go.mod h1:Q+oiWic2l6TaGuIWtUo0E9tL2RDT2APHvjUc/mJtn24=
github.com/cosi-project/runtime v0.3.9 h1:tQu+vr1/HonI4Th8fnZbSUvzU635d2a3gWLv/PnBN3g=
github.com/cosi-project/runtime v0.3.9/go.mod h1:kLIIwnTlUnVPhZZN82esCuyvD23eNJkOcnjWE7i+qBk=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
@ -624,8 +624,8 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2 h1:dygLcbEBA+t/P7ck6a8AkXv6juQ4cK0RHBoh32jxhHM=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.2/go.mod h1:Ap9RLCIJVtgQg1/BBgVEfypOAySvvlcpcVQkSzJCH4Y=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0 h1:RtRsiaGvWxcwd8y3BiRZxsylPT8hLWZ5SPcfI+3IDNk=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.0/go.mod h1:TzP6duP4Py2pHLVPPQp42aoYI92+PCrVotyR5e8Vqlk=
github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
@ -1010,8 +1010,8 @@ github.com/siderolabs/discovery-api v0.1.3 h1:37ue+0w2A7Q2FrhyuDbfdhL4VPvDTpCzUY
github.com/siderolabs/discovery-api v0.1.3/go.mod h1:fC6DOJwYQy2QsMCLLTvoScKmBCMNza+VwK2/RHLsoHU=
github.com/siderolabs/discovery-client v0.1.5 h1:CyaOOynanZdB29v46lyEOaNfPoBnKjjEBwdYbyCZEh4=
github.com/siderolabs/discovery-client v0.1.5/go.mod h1:XFSNX7ADu+4r3j/m299V6pP7f4vEDnSJJhgc5yZE73g=
github.com/siderolabs/gen v0.4.5 h1:rwXUVJlL7hYza1LrSVXfT905ZC9Rgei37jMKKs/+eP0=
github.com/siderolabs/gen v0.4.5/go.mod h1:wS8tFq7sn5vqKAuyS30vJUig3tX5v6q79VG4KfUnILM=
github.com/siderolabs/gen v0.4.7 h1:lM69UYggT7yzpubf7hEFaNujPdY55Y9zvQf/NC18GvA=
github.com/siderolabs/gen v0.4.7/go.mod h1:4PBYMdXxTg292IDRq4CGn5AymyDxJVEDvobVKDqFBEA=
github.com/siderolabs/go-api-signature v0.2.6 h1:X4Q+J7CmyfUHKUR+4x4RqmmSSksQ2pYGDajwVX8ZaJ0=
github.com/siderolabs/go-api-signature v0.2.6/go.mod h1:jt7azUqWctrkn7XuTPunfkWllvGPIfRJW8AS3OVkiqE=
github.com/siderolabs/go-blockdevice v0.4.6 h1:yfxFYzXezzszB0mSF2ZG8jPPampoNXa9r8W8nM0IoZI=
@ -1229,8 +1229,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c=
go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk=
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
go4.org/netipx v0.0.0-20230728184502-ec4c8b891b28 h1:zLxFnORHDFTSkJPawMU7LzsuGQJ4MUFS653jJHpORow=
go4.org/netipx v0.0.0-20230728184502-ec4c8b891b28/go.mod h1:TQvodOM+hJTioNQJilmLXu08JNb8i+ccq418+KWu1/Y=
golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
@ -1253,8 +1253,8 @@ golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@ -1348,8 +1348,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@ -1359,8 +1359,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8=
golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI=
golang.org/x/oauth2 v0.12.0 h1:smVPGxink+n1ZI5pkQa8y6fZT0RW0MgCO5bFpepy4B4=
golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba4=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -1477,8 +1477,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -1487,8 +1487,8 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo=
golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -1502,8 +1502,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@ -1661,8 +1661,8 @@ google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5 h1:L6iMMGrtzgHsWofoFcihmDEMYeDR9KN/ThbPWGrh++g=
google.golang.org/genproto v0.0.0-20230803162519-f966b187b2e5/go.mod h1:oH/ZOT02u4kWEp7oYBGYFFkCdKS/uYR9Z7+0/xuuFp8=
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e h1:z3vDksarJxsAKM5dmEGv0GHwE2hKJ096wZra71Vs4sw=
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ=
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d h1:DoPTO70H+bcDXcd39vOqb2viZxgqeBeSGtZ55yZU4/Q=
google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M=
google.golang.org/grpc v0.0.0-20160317175043-d3ddb4469d5a/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
@ -1688,8 +1688,8 @@ google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA5
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.58.0 h1:32JY8YpPMSR45K+c3o6b8VL73V+rR8k+DeMIr4vRH8o=
google.golang.org/grpc v1.58.0/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/grpc v1.58.1 h1:OL+Vz23DTtrrldqHK49FUOPHyY75rvFqJfXC84NYW58=
google.golang.org/grpc v1.58.1/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=

View File

@ -1,4 +1,4 @@
go 1.21
go 1.21.1
use (
.

View File

@ -8,9 +8,9 @@ package director
import (
"context"
"regexp"
"slices"
"strings"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/grpc-proxy/proxy"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
@ -129,7 +129,7 @@ func (r *Router) aggregateDirector(targets []string) (proxy.Mode, []proxy.Backen
// StreamedDetector implements proxy.StreamedDetector.
func (r *Router) StreamedDetector(fullMethodName string) bool {
return slices.Contains(r.streamedMatchers, func(regex *regexp.Regexp) bool { return regex.MatchString(fullMethodName) })
return slices.ContainsFunc(r.streamedMatchers, func(regex *regexp.Regexp) bool { return regex.MatchString(fullMethodName) })
}
// RegisterStreamedRegex register regex for streamed method.

View File

@ -10,10 +10,11 @@ import (
"fmt"
"log"
"net/netip"
"slices"
"strings"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"google.golang.org/grpc/metadata"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -64,7 +65,7 @@ func (s *Server) HealthCheck(in *clusterapi.HealthCheckRequest, srv clusterapi.C
Info: clusterInfo,
}
nodeInternalIPs := slices.Map(clusterInfo.Nodes(), func(info cluster.NodeInfo) string {
nodeInternalIPs := xslices.Map(clusterInfo.Nodes(), func(info cluster.NodeInfo) string {
return info.InternalIP.String()
})
@ -109,10 +110,10 @@ func (cl *clusterState) NodesByType(t machine.Type) []cluster.NodeInfo {
func (cl *clusterState) String() string {
return fmt.Sprintf("control plane: %q, worker: %q",
slices.Map(cl.nodeInfosByType[machine.TypeControlPlane], func(info cluster.NodeInfo) string {
xslices.Map(cl.nodeInfosByType[machine.TypeControlPlane], func(info cluster.NodeInfo) string {
return info.InternalIP.String()
}),
slices.Map(cl.nodeInfosByType[machine.TypeWorker], func(info cluster.NodeInfo) string {
xslices.Map(cl.nodeInfosByType[machine.TypeWorker], func(info cluster.NodeInfo) string {
return info.InternalIP.String()
}))
}
@ -237,7 +238,7 @@ func getDiscoveryMemberList(ctx context.Context, runtime runtime.Runtime) ([]*cl
result := make([]*clusterres.Member, 0, list.Len())
for iter := safe.IteratorFromList(list); iter.Next(); {
for iter := list.Iterator(); iter.Next(); {
result = append(result, iter.Value())
}

View File

@ -13,7 +13,7 @@ import (
"github.com/prometheus/procfs"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"google.golang.org/protobuf/types/known/emptypb"
"github.com/siderolabs/talos/pkg/machinery/api/machine"
@ -188,7 +188,7 @@ func (s *Server) CPUInfo(ctx context.Context, in *emptypb.Empty) (*machine.CPUIn
reply := &machine.CPUInfoResponse{
Messages: []*machine.CPUsInfo{
{
CpuInfo: slices.Map(info, translateCPUInfo),
CpuInfo: xslices.Map(info, translateCPUInfo),
},
},
}

View File

@ -36,7 +36,7 @@ import (
"github.com/nberlee/go-netstat/netstat"
"github.com/prometheus/procfs"
"github.com/rs/xid"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-blockdevice/blockdevice/partition/gpt"
bddisk "github.com/siderolabs/go-blockdevice/blockdevice/util/disk"
"github.com/siderolabs/go-kmsg"
@ -552,7 +552,7 @@ func (opt *ResetOptions) GetSystemDiskTargets() []runtime.PartitionTarget {
return nil
}
return slices.Map(opt.systemDiskTargets, func(t *installer.Target) runtime.PartitionTarget { return t })
return xslices.Map(opt.systemDiskTargets, func(t *installer.Target) runtime.PartitionTarget { return t })
}
// Reset resets the node.
@ -579,7 +579,7 @@ func (s *Server) Reset(ctx context.Context, in *machine.ResetRequest) (reply *ma
return nil, err
}
disks := slices.ToMap(diskList, func(disk *bddisk.Disk) (string, *bddisk.Disk) {
disks := xslices.ToMap(diskList, func(disk *bddisk.Disk) (string, *bddisk.Disk) {
return disk.DeviceName, disk
})
@ -661,7 +661,7 @@ func (s *Server) ServiceList(ctx context.Context, in *emptypb.Empty) (result *ma
result = &machine.ServiceListResponse{
Messages: []*machine.ServiceList{
{
Services: slices.Map(services, (*system.ServiceRunner).AsProto),
Services: xslices.Map(services, (*system.ServiceRunner).AsProto),
},
},
}
@ -1706,8 +1706,8 @@ func (s *Server) EtcdMemberList(ctx context.Context, in *machine.EtcdMemberListR
return &machine.EtcdMemberListResponse{
Messages: []*machine.EtcdMembers{
{
LegacyMembers: slices.Map(resp.Members, (*etcdserverpb.Member).GetName),
Members: slices.Map(resp.Members, func(member *etcdserverpb.Member) *machine.EtcdMember {
LegacyMembers: xslices.Map(resp.Members, (*etcdserverpb.Member).GetName),
Members: xslices.Map(resp.Members, func(member *etcdserverpb.Member) *machine.EtcdMember {
return &machine.EtcdMember{
Id: member.GetID(),
Hostname: member.GetName(),
@ -1954,7 +1954,7 @@ func mapAlarms(alarms []*etcdserverpb.AlarmMember) []*machine.EtcdMemberAlarm {
}
}
return slices.Map(alarms, func(alarm *etcdserverpb.AlarmMember) *machine.EtcdMemberAlarm {
return xslices.Map(alarms, func(alarm *etcdserverpb.AlarmMember) *machine.EtcdMemberAlarm {
return &machine.EtcdMemberAlarm{
MemberId: alarm.MemberID,
Alarm: mapAlarmType(alarm.Alarm),

View File

@ -11,7 +11,7 @@ import (
"fmt"
"io"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/yaml"
@ -95,7 +95,7 @@ func (a manifest) SetYAML(yamlBytes []byte) error {
// Objects returns list of unstructured object.
func (a manifest) Objects() []*unstructured.Unstructured {
return slices.Map(a.Manifest.TypedSpec().Items, func(item k8s.SingleManifest) *unstructured.Unstructured {
return xslices.Map(a.Manifest.TypedSpec().Items, func(item k8s.SingleManifest) *unstructured.Unstructured {
return &unstructured.Unstructured{Object: item.Object}
})
}

View File

@ -8,7 +8,7 @@ import (
"net"
"net/netip"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"go4.org/netipx"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
@ -96,7 +96,7 @@ func (a wireguardSpec) Encode(existing *network.WireguardSpec) (*wgtypes.Config,
PresharedKey: presharedKey,
PersistentKeepaliveInterval: &peer.PersistentKeepaliveInterval,
ReplaceAllowedIPs: true,
AllowedIPs: slices.Map(peer.AllowedIPs, func(peerIP netip.Prefix) net.IPNet {
AllowedIPs: xslices.Map(peer.AllowedIPs, func(peerIP netip.Prefix) net.IPNet {
return *netipx.PrefixIPNet(peerIP)
}),
})
@ -190,7 +190,7 @@ func (a wireguardSpec) Decode(dev *wgtypes.Device, isStatus bool) {
}
spec.Peers[i].PersistentKeepaliveInterval = dev.Peers[i].PersistentKeepaliveInterval
spec.Peers[i].AllowedIPs = slices.Map(dev.Peers[i].AllowedIPs, func(peerIP net.IPNet) netip.Prefix {
spec.Peers[i].AllowedIPs = xslices.Map(dev.Peers[i].AllowedIPs, func(peerIP net.IPNet) netip.Prefix {
res, _ := netipx.FromStdIPNet(&peerIP)
return res

View File

@ -11,7 +11,6 @@ import (
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/siderolabs/gen/channel"
"go.uber.org/zap"
"github.com/siderolabs/talos/pkg/machinery/resources/cluster"
@ -51,8 +50,10 @@ func (ctrl *AffiliateMergeController) Outputs() []controller.Output {
//nolint:gocyclo
func (ctrl *AffiliateMergeController) Run(ctx context.Context, r controller.Runtime, _ *zap.Logger) error {
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok && ctx.Err() != nil {
return nil //nolint:nilerr
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
rawAffiliates, err := safe.ReaderList[*cluster.Affiliate](ctx, r, resource.NewMetadata(cluster.RawNamespaceName, cluster.AffiliateType, "", resource.VersionUndefined))
@ -62,7 +63,7 @@ func (ctrl *AffiliateMergeController) Run(ctx context.Context, r controller.Runt
mergedAffiliates := make(map[resource.ID]*cluster.AffiliateSpec, rawAffiliates.Len())
for it := safe.IteratorFromList(rawAffiliates); it.Next(); {
for it := rawAffiliates.Iterator(); it.Next(); {
affiliateSpec := it.Value().TypedSpec()
id := affiliateSpec.NodeID
@ -95,7 +96,7 @@ func (ctrl *AffiliateMergeController) Run(ctx context.Context, r controller.Runt
return fmt.Errorf("error listing resources: %w", err)
}
for it := safe.IteratorFromList(list); it.Next(); {
for it := list.Iterator(); it.Next(); {
res := it.Value()
if res.Metadata().Owner() != ctrl.Name() {

View File

@ -27,7 +27,7 @@ func cleanupAffiliates(ctx context.Context, ctrl controller.Controller, r contro
return fmt.Errorf("error listing resources: %w", err)
}
for it := safe.IteratorFromList(list); it.Next(); {
for it := list.Iterator(); it.Next(); {
res := it.Value()
if res.Metadata().Owner() != ctrl.Name() {
continue

View File

@ -19,7 +19,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/discovery-api/api/v1alpha1/client/pb"
discoveryclient "github.com/siderolabs/discovery-client/pkg/client"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -327,7 +327,7 @@ func (ctrl *DiscoveryServiceController) Run(ctx context.Context, r controller.Ru
}
func pbAffiliate(affiliate *cluster.AffiliateSpec) *pb.Affiliate {
addresses := slices.Map(affiliate.Addresses, func(address netip.Addr) []byte {
addresses := xslices.Map(affiliate.Addresses, func(address netip.Addr) []byte {
return takeResult(address.MarshalBinary())
})
@ -337,7 +337,7 @@ func pbAffiliate(affiliate *cluster.AffiliateSpec) *pb.Affiliate {
kubeSpan = &pb.KubeSpan{
PublicKey: affiliate.KubeSpan.PublicKey,
Address: takeResult(affiliate.KubeSpan.Address.MarshalBinary()),
AdditionalAddresses: slices.Map(affiliate.KubeSpan.AdditionalAddresses, func(address netip.Prefix) *pb.IPPrefix {
AdditionalAddresses: xslices.Map(affiliate.KubeSpan.AdditionalAddresses, func(address netip.Prefix) *pb.IPPrefix {
return &pb.IPPrefix{
Bits: uint32(address.Bits()),
Ip: takeResult(address.Addr().MarshalBinary()),
@ -371,7 +371,7 @@ func pbEndpoints(affiliate *cluster.AffiliateSpec) []*pb.Endpoint {
return nil
}
return slices.Map(affiliate.KubeSpan.Endpoints, func(endpoint netip.AddrPort) *pb.Endpoint {
return xslices.Map(affiliate.KubeSpan.Endpoints, func(endpoint netip.AddrPort) *pb.Endpoint {
return &pb.Endpoint{
Port: uint32(endpoint.Port()),
Ip: takeResult(endpoint.Addr().MarshalBinary()),
@ -386,7 +386,7 @@ func pbOtherEndpoints(otherEndpointsList safe.List[*kubespan.Endpoint]) []discov
result := make([]discoveryclient.Endpoint, 0, otherEndpointsList.Len())
for it := safe.IteratorFromList(otherEndpointsList); it.Next(); {
for it := otherEndpointsList.Iterator(); it.Next(); {
endpoint := it.Value().TypedSpec()
result = append(result, discoveryclient.Endpoint{

View File

@ -13,7 +13,6 @@ import (
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/siderolabs/gen/channel"
"go.uber.org/zap"
"github.com/siderolabs/talos/pkg/machinery/config/machine"
@ -53,8 +52,10 @@ func (ctrl *EndpointController) Outputs() []controller.Output {
// Run implements controller.Controller interface.
func (ctrl *EndpointController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok && ctx.Err() != nil {
return nil //nolint:nilerr
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
memberList, err := safe.ReaderListAll[*cluster.Member](ctx, r)
@ -64,7 +65,7 @@ func (ctrl *EndpointController) Run(ctx context.Context, r controller.Runtime, l
var endpoints []netip.Addr
for it := safe.IteratorFromList(memberList); it.Next(); {
for it := memberList.Iterator(); it.Next(); {
member := it.Value().TypedSpec()
if !(member.MachineType == machine.TypeControlPlane || member.MachineType == machine.TypeInit) {

View File

@ -9,7 +9,7 @@ import (
"testing"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
@ -71,7 +71,7 @@ func (suite *EndpointSuite) TestReconcileDefault() {
"fd50:8d60:4238:6302:f857:23ff:fe21:d1e0",
"fd50:8d60:4238:6302:f857:23ff:fe21:d1e1",
},
slices.Map(spec.Addresses, netip.Addr.String),
xslices.Map(spec.Addresses, netip.Addr.String),
)
})
}

View File

@ -8,13 +8,13 @@ import (
"context"
"fmt"
"net/netip"
"slices"
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/channel"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"github.com/siderolabs/net"
"go.uber.org/zap"
@ -115,8 +115,10 @@ func (ctrl *LocalAffiliateController) Outputs() []controller.Output {
//nolint:gocyclo,cyclop
func (ctrl *LocalAffiliateController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok && ctx.Err() != nil {
return nil //nolint:nilerr
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
// mandatory resources to be fetched
@ -249,7 +251,7 @@ func (ctrl *LocalAffiliateController) Run(ctx context.Context, r controller.Runt
spec.KubeSpan.AdditionalAddresses = nil
}
endpointIPs := slices.Filter(currentNodeIPs, func(ip netip.Addr) bool {
endpointIPs := xslices.Filter(currentNodeIPs, func(ip netip.Addr) bool {
if ip == spec.KubeSpan.Address {
// skip kubespan local address
return false
@ -264,10 +266,10 @@ func (ctrl *LocalAffiliateController) Run(ctx context.Context, r controller.Runt
})
// mix in discovered public IPs
for iter := safe.IteratorFromList(discoveredPublicIPs); iter.Next(); {
for iter := discoveredPublicIPs.Iterator(); iter.Next(); {
addr := iter.Value().TypedSpec().Address.Addr()
if slices.Contains(endpointIPs, func(a netip.Addr) bool { return addr == a }) {
if slices.ContainsFunc(endpointIPs, func(a netip.Addr) bool { return addr == a }) {
// this address is already published
continue
}
@ -283,7 +285,7 @@ func (ctrl *LocalAffiliateController) Run(ctx context.Context, r controller.Runt
}
}
spec.KubeSpan.Endpoints = slices.Map(endpointIPs, func(addr netip.Addr) netip.AddrPort {
spec.KubeSpan.Endpoints = xslices.Map(endpointIPs, func(addr netip.Addr) netip.AddrPort {
return netip.AddrPortFrom(addr, constants.KubeSpanDefaultPort)
})
}
@ -302,7 +304,7 @@ func (ctrl *LocalAffiliateController) Run(ctx context.Context, r controller.Runt
return fmt.Errorf("error listing resources: %w", err)
}
for it := safe.IteratorFromList(list); it.Next(); {
for it := list.Iterator(); it.Next(); {
res := it.Value()
if res.Metadata().Owner() != ctrl.Name() {

View File

@ -9,7 +9,7 @@ import (
"net/netip"
"testing"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
@ -49,7 +49,7 @@ func (suite *LocalAffiliateSuite) TestGeneration() {
"10.5.0.1",
"192.168.192.168",
"2001:123:4567::1",
}, slices.Map(spec.Addresses, netip.Addr.String))
}, xslices.Map(spec.Addresses, netip.Addr.String))
asrt.Equal("example1", spec.Hostname)
asrt.Equal("example1.com", spec.Nodename)
asrt.Equal(machine.TypeWorker, spec.MachineType)
@ -120,7 +120,7 @@ func (suite *LocalAffiliateSuite) TestGeneration() {
"1.1.1.1:51820",
"[2001:123:4567::1]:51820",
},
slices.Map(spec.KubeSpan.Endpoints, netip.AddrPort.String),
xslices.Map(spec.KubeSpan.Endpoints, netip.AddrPort.String),
)
})
@ -162,7 +162,7 @@ func (suite *LocalAffiliateSuite) TestCPGeneration() {
"10.5.0.1",
"192.168.192.168",
"2001:123:4567::1",
}, slices.Map(spec.Addresses, netip.Addr.String))
}, xslices.Map(spec.Addresses, netip.Addr.String))
asrt.Equal("example1", spec.Hostname)
asrt.Equal("example1.com", spec.Nodename)
asrt.Equal(machine.TypeControlPlane, spec.MachineType)

View File

@ -7,12 +7,11 @@ package cluster
import (
"context"
"fmt"
"slices"
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/siderolabs/gen/channel"
"github.com/siderolabs/gen/slices"
"go.uber.org/zap"
"github.com/siderolabs/talos/pkg/machinery/resources/cluster"
@ -52,8 +51,10 @@ func (ctrl *MemberController) Outputs() []controller.Output {
//nolint:gocyclo
func (ctrl *MemberController) Run(ctx context.Context, r controller.Runtime, _ *zap.Logger) error {
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok && ctx.Err() != nil {
return nil //nolint:nilerr
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
affiliates, err := safe.ReaderListAll[*cluster.Affiliate](ctx, r)
@ -63,7 +64,7 @@ func (ctrl *MemberController) Run(ctx context.Context, r controller.Runtime, _ *
touchedIDs := make(map[resource.ID]struct{})
for it := safe.IteratorFromList(affiliates); it.Next(); {
for it := affiliates.Iterator(); it.Next(); {
affiliateSpec := it.Value().TypedSpec()
if affiliateSpec.Nodename == "" {
// not a cluster member
@ -94,7 +95,7 @@ func (ctrl *MemberController) Run(ctx context.Context, r controller.Runtime, _ *
return fmt.Errorf("error listing resources: %w", err)
}
for it := safe.IteratorFromList(list); it.Next(); {
for it := list.Iterator(); it.Next(); {
res := it.Value()
if res.Metadata().Owner() != ctrl.Name() {

View File

@ -13,6 +13,7 @@ import (
"net/url"
"os"
"path/filepath"
"slices"
"sync"
"testing"
"time"
@ -20,8 +21,6 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/resource/rtestutils"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/channel"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/go-retry/retry"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
@ -186,8 +185,13 @@ func (suite *AcquireSuite) triggerAcquire() {
}
func (suite *AcquireSuite) waitForConfig() config.Provider {
cfg, ok := channel.RecvWithContext(suite.Ctx(), suite.configSetter.cfgCh)
suite.Require().True(ok)
var cfg config.Provider
select {
case cfg = <-suite.configSetter.cfgCh:
case <-suite.Ctx().Done():
suite.Require().Fail("timed out waiting for config")
}
status := v1alpha1.NewAcquireConfigStatus()
rtestutils.AssertResources(suite.Ctx(), suite.T(), suite.State(), []resource.ID{status.Metadata().ID()}, func(*v1alpha1.AcquireConfigStatus, *assert.Assertions) {})
@ -256,8 +260,13 @@ func (suite *AcquireSuite) TestFromDiskToMaintenance() {
suite.triggerAcquire()
cfg, ok := channel.RecvWithContext(suite.Ctx(), suite.configSetter.cfgCh)
suite.Require().True(ok)
var cfg config.Provider
select {
case cfg = <-suite.configSetter.cfgCh:
case <-suite.Ctx().Done():
suite.Require().Fail("timed out waiting for config")
}
suite.Require().Equal(cfg.SideroLink().APIUrl().Host, "siderolink.api")
@ -372,8 +381,13 @@ func (suite *AcquireSuite) TestFromPlatformToMaintenance() {
suite.triggerAcquire()
cfg, ok := channel.RecvWithContext(suite.Ctx(), suite.configSetter.cfgCh)
suite.Require().True(ok)
var cfg config.Provider
select {
case cfg = <-suite.configSetter.cfgCh:
case <-suite.Ctx().Done():
suite.Require().Fail("timed out waiting for config")
}
suite.Require().Equal(cfg.SideroLink().APIUrl().Host, "siderolink.api")

View File

@ -114,7 +114,7 @@ func (ctrl *SeccompProfileFileController) Run(ctx context.Context, r controller.
touchedIDs := make(map[string]struct{}, list.Len())
for iter := safe.IteratorFromList(list); iter.Next(); {
for iter := list.Iterator(); iter.Next(); {
profile := iter.Value()
profileName := profile.TypedSpec().Name

View File

@ -15,7 +15,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.etcd.io/etcd/api/v3/etcdserverpb"
"go.uber.org/zap"
@ -147,7 +147,7 @@ func (ctrl *AdvertisedPeerController) updateAdvertisedPeers(ctx context.Context,
return fmt.Errorf("local member not found in member list")
}
newPeerURLs := slices.Map(advertisedAddresses, func(addr netip.Addr) string {
newPeerURLs := xslices.Map(advertisedAddresses, func(addr netip.Addr) string {
return fmt.Sprintf("https://%s", nethelpers.JoinHostPort(addr.String(), constants.EtcdPeerPort))
})
currentPeerURLs := localMember.PeerURLs

View File

@ -13,7 +13,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"github.com/siderolabs/net"
"go.uber.org/zap"
@ -128,11 +128,11 @@ func (ctrl *SpecController) Run(ctx context.Context, r controller.Runtime, logge
advertisedCIDRs := make([]string, 0, len(advertiseValidSubnets)+len(etcdConfig.TypedSpec().AdvertiseExcludeSubnets))
advertisedCIDRs = append(advertisedCIDRs, advertiseValidSubnets...)
advertisedCIDRs = append(advertisedCIDRs, slices.Map(etcdConfig.TypedSpec().AdvertiseExcludeSubnets, func(cidr string) string { return "!" + cidr })...)
advertisedCIDRs = append(advertisedCIDRs, xslices.Map(etcdConfig.TypedSpec().AdvertiseExcludeSubnets, func(cidr string) string { return "!" + cidr })...)
listenCIDRs := make([]string, 0, len(etcdConfig.TypedSpec().ListenValidSubnets)+len(etcdConfig.TypedSpec().ListenExcludeSubnets))
listenCIDRs = append(listenCIDRs, etcdConfig.TypedSpec().ListenValidSubnets...)
listenCIDRs = append(listenCIDRs, slices.Map(etcdConfig.TypedSpec().ListenExcludeSubnets, func(cidr string) string { return "!" + cidr })...)
listenCIDRs = append(listenCIDRs, xslices.Map(etcdConfig.TypedSpec().ListenExcludeSubnets, func(cidr string) string { return "!" + cidr })...)
defaultListenAddress := netip.AddrFrom4([4]byte{0, 0, 0, 0})
loopbackAddress := netip.AddrFrom4([4]byte{127, 0, 0, 1})

View File

@ -16,7 +16,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
"golang.org/x/sys/unix"
@ -162,7 +162,7 @@ func (ctrl *CRIRegistryConfigController) syncHosts(shadowPath string, criHosts *
return err
}
fileListMap := slices.ToSetFunc(fileList, fs.DirEntry.Name)
fileListMap := xslices.ToSetFunc(fileList, fs.DirEntry.Name)
for _, file := range directory.Files {
delete(fileListMap, file.Name)

View File

@ -8,12 +8,12 @@ import (
"context"
"fmt"
"net/netip"
"slices"
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"

View File

@ -13,7 +13,7 @@ import (
"github.com/cosi-project/runtime/pkg/controller/generic"
"github.com/cosi-project/runtime/pkg/controller/generic/transform"
"github.com/siderolabs/gen/optional"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"go.uber.org/zap"
v1 "k8s.io/api/core/v1"
@ -332,7 +332,7 @@ func NewControlPlaneExtraManifestsController() *ControlPlaneExtraManifestsContro
}
func convertVolumes(volumes []talosconfig.VolumeMount) []k8s.ExtraVolume {
return slices.Map(volumes, func(v talosconfig.VolumeMount) k8s.ExtraVolume {
return xslices.Map(volumes, func(v talosconfig.VolumeMount) k8s.ExtraVolume {
return k8s.ExtraVolume{
Name: v.Name(),
HostPath: v.HostPath(),

View File

@ -16,7 +16,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
v1 "k8s.io/api/core/v1"
@ -235,7 +235,7 @@ func (ctrl *ControlPlaneStaticPodController) teardownAll(ctx context.Context, r
}
func volumeMounts(volumes []k8s.ExtraVolume) []v1.VolumeMount {
return slices.Map(volumes, func(vol k8s.ExtraVolume) v1.VolumeMount {
return xslices.Map(volumes, func(vol k8s.ExtraVolume) v1.VolumeMount {
return v1.VolumeMount{
Name: vol.Name,
MountPath: vol.MountPath,
@ -245,7 +245,7 @@ func volumeMounts(volumes []k8s.ExtraVolume) []v1.VolumeMount {
}
func volumes(volumes []k8s.ExtraVolume) []v1.Volume {
return slices.Map(volumes, func(vol k8s.ExtraVolume) v1.Volume {
return xslices.Map(volumes, func(vol k8s.ExtraVolume) v1.Volume {
return v1.Volume{
Name: vol.Name,
VolumeSource: v1.VolumeSource{
@ -265,7 +265,7 @@ func envVars(environment map[string]string) []v1.EnvVar {
keys := maps.Keys(environment)
sort.Strings(keys)
return slices.Map(keys, func(key string) v1.EnvVar {
return xslices.Map(keys, func(key string) v1.EnvVar {
// Kubernetes supports variable references in variable values, so escape '$' to prevent that.
return v1.EnvVar{
Name: key,

View File

@ -20,7 +20,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/cosi-project/runtime/pkg/state/impl/inmem"
"github.com/cosi-project/runtime/pkg/state/impl/namespaced"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
"github.com/stretchr/testify/suite"
v1 "k8s.io/api/core/v1"
@ -92,7 +92,7 @@ func (suite *ControlPlaneStaticPodSuite) assertControlPlaneStaticPods(manifests
return err
}
ids := slices.Map(resources.Items, func(r resource.Resource) string { return r.Metadata().ID() })
ids := xslices.Map(resources.Items, func(r resource.Resource) string { return r.Metadata().ID() })
if !reflect.DeepEqual(manifests, ids) {
return retry.ExpectedError(fmt.Errorf("expected %q, got %q", manifests, ids))

View File

@ -20,7 +20,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/cosi-project/runtime/pkg/state/impl/inmem"
"github.com/cosi-project/runtime/pkg/state/impl/namespaced"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
"github.com/stretchr/testify/suite"
@ -78,7 +78,7 @@ func (suite *ExtraManifestSuite) assertExtraManifests(manifests []string) error
return err
}
ids := slices.Map(resources.Items, func(r resource.Resource) string { return r.Metadata().ID() })
ids := xslices.Map(resources.Items, func(r resource.Resource) string { return r.Metadata().ID() })
if !reflect.DeepEqual(manifests, ids) {
return retry.ExpectedError(fmt.Errorf("expected %q, got %q", manifests, ids))

View File

@ -14,8 +14,8 @@ import (
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/optional"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xerrors"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -65,7 +65,7 @@ func NewKubeletConfigController() *KubeletConfigController {
return fmt.Errorf("error building DNS service IPs: %w", err)
}
kubeletConfig.ClusterDNS = slices.Map(addrs, netip.Addr.String)
kubeletConfig.ClusterDNS = xslices.Map(addrs, netip.Addr.String)
}
kubeletConfig.ClusterDomain = cfgProvider.Cluster().Network().DNSDomain()

View File

@ -22,7 +22,6 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/channel"
"github.com/siderolabs/gen/optional"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -93,8 +92,10 @@ func (ctrl *KubeletServiceController) Run(ctx context.Context, r controller.Runt
}
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok && ctx.Err() != nil {
return nil //nolint:nilerr
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
_, err := r.Get(ctx, resource.NewMetadata(files.NamespaceName, files.EtcFileStatusType, "machine-id", resource.VersionUndefined))
@ -143,8 +144,10 @@ func (ctrl *KubeletServiceController) Run(ctx context.Context, r controller.Runt
r.QueueReconcile()
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok && ctx.Err() != nil {
return nil //nolint:nilerr
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
cfg, err := safe.ReaderGetByID[*k8s.KubeletSpec](ctx, r, k8s.KubeletID)

View File

@ -15,8 +15,7 @@ import (
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/hashicorp/go-multierror"
"github.com/siderolabs/gen/channel"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -79,8 +78,10 @@ func (ctrl *KubeletSpecController) Outputs() []controller.Output {
//nolint:gocyclo
func (ctrl *KubeletSpecController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok && ctx.Err() != nil {
return nil //nolint:nilerr
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
cfg, err := safe.ReaderGetByID[*k8s.KubeletConfig](ctx, r, k8s.KubeletID)
@ -140,7 +141,7 @@ func (ctrl *KubeletSpecController) Run(ctx context.Context, r controller.Runtime
return fmt.Errorf("error getting node IPs: %w", nodeErr)
}
nodeIPsString := slices.Map(nodeIP.TypedSpec().Addresses, netip.Addr.String)
nodeIPsString := xslices.Map(nodeIP.TypedSpec().Addresses, netip.Addr.String)
args["node-ip"] = strings.Join(nodeIPsString, ",")
}

View File

@ -14,7 +14,7 @@ import (
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-loadbalancer/controlplane"
"github.com/siderolabs/go-loadbalancer/upstream"
"github.com/siderolabs/go-pointer"
@ -172,7 +172,7 @@ func (ctrl *KubePrismController) writeKubePrismStatus(
return fmt.Errorf("error listing KubePrism resources: %w", err)
}
for it := safe.IteratorFromList(list); it.Next(); {
for it := list.Iterator(); it.Next(); {
res := it.Value()
if ctrl.lb == nil || res.Metadata().ID() != k8s.KubePrismStatusesID {
@ -219,7 +219,7 @@ func (ctrl *KubePrismController) startKubePrism(lbCfg *k8s.KubePrismConfig, logg
}
func makeEndpoints(spec *k8s.KubePrismConfigSpec) []string {
return slices.Map(spec.Endpoints, func(e k8s.KubePrismEndpoint) string {
return xslices.Map(spec.Endpoints, func(e k8s.KubePrismEndpoint) string {
return net.JoinHostPort(e.Host, strconv.FormatUint(uint64(e.Port), 10))
})
}

View File

@ -63,7 +63,7 @@ func NewKubePrismEndpointsController() *KubePrismEndpointsController {
})
}
for it := safe.IteratorFromList(members); it.Next(); {
for it := members.Iterator(); it.Next(); {
memberSpec := it.Value().TypedSpec()
if len(memberSpec.Addresses) > 0 && memberSpec.ControlPlane != nil {

View File

@ -13,7 +13,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/state"
"github.com/hashicorp/go-multierror"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
@ -166,7 +166,7 @@ func (ctrl *ManifestApplyController) Run(ctx context.Context, r controller.Runti
if err = r.Modify(ctx, k8s.NewManifestStatus(k8s.ControlPlaneNamespaceName), func(r resource.Resource) error {
status := r.(*k8s.ManifestStatus).TypedSpec()
status.ManifestsApplied = slices.Map(manifests.Items, func(m resource.Resource) string {
status.ManifestsApplied = xslices.Map(manifests.Items, func(m resource.Resource) string {
return m.Metadata().ID()
})
@ -182,7 +182,7 @@ func (ctrl *ManifestApplyController) Run(ctx context.Context, r controller.Runti
//nolint:gocyclo,cyclop
func (ctrl *ManifestApplyController) apply(ctx context.Context, logger *zap.Logger, mapper *restmapper.DeferredDiscoveryRESTMapper, dyn dynamic.Interface, manifests resource.List) error {
// flatten list of objects to be applied
objects := slices.FlatMap(manifests.Items, func(m resource.Resource) []*unstructured.Unstructured {
objects := xslices.FlatMap(manifests.Items, func(m resource.Resource) []*unstructured.Unstructured {
return k8sadapter.Manifest(m.(*k8s.Manifest)).Objects()
})

View File

@ -19,7 +19,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/cosi-project/runtime/pkg/state/impl/inmem"
"github.com/cosi-project/runtime/pkg/state/impl/namespaced"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
"github.com/stretchr/testify/suite"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@ -79,7 +79,7 @@ func (suite *ManifestSuite) assertManifests(manifests []string) error {
return err
}
ids := slices.Map(resources.Items, func(r resource.Resource) string { return r.Metadata().ID() })
ids := xslices.Map(resources.Items, func(r resource.Resource) string { return r.Metadata().ID() })
if !reflect.DeepEqual(manifests, ids) {
return retry.ExpectedError(fmt.Errorf("expected %q, got %q", manifests, ids))

View File

@ -16,7 +16,7 @@ import (
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"github.com/siderolabs/go-retry/retry"
"go.uber.org/zap"
@ -115,7 +115,7 @@ func (ctrl *NodeApplyController) getNodeLabelSpecs(ctx context.Context, r contro
result := make(map[string]string, items.Len())
for iter := safe.IteratorFromList(items); iter.Next(); {
for iter := items.Iterator(); iter.Next(); {
result[iter.Value().TypedSpec().Key] = iter.Value().TypedSpec().Value
}
@ -130,7 +130,7 @@ func (ctrl *NodeApplyController) getNodeTaintSpecs(ctx context.Context, r contro
result := make([]k8s.NodeTaintSpecSpec, 0, items.Len())
for iter := safe.IteratorFromList(items); iter.Next(); {
for iter := items.Iterator(); iter.Next(); {
result = append(result, *iter.Value().TypedSpec())
}
@ -248,7 +248,7 @@ func umarshalOwnedAnnotation(node *v1.Node, annotation string) (map[string]struc
}
}
ownedMap := slices.ToSet(owned)
ownedMap := xslices.ToSet(owned)
if ownedMap == nil {
ownedMap = map[string]struct{}{}
}
@ -400,7 +400,7 @@ func (ctrl *NodeApplyController) ApplyTaints(logger *zap.Logger, node *v1.Node,
}
// remove taints which are owned but are not in the spec
node.Spec.Taints = slices.FilterInPlace(node.Spec.Taints,
node.Spec.Taints = xslices.FilterInPlace(node.Spec.Taints,
func(nodeTaint v1.Taint) bool {
if _, owned := ownedTaints[nodeTaint.Key]; !owned {
return true

View File

@ -9,7 +9,7 @@ import (
"testing"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/stretchr/testify/assert"
"go.uber.org/zap/zaptest"
v1 "k8s.io/api/core/v1"
@ -120,7 +120,7 @@ func TestApplyLabels(t *testing.T) {
node := &v1.Node{}
node.Labels = tt.inputLabels
ownedLabels := slices.ToSet(tt.ownedLabels)
ownedLabels := xslices.ToSet(tt.ownedLabels)
if ownedLabels == nil {
ownedLabels = map[string]struct{}{}
}
@ -305,7 +305,7 @@ func TestApplyTaints(t *testing.T) {
node := &v1.Node{}
node.Spec.Taints = tt.inputTaints
ownedTaints := slices.ToSet(tt.ownedTaints)
ownedTaints := xslices.ToSet(tt.ownedTaints)
if ownedTaints == nil {
ownedTaints = map[string]struct{}{}
}

View File

@ -93,7 +93,7 @@ func (ctrl *NodeCordonedSpecController) Run(ctx context.Context, r controller.Ru
return fmt.Errorf("error getting node cordoned specs: %w", err)
}
for iter := safe.IteratorFromList(nodeCordoned); iter.Next(); {
for iter := nodeCordoned.Iterator(); iter.Next(); {
if err = r.Destroy(ctx, iter.Value().Metadata()); err != nil {
return fmt.Errorf("error destroying node cordoned spec: %w", err)
}

View File

@ -179,7 +179,7 @@ func (ctrl *NodeStatusController) Run(ctx context.Context, r controller.Runtime,
return fmt.Errorf("error listing node statuses: %w", err)
}
for iter := safe.IteratorFromList(items); iter.Next(); {
for iter := items.Iterator(); iter.Next(); {
if _, touched := touchedIDs[iter.Value().Metadata().ID()]; touched {
continue
}

View File

@ -13,7 +13,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"github.com/siderolabs/net"
"go.uber.org/zap"
@ -102,7 +102,7 @@ func (ctrl *NodeIPController) Run(ctx context.Context, r controller.Runtime, log
cidrs := make([]string, 0, len(cfgSpec.ValidSubnets)+len(cfgSpec.ExcludeSubnets))
cidrs = append(cidrs, cfgSpec.ValidSubnets...)
cidrs = append(cidrs, slices.Map(cfgSpec.ExcludeSubnets, func(cidr string) string { return "!" + cidr })...)
cidrs = append(cidrs, xslices.Map(cfgSpec.ExcludeSubnets, func(cidr string) string { return "!" + cidr })...)
ips, err := net.FilterIPs(addrs, cidrs)
if err != nil {

View File

@ -13,7 +13,7 @@ import (
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -82,7 +82,7 @@ func (ctrl *StaticEndpointController) Run(ctx context.Context, r controller.Runt
return fmt.Errorf("error resolving %q: %w", cpHostname, err)
}
addrs = slices.Map(addrs, netip.Addr.Unmap)
addrs = xslices.Map(addrs, netip.Addr.Unmap)
if err = safe.WriterModify(ctx, r, k8s.NewEndpoint(k8s.ControlPlaneNamespaceName, k8s.ControlPlaneKubernetesEndpointsID), func(endpoint *k8s.Endpoint) error {
endpoint.TypedSpec().Addresses = addrs

View File

@ -109,7 +109,7 @@ func (ctrl *StaticPodServerController) buildPodList(ctx context.Context, r contr
touchedPodIDs := map[string]struct{}{}
for iter := safe.IteratorFromList(staticPods); iter.Next(); {
for iter := staticPods.Iterator(); iter.Next(); {
id := iter.Value().Metadata().ID()
version := iter.Value().Metadata().Version().String()

View File

@ -13,12 +13,13 @@ import (
"errors"
"fmt"
"reflect"
"slices"
"sort"
"sync"
"time"
"github.com/siderolabs/crypto/x509"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
taloskubernetes "github.com/siderolabs/go-kubernetes/kubernetes"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
@ -155,7 +156,7 @@ func NewCRDController(
controller := CRDController{
talosCA: talosCA,
allowedNamespaces: allowedNamespaces,
allowedRoles: slices.ToSet(allowedRoles),
allowedRoles: xslices.ToSet(allowedRoles),
dynamicInformerFactory: dynamicInformerFactory,
kubeInformerFactory: kubeInformerFactory,
kubeClient: kubeCli,
@ -353,7 +354,7 @@ func (t *CRDController) syncHandler(ctx context.Context, key string) error {
desiredRoleSet, _ := role.Parse(desiredRoles)
if !slices.Contains(t.allowedNamespaces, func(allowedNS string) bool {
if !slices.ContainsFunc(t.allowedNamespaces, func(allowedNS string) bool {
return allowedNS == namespace
}) {
msg := fmt.Sprintf(messageNamespaceNotAllowed, namespace)

View File

@ -11,7 +11,6 @@ import (
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/siderolabs/gen/channel"
"github.com/siderolabs/gen/value"
"go.uber.org/zap"
@ -58,8 +57,10 @@ func (ctrl *EndpointController) Outputs() []controller.Output {
//nolint:gocyclo
func (ctrl *EndpointController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok && ctx.Err() != nil {
return nil //nolint:nilerr
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
peerStatuses, err := safe.ReaderListAll[*kubespan.PeerStatus](ctx, r)
@ -75,7 +76,7 @@ func (ctrl *EndpointController) Run(ctx context.Context, r controller.Runtime, l
// build lookup table of affiliate's kubespan public key back to affiliate ID
affiliateLookup := make(map[string]string)
for it := safe.IteratorFromList(affiliates); it.Next(); {
for it := affiliates.Iterator(); it.Next(); {
affiliate := it.Value().TypedSpec()
if affiliate.KubeSpan.PublicKey != "" {
@ -86,7 +87,7 @@ func (ctrl *EndpointController) Run(ctx context.Context, r controller.Runtime, l
// for every kubespan peer, if it's up and has endpoint, harvest that endpoint
touchedIDs := make(map[resource.ID]struct{})
for it := safe.IteratorFromList(peerStatuses); it.Next(); {
for it := peerStatuses.Iterator(); it.Next(); {
res := it.Value()
peerStatus := res.TypedSpec()
@ -123,7 +124,7 @@ func (ctrl *EndpointController) Run(ctx context.Context, r controller.Runtime, l
return fmt.Errorf("error listing resources: %w", err)
}
for it := safe.IteratorFromList(list); it.Next(); {
for it := list.Iterator(); it.Next(); {
res := it.Value()
if res.Metadata().Owner() != ctrl.Name() {

View File

@ -17,7 +17,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/cosi-project/runtime/pkg/state/impl/inmem"
"github.com/cosi-project/runtime/pkg/state/impl/namespaced"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
"github.com/stretchr/testify/suite"
@ -66,7 +66,7 @@ func (suite *KubeSpanSuite) assertResourceIDs(md resource.Metadata, expectedIDs
return err
}
actualIDs := slices.Map(l.Items, func(r resource.Resource) string { return r.Metadata().ID() })
actualIDs := xslices.Map(l.Items, func(r resource.Resource) string { return r.Metadata().ID() })
sort.Strings(expectedIDs)

View File

@ -10,12 +10,12 @@ import (
"fmt"
"net/netip"
"os"
"slices"
"time"
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/value"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"

View File

@ -7,13 +7,13 @@ package kubespan
import (
"context"
"fmt"
"slices"
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/channel"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
"go4.org/netipx"
@ -69,8 +69,10 @@ func (ctrl *PeerSpecController) Outputs() []controller.Output {
//nolint:gocyclo,cyclop
func (ctrl *PeerSpecController) Run(ctx context.Context, r controller.Runtime, logger *zap.Logger) error {
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok && ctx.Err() != nil {
return nil //nolint:nilerr
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
cfg, err := safe.ReaderGetByID[*kubespan.Config](ctx, r, kubespan.ConfigID)
@ -96,7 +98,7 @@ func (ctrl *PeerSpecController) Run(ctx context.Context, r controller.Runtime, l
peerIPSets := make(map[string]*netipx.IPSet, affiliates.Len())
affiliateLoop:
for it := safe.IteratorFromList(affiliates); it.Next(); {
for it := affiliates.Iterator(); it.Next(); {
affiliate := it.Value()
if affiliate.Metadata().ID() == localAffiliateID {
@ -183,7 +185,7 @@ func (ctrl *PeerSpecController) Run(ctx context.Context, r controller.Runtime, l
return fmt.Errorf("error listing resources: %w", err)
}
for it := safe.IteratorFromList(list); it.Next(); {
for it := list.Iterator(); it.Next(); {
res := it.Value()
if res.Metadata().Owner() != ctrl.Name() {
@ -203,5 +205,5 @@ func (ctrl *PeerSpecController) Run(ctx context.Context, r controller.Runtime, l
// dumpSet converts IPSet to a form suitable for logging.
func dumpSet(set *netipx.IPSet) []string {
return slices.Map(set.Ranges(), netipx.IPRange.String)
return xslices.Map(set.Ranges(), netipx.IPRange.String)
}

View File

@ -20,7 +20,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/cosi-project/runtime/pkg/state/impl/inmem"
"github.com/cosi-project/runtime/pkg/state/impl/namespaced"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
@ -293,7 +293,7 @@ func assertResources[R rtestutils.ResourceWithRD](
ctx,
t,
state,
slices.Map(requiredIDs, func(id string) resource.ID { return id }),
xslices.Map(requiredIDs, func(id string) resource.ID { return id }),
check,
opts...,
)

View File

@ -12,7 +12,7 @@ import (
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
glob "github.com/ryanuber/go-glob"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -112,7 +112,7 @@ func (ctrl *DeviceConfigController) Run(ctx context.Context, r controller.Runtim
continue
}
out = slices.Map(matched, func(device *v1alpha1.Device) talosconfig.Device { return device })
out = xslices.Map(matched, func(device *v1alpha1.Device) talosconfig.Device { return device })
} else if device.Bond() != nil && len(device.Bond().Selectors()) > 0 {
dev := device.(*v1alpha1.Device).DeepCopy()
device = dev
@ -180,18 +180,18 @@ func (ctrl *DeviceConfigController) expandBondSelector(device *v1alpha1.Device,
for _, selector := range device.Bond().Selectors() {
matches = append(matches,
// filter out bond device itself, as it will inherit the MAC address of the first link
slices.Filter(
xslices.Filter(
ctrl.selectDevices(selector, links),
func(link *network.LinkStatus) bool {
return link.Metadata().ID() != device.Interface()
})...)
}
device.DeviceBond.BondInterfaces = slices.Map(matches, func(link *network.LinkStatus) string { return link.Metadata().ID() })
device.DeviceBond.BondInterfaces = xslices.Map(matches, func(link *network.LinkStatus) string { return link.Metadata().ID() })
if len(device.DeviceBond.BondInterfaces) == 0 {
return fmt.Errorf("no matching network device for defined bond selectors: %v",
slices.Map(device.Bond().Selectors(),
xslices.Map(device.Bond().Selectors(),
func(selector talosconfig.NetworkDeviceSelector) string {
return fmt.Sprintf("%+v", selector)
},
@ -207,7 +207,7 @@ func (ctrl *DeviceConfigController) expandBondSelector(device *v1alpha1.Device,
func (ctrl *DeviceConfigController) selectDevices(selector talosconfig.NetworkDeviceSelector, links safe.List[*network.LinkStatus]) []*network.LinkStatus {
var result []*network.LinkStatus
for iter := safe.IteratorFromList(links); iter.Next(); {
for iter := links.Iterator(); iter.Next(); {
linkStatus := iter.Value().TypedSpec()
match := false

View File

@ -21,7 +21,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/cosi-project/runtime/pkg/state/impl/inmem"
"github.com/cosi-project/runtime/pkg/state/impl/namespaced"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
@ -954,7 +954,7 @@ func TestSortBonds(t *testing.T) {
}
func toResources(slice []network.LinkSpecSpec) []resource.Resource {
return slices.Map(slice, func(spec network.LinkSpecSpec) resource.Resource {
return xslices.Map(slice, func(spec network.LinkSpecSpec) resource.Resource {
link := network.NewLinkSpec(network.NamespaceName, "bar")
*link.TypedSpec() = spec
@ -963,7 +963,7 @@ func toResources(slice []network.LinkSpecSpec) []resource.Resource {
}
func toSpecs(slice []resource.Resource) []network.LinkSpecSpec {
return slices.Map(slice, func(r resource.Resource) network.LinkSpecSpec {
return xslices.Map(slice, func(r resource.Resource) network.LinkSpecSpec {
v := r.Spec().(*network.LinkSpecSpec) //nolint:errcheck
return *v

View File

@ -8,11 +8,11 @@ import (
"context"
"fmt"
"net/netip"
"slices"
"sort"
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/value"
"go.uber.org/zap"
@ -168,7 +168,7 @@ func (ctrl *NodeAddressController) Run(ctx context.Context, r controller.Runtime
// we should start handing default address updates, but for now we're not ready
//
// at the same time check that recorded default address is still on the host, if it's not => replace it
if len(spec.Addresses) > 0 && slices.Contains(current, func(addr netip.Prefix) bool { return spec.Addresses[0] == addr }) {
if len(spec.Addresses) > 0 && slices.ContainsFunc(current, func(addr netip.Prefix) bool { return spec.Addresses[0] == addr }) {
return nil
}

View File

@ -19,7 +19,7 @@ import (
"github.com/insomniacslk/dhcp/dhcpv4"
"github.com/insomniacslk/dhcp/dhcpv4/nclient4"
"github.com/siderolabs/gen/channel"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"go.uber.org/zap"
"go4.org/netipx"
@ -237,7 +237,7 @@ func (d *DHCP4) Run(ctx context.Context, notifyCh chan<- struct{}) {
d.lease = nil
d.logger.Debug("restarting DHCP sequence due to hostname change",
zap.Strings("dhcp_hostname", slices.Map(d.hostname, func(spec network.HostnameSpecSpec) string {
zap.Strings("dhcp_hostname", xslices.Map(d.hostname, func(spec network.HostnameSpecSpec) string {
return spec.Hostname
})),
)
@ -422,7 +422,7 @@ func (d *DHCP4) parseNetworkConfigFromAck(ack *dhcpv4.DHCPv4, useHostname bool)
d.resolvers = []network.ResolverSpecSpec{
{
DNSServers: slices.Map(ack.DNS(), convertIP),
DNSServers: xslices.Map(ack.DNS(), convertIP),
ConfigLayer: network.ConfigOperator,
},
}
@ -439,7 +439,7 @@ func (d *DHCP4) parseNetworkConfigFromAck(ack *dhcpv4.DHCPv4, useHostname bool)
d.timeservers = []network.TimeServerSpecSpec{
{
NTPServers: slices.Map(ack.NTPServers(), convertIP),
NTPServers: xslices.Map(ack.NTPServers(), convertIP),
ConfigLayer: network.ConfigOperator,
},
}

View File

@ -18,7 +18,7 @@ import (
"github.com/insomniacslk/dhcp/dhcpv6"
"github.com/insomniacslk/dhcp/dhcpv6/nclient6"
"github.com/jsimonetti/rtnetlink"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
"go.uber.org/zap"
"go4.org/netipx"
@ -184,7 +184,7 @@ func (d *DHCP6) parseReply(reply *dhcpv6.Message) (leaseTime time.Duration) {
d.resolvers = []network.ResolverSpecSpec{
{
DNSServers: slices.Map(reply.Options.DNS(), convertIP),
DNSServers: xslices.Map(reply.Options.DNS(), convertIP),
ConfigLayer: network.ConfigOperator,
},
}
@ -213,7 +213,7 @@ func (d *DHCP6) parseReply(reply *dhcpv6.Message) (leaseTime time.Duration) {
d.timeservers = []network.TimeServerSpecSpec{
{
NTPServers: slices.Map(reply.Options.NTPServers(), convertIP),
NTPServers: xslices.Map(reply.Options.NTPServers(), convertIP),
ConfigLayer: network.ConfigOperator,
},
}

View File

@ -12,7 +12,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/state"
"github.com/hashicorp/go-multierror"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-procfs/procfs"
"go.uber.org/zap"
@ -118,7 +118,7 @@ func (ctrl *OperatorConfigController) Run(ctx context.Context, r controller.Runt
}
}
devices := slices.Map(items.Items, func(item resource.Resource) talosconfig.Device {
devices := xslices.Map(items.Items, func(item resource.Resource) talosconfig.Device {
return item.(*network.DeviceConfigSpec).TypedSpec().Device
})

View File

@ -13,7 +13,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/state"
"github.com/hashicorp/go-multierror"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-procfs/procfs"
"go.uber.org/zap"
@ -74,7 +74,7 @@ func (ctrl *OperatorVIPConfigController) Run(ctx context.Context, r controller.R
}
}
devices := slices.Map(items.Items, func(item resource.Resource) talosconfig.Device {
devices := xslices.Map(items.Items, func(item resource.Resource) talosconfig.Device {
return item.(*network.DeviceConfigSpec).TypedSpec().Device
})

View File

@ -88,7 +88,7 @@ func (ctrl *ProbeController) reconcileRunners(ctx context.Context, r controller.
// figure out which operators should run
shouldRun := make(map[string]network.ProbeSpecSpec)
for iter := safe.IteratorFromList(specList); iter.Next(); {
for iter := specList.Iterator(); iter.Next(); {
shouldRun[iter.Value().Metadata().ID()] = *iter.Value().TypedSpec()
}
@ -126,7 +126,7 @@ func (ctrl *ProbeController) reconcileRunners(ctx context.Context, r controller.
return fmt.Errorf("error listing probe statuses: %w", err)
}
for iter := safe.IteratorFromList(statusList); iter.Next(); {
for iter := statusList.Iterator(); iter.Next(); {
if _, exists := shouldRun[iter.Value().Metadata().ID()]; exists {
continue
}

View File

@ -12,7 +12,7 @@ import (
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"go.uber.org/zap"
"github.com/siderolabs/talos/pkg/machinery/resources/network"
@ -89,7 +89,7 @@ func (ctrl *ResolverSpecController) Run(ctx context.Context, r controller.Runtim
return fmt.Errorf("error removing finalizer: %w", err)
}
case resource.PhaseRunning:
resolvers := slices.Map(spec.TypedSpec().DNSServers, netip.Addr.String)
resolvers := xslices.Map(spec.TypedSpec().DNSServers, netip.Addr.String)
logger.Info("setting resolvers", zap.Strings("resolvers", resolvers))
if err = r.Modify(ctx, network.NewResolverStatus(network.NamespaceName, spec.Metadata().ID()), func(r resource.Resource) error {

View File

@ -102,7 +102,7 @@ func (ctrl *StatusController) Run(ctx context.Context, r controller.Runtime, log
allProbesSuccess := true
for iter := safe.IteratorFromList(probeStatuses); iter.Next(); {
for iter := probeStatuses.Iterator(); iter.Next(); {
if !iter.Value().TypedSpec().Success {
allProbesSuccess = false
@ -120,7 +120,7 @@ func (ctrl *StatusController) Run(ctx context.Context, r controller.Runtime, log
return fmt.Errorf("error getting routes: %w", err)
}
for iter := safe.IteratorFromList(routes); iter.Next(); {
for iter := routes.Iterator(); iter.Next(); {
if value.IsZero(iter.Value().TypedSpec().Destination) {
result.ConnectivityReady = true

View File

@ -7,12 +7,12 @@ package network
import (
"context"
"fmt"
"slices"
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/go-pointer"
"github.com/siderolabs/go-procfs/procfs"
"go.uber.org/zap"

View File

@ -19,7 +19,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -189,7 +189,7 @@ func (ctrl *CRIImageGCController) Run(ctx context.Context, r controller.Runtime,
func buildExpectedImageNames(logger *zap.Logger, actualImages []images.Image, expectedImages []string) (map[string]struct{}, error) {
var parseErrors []error
expectedReferences := slices.Map(expectedImages, func(ref string) docker.Named {
expectedReferences := xslices.Map(expectedImages, func(ref string) docker.Named {
res, parseErr := docker.ParseNamed(ref)
parseErrors = append(parseErrors, parseErr)

View File

@ -7,6 +7,7 @@ package runtime_test
import (
"context"
"reflect"
"slices"
"sort"
"sync"
"testing"
@ -17,7 +18,7 @@ import (
"github.com/opencontainers/go-digest"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -88,7 +89,7 @@ func (m *mockImageService) Delete(ctx context.Context, name string, opts ...imag
m.mu.Lock()
defer m.mu.Unlock()
m.images = slices.FilterInPlace(m.images, func(i images.Image) bool { return i.Name != name })
m.images = xslices.FilterInPlace(m.images, func(i images.Image) bool { return i.Name != name })
return nil
}
@ -169,13 +170,13 @@ func (suite *CRIImageGCSuite) TestReconcile() {
etcd.TypedSpec().Image = "registry.io/org/image2:v3.5.9@sha256:2f794176e9bd8a28501fa185693dc1073013a048c51585022ebce4f84b469db8"
suite.Require().NoError(suite.State().Create(suite.Ctx(), etcd))
expectedImages := slices.Map(storedImages[2:7], func(i images.Image) string { return i.Name })
expectedImages := xslices.Map(storedImages[2:7], func(i images.Image) string { return i.Name })
suite.Assert().NoError(retry.Constant(5*time.Second, retry.WithUnits(100*time.Millisecond)).Retry(func() error {
suite.fakeClock.Add(runtimectrl.ImageCleanupInterval)
imageList, _ := suite.mockImageService.List(suite.Ctx()) //nolint:errcheck
actualImages := slices.Map(imageList, func(i images.Image) string { return i.Name })
actualImages := xslices.Map(imageList, func(i images.Image) string { return i.Name })
if reflect.DeepEqual(expectedImages, actualImages) {
return nil

View File

@ -14,8 +14,7 @@ import (
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/channel"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-kmsg"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -87,8 +86,10 @@ func (ctrl *KmsgLogDeliveryController) Run(ctx context.Context, r controller.Run
kmsgCh := reader.Scan(ctx)
for {
if _, ok := channel.RecvWithContext(ctx, r.EventCh()); !ok {
select {
case <-ctx.Done():
return nil
case <-r.EventCh():
}
cfg, err := safe.ReaderGetByID[*runtime.KmsgLogConfig](ctx, r, runtime.KmsgLogConfigID)
@ -116,7 +117,7 @@ func (ctrl *KmsgLogDeliveryController) deliverLogs(ctx context.Context, r contro
}
// initialize all log senders
senders := slices.Map(destURLs, logging.NewJSONLines)
senders := xslices.Map(destURLs, logging.NewJSONLines)
defer func() {
closeCtx, closeCtxCancel := context.WithTimeout(context.Background(), logCloseTimeout)

View File

@ -8,11 +8,12 @@ import (
"context"
"fmt"
"net/url"
"slices"
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"github.com/siderolabs/go-procfs/procfs"
"go.uber.org/zap"
@ -85,9 +86,9 @@ func (ctrl *KmsgLogConfigController) Run(ctx context.Context, r controller.Runti
if cfg != nil {
// remove duplicate URLs in case same destination is specified in both machine config and kernel args
destinations = append(destinations, slices.Filter(cfg.Config().Runtime().KmsgLogURLs(),
destinations = append(destinations, xslices.Filter(cfg.Config().Runtime().KmsgLogURLs(),
func(u *url.URL) bool {
return !slices.Contains(destinations, func(v *url.URL) bool {
return !slices.ContainsFunc(destinations, func(v *url.URL) bool {
return v.String() == u.String()
})
})...)

View File

@ -10,7 +10,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/resource/rtestutils"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-procfs/procfs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
@ -73,7 +73,7 @@ func (suite *KmsgLogConfigSuite) TestKmsgLogConfigMachineConfig() {
"https://10.0.0.1:3333/logs",
"https://10.0.0.2:4444/logs",
},
slices.Map(cfg.TypedSpec().Destinations, func(u *url.URL) string { return u.String() }),
xslices.Map(cfg.TypedSpec().Destinations, func(u *url.URL) string { return u.String() }),
)
})
}
@ -90,7 +90,7 @@ func (suite *KmsgLogConfigSuite) TestKmsgLogConfigCmdline() {
func(cfg *runtime.KmsgLogConfig, asrt *assert.Assertions) {
asrt.Equal(
[]string{"https://10.0.0.1:3333/logs"},
slices.Map(cfg.TypedSpec().Destinations, func(u *url.URL) string { return u.String() }),
xslices.Map(cfg.TypedSpec().Destinations, func(u *url.URL) string { return u.String() }),
)
})
}

View File

@ -273,13 +273,11 @@ func (ctrl *MachineStatusController) servicesCheck(requiredServices []string) fu
return err
}
it := safe.IteratorFromList(serviceList)
var problems []string
runningServices := map[string]struct{}{}
for it.Next() {
for it := serviceList.Iterator(); it.Next(); {
service := it.Value()
if !service.TypedSpec().Running {
@ -316,11 +314,9 @@ func (ctrl *MachineStatusController) staticPodsCheck(ctx context.Context, r cont
return err
}
it := safe.IteratorFromList(staticPodList)
var problems []string
for it.Next() {
for it := staticPodList.Iterator(); it.Next(); {
status, err := k8sadapter.StaticPodStatus(it.Value()).Status()
if err != nil {
return err

View File

@ -11,7 +11,7 @@ import (
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -69,7 +69,7 @@ func (ctrl *MachineStatusPublisherController) Run(ctx context.Context, r control
Stage: machine.MachineStatusEvent_MachineStage(machineStatus.TypedSpec().Stage),
Status: &machine.MachineStatusEvent_MachineStatus{
Ready: machineStatus.TypedSpec().Status.Ready,
UnmetConditions: slices.Map(machineStatus.TypedSpec().Status.UnmetConditions,
UnmetConditions: xslices.Map(machineStatus.TypedSpec().Status.UnmetConditions,
func(unmetCondition runtime.UnmetCondition) *machine.MachineStatusEvent_MachineStatus_UnmetCondition {
return &machine.MachineStatusEvent_MachineStatus_UnmetCondition{
Name: unmetCondition.Name,

View File

@ -10,7 +10,7 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/resource/rtestutils"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
@ -66,7 +66,7 @@ func (suite *MachineStatusSuite) assertMachineStatus(stage runtime.MachineStage,
asrt.Equal(ready, machineStatus.TypedSpec().Status.Ready)
asrt.Equal(unmetConditions,
slices.Map(machineStatus.TypedSpec().Status.UnmetConditions, func(c runtime.UnmetCondition) string { return c.Name }))
xslices.Map(machineStatus.TypedSpec().Status.UnmetConditions, func(c runtime.UnmetCondition) string { return c.Name }))
})
}

View File

@ -12,7 +12,7 @@ import (
"github.com/cosi-project/runtime/pkg/controller"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -90,7 +90,7 @@ func (ctrl *MaintenanceConfigController) Run(ctx context.Context, r controller.R
// * if it exists, find the SideroLink address and listen only on it
case err == nil:
if nodeAddresses != nil {
sideroLinkAddresses := slices.Filter(nodeAddresses.TypedSpec().IPs(), func(addr netip.Addr) bool {
sideroLinkAddresses := xslices.Filter(nodeAddresses.TypedSpec().IPs(), func(addr netip.Addr) bool {
return network.IsULA(addr, network.ULASideroLink)
})

View File

@ -18,7 +18,7 @@ import (
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/crypto/x509"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-debug"
"github.com/siderolabs/go-pointer"
"go.uber.org/zap"
@ -253,7 +253,7 @@ func (ctrl *MaintenanceServiceController) Run(ctx context.Context, r controller.
}
// print additional information for the user on important state changes
reachableAddresses := slices.Map(cfg.TypedSpec().ReachableAddresses, netip.Addr.String)
reachableAddresses := xslices.Map(cfg.TypedSpec().ReachableAddresses, netip.Addr.String)
if !reflect.DeepEqual(lastReachableAddresses, reachableAddresses) {
logger.Info("this machine is reachable at:")

View File

@ -321,7 +321,7 @@ func (ctrl *ManagerController) cleanupLinkSpecs(ctx context.Context, r controlle
return err
}
for iter := safe.IteratorFromList(list); iter.Next(); {
for iter := list.Iterator(); iter.Next(); {
link := iter.Value()
if link.Metadata().Owner() != ctrl.Name() {
@ -349,7 +349,7 @@ func (ctrl *ManagerController) cleanupAddressSpecs(ctx context.Context, r contro
return err
}
for iter := safe.IteratorFromList(list); iter.Next(); {
for iter := list.Iterator(); iter.Next(); {
address := iter.Value()
if address.Metadata().Owner() != ctrl.Name() {

View File

@ -9,6 +9,7 @@ import (
"fmt"
"log"
"reflect"
"slices"
"sync"
"testing"
"time"
@ -18,7 +19,6 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/cosi-project/runtime/pkg/state/impl/inmem"
"github.com/cosi-project/runtime/pkg/state/impl/namespaced"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/go-pointer"
"github.com/siderolabs/go-retry/retry"
"github.com/stretchr/testify/suite"

View File

@ -145,7 +145,7 @@ func (p *EquinixMetal) ParseMetadata(ctx context.Context, equinixMetadata *Metad
found := false
hostInterfaceIter := safe.IteratorFromList(hostInterfaces)
hostInterfaceIter := hostInterfaces.Iterator()
for hostInterfaceIter.Next() {
// match using permanent MAC address:

View File

@ -13,7 +13,7 @@ import (
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
)
// Populate populates the config download URL with values replacing variables.
@ -57,11 +57,11 @@ func PopulateVariables(ctx context.Context, downloadURL string, st state.State,
}
}
pendingVariables := slices.ToSet(activeVariables)
pendingVariables := xslices.ToSet(activeVariables)
// wait for all variables to be populated
for len(pendingVariables) > 0 {
log.Printf("waiting for URL variables: %v", slices.Map(maps.Keys(pendingVariables), func(v *Variable) string { return v.Key }))
log.Printf("waiting for URL variables: %v", xslices.Map(maps.Keys(pendingVariables), func(v *Variable) string { return v.Key }))
var ev state.Event

View File

@ -544,7 +544,7 @@ func (n *Nocloud) applyNetworkConfigV2(config *NetworkConfig, st state.State, ne
var availableMACAddresses []string
macAddressMatched := false
hostInterfaceIter := safe.IteratorFromList(hostInterfaces)
hostInterfaceIter := hostInterfaces.Iterator()
for hostInterfaceIter.Next() {
macAddress := hostInterfaceIter.Value().TypedSpec().PermanentAddr.String()

View File

@ -150,7 +150,7 @@ func (o *Openstack) ParseMetadata(
case "phy", "vif", "ovs":
linkName := ""
for hostInterfaceIter := safe.IteratorFromList(hostInterfaces); hostInterfaceIter.Next(); {
for hostInterfaceIter := hostInterfaces.Iterator(); hostInterfaceIter.Next(); {
if strings.EqualFold(hostInterfaceIter.Value().TypedSpec().PermanentAddr.String(), netLink.Mac) {
linkName = hostInterfaceIter.Value().Metadata().ID()

View File

@ -105,7 +105,7 @@ func (v *VMware) ApplyNetworkConfigV2(ctx context.Context, st state.State, confi
var availableMACAddresses []string
macAddressMatched := false
hostInterfaceIter := safe.IteratorFromList(hostInterfaces)
hostInterfaceIter := hostInterfaces.Iterator()
for hostInterfaceIter.Next() {
macAddress := hostInterfaceIter.Value().TypedSpec().PermanentAddr.String()

View File

@ -15,6 +15,7 @@ import (
"log"
"os"
"path/filepath"
"slices"
"strings"
"syscall"
"time"
@ -27,7 +28,7 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/opencontainers/runtime-spec/specs-go"
pprocfs "github.com/prometheus/procfs"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-blockdevice/blockdevice"
"github.com/siderolabs/go-blockdevice/blockdevice/partition/gpt"
"github.com/siderolabs/go-blockdevice/blockdevice/util"
@ -1491,7 +1492,7 @@ func ResetSystemDiskPartitions(seq runtime.Sequence, _ any) (runtime.TaskExecuti
logger.Printf("finished resetting system disks %s", diskTargets)
bootWiped := slices.Contains(diskTargets, func(t runtime.PartitionTarget) bool {
bootWiped := slices.ContainsFunc(diskTargets, func(t runtime.PartitionTarget) bool {
return t.GetLabel() == constants.BootPartitionLabel
})
@ -1565,7 +1566,7 @@ type targets struct {
}
func (opt targets) GetSystemDiskTargets() []runtime.PartitionTarget {
return slices.Map(opt.systemDiskTargets, func(t *installer.Target) runtime.PartitionTarget { return t })
return xslices.Map(opt.systemDiskTargets, func(t *installer.Target) runtime.PartitionTarget { return t })
}
func parseTargets(r runtime.Runtime, wipeStr string) (targets, error) {

View File

@ -15,7 +15,7 @@ import (
osruntime "github.com/cosi-project/runtime/pkg/controller/runtime"
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/state"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-procfs/procfs"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
@ -406,7 +406,7 @@ func (ctrl *Controller) updateLoggingConfig(ctx context.Context, dests []talosco
var prevSenders []runtime.LogSender
if len(loggingEndpoints) > 0 {
senders := slices.Map(loggingEndpoints, runtimelogging.NewJSONLines)
senders := xslices.Map(loggingEndpoints, runtimelogging.NewJSONLines)
ctrl.logger.Info("enabling JSON logging")
prevSenders = ctrl.loggingManager.SetSenders(senders)

View File

@ -7,7 +7,7 @@ package events
import (
"time"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/siderolabs/talos/internal/app/machined/pkg/system/health"
@ -132,7 +132,7 @@ func (events *ServiceEvents) AsProto(count int) *machineapi.ServiceEvents {
}
return &machineapi.ServiceEvents{
Events: slices.Map(eventList, fn),
Events: xslices.Map(eventList, fn),
}
}

View File

@ -8,7 +8,7 @@ import (
"strconv"
"testing"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/stretchr/testify/suite"
"github.com/siderolabs/talos/internal/app/machined/pkg/system/events"
@ -19,7 +19,7 @@ type EventsSuite struct {
}
func (suite *EventsSuite) assertEvents(expectedMessages []string, evs []events.ServiceEvent) {
messages := slices.Map(evs, func(ev events.ServiceEvent) string { return ev.Message })
messages := xslices.Map(evs, func(ev events.ServiceEvent) string { return ev.Message })
suite.Assert().Equal(expectedMessages, messages)
}

View File

@ -5,10 +5,10 @@
package health
import (
"slices"
"sync"
"time"
"github.com/siderolabs/gen/slices"
"google.golang.org/protobuf/types/known/timestamppb"
machineapi "github.com/siderolabs/talos/pkg/machinery/api/machine"

View File

@ -9,10 +9,11 @@ import (
"errors"
"fmt"
"log"
"slices"
"sync"
"time"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/internal/app/machined/pkg/system/events"
@ -207,7 +208,7 @@ func (svcrunner *ServiceRunner) Run() error {
dependencies := svcrunner.service.DependsOn(svcrunner.runtime)
if len(dependencies) > 0 {
serviceConditions := slices.Map(dependencies, func(dep string) conditions.Condition { return WaitForService(StateEventUp, dep) })
serviceConditions := xslices.Map(dependencies, func(dep string) conditions.Condition { return WaitForService(StateEventUp, dep) })
serviceDependencies := conditions.WaitForAll(serviceConditions...)
if condition != nil {

View File

@ -24,7 +24,7 @@ import (
"github.com/cosi-project/runtime/pkg/safe"
"github.com/cosi-project/runtime/pkg/state"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
clientv3 "go.etcd.io/etcd/client/v3"
snapshot "go.etcd.io/etcd/etcdutl/v3/snapshot"
@ -695,7 +695,7 @@ func formatEtcdURL(addr netip.Addr, port int) string {
}
func getEtcdURLs(addrs []netip.Addr, port int) []string {
return slices.Map(addrs, func(addr netip.Addr) string {
return xslices.Map(addrs, func(addr netip.Addr) string {
return formatEtcdURL(addr, port)
})
}
@ -705,7 +705,7 @@ func formatEtcdURLs(addrs []netip.Addr, port int) string {
}
func formatClusterURLs(name string, urls []string) string {
return strings.Join(slices.Map(urls, func(url string) string {
return strings.Join(xslices.Map(urls, func(url string) string {
return fmt.Sprintf("%s=%s", name, url)
}), ",")
}

View File

@ -16,7 +16,7 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime"
"github.com/siderolabs/talos/internal/app/machined/pkg/system/events"
@ -352,7 +352,7 @@ func (s *singleton) stopServices(ctx context.Context, services []string, waitFor
go func(svcrunner *ServiceRunner, reverseDeps []string) {
defer shutdownWg.Done()
conds := slices.Map(reverseDeps, func(dep string) conditions.Condition { return WaitForService(StateEventDown, dep) })
conds := xslices.Map(reverseDeps, func(dep string) conditions.Condition { return WaitForService(StateEventDown, dep) })
allDeps := conditions.WaitForAll(conds...)
if err := allDeps.Wait(shutdownCtx); err != nil {

View File

@ -8,8 +8,8 @@ import (
"context"
"fmt"
"log"
"slices"
"github.com/siderolabs/gen/slices"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/metadata"
@ -60,13 +60,13 @@ func Main(args []string) {
// ActionFromArgs returns the action to be performed based on the arguments.
func ActionFromArgs(args []string) Action {
if len(args) > 1 {
if slices.Contains(args[1:], func(s string) bool {
if slices.ContainsFunc(args[1:], func(s string) bool {
return s == "--halt" || s == "-H" || s == "--poweroff" || s == "-P" || s == "-p"
}) {
return Shutdown
}
if slices.Contains(args[1:], func(s string) bool {
if slices.ContainsFunc(args[1:], func(s string) bool {
return s == "--reboot" || s == "-r"
}) {
return Reboot

View File

@ -8,7 +8,7 @@ package internal
import (
"context"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
bddisk "github.com/siderolabs/go-blockdevice/blockdevice/util/disk"
"google.golang.org/protobuf/types/known/emptypb"
@ -48,7 +48,7 @@ func (s *Server) Disks(ctx context.Context, in *emptypb.Empty) (reply *storage.D
}
}
diskList := slices.Map(disks, diskConv)
diskList := xslices.Map(disks, diskConv)
reply = &storage.DisksResponse{
Messages: []*storage.Disks{

View File

@ -14,7 +14,7 @@ import (
"github.com/containerd/cgroups"
cgroupsv2 "github.com/containerd/cgroups/v2"
"github.com/containerd/containerd/sys"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"golang.org/x/sys/unix"
"kernel.org/pub/linux/libs/security/libcap/cap"
@ -80,7 +80,7 @@ func Main() {
log.Printf("kernel.kexec_load_disabled is %v, skipping dropping capabilities", v)
} else if droppedCaps != "" {
caps := strings.Split(droppedCaps, ",")
dropCaps := slices.Map(caps, func(c string) cap.Value {
dropCaps := xslices.Map(caps, func(c string) cap.Value {
capability, capErr := cap.FromName(c)
if capErr != nil {
log.Fatalf("failed to parse capability: %v", capErr)

View File

@ -16,8 +16,8 @@ import (
"github.com/cosi-project/runtime/pkg/resource"
"github.com/cosi-project/runtime/pkg/safe"
"github.com/siderolabs/gen/maps"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/value"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/talos/internal/integration/base"
"github.com/siderolabs/talos/pkg/machinery/client"
@ -80,18 +80,18 @@ func (suite *DiscoverySuite) TestMembers() {
// do basic check against discovered nodes
for _, expectedNode := range nodes {
nodeAddresses := slices.Map(expectedNode.IPs, func(t netip.Addr) string {
nodeAddresses := xslices.Map(expectedNode.IPs, func(t netip.Addr) string {
return t.String()
})
found := false
for _, member := range members {
memberAddresses := slices.Map(member.TypedSpec().Addresses, func(t netip.Addr) string {
memberAddresses := xslices.Map(member.TypedSpec().Addresses, func(t netip.Addr) string {
return t.String()
})
if maps.Contains(slices.ToSet(memberAddresses), nodeAddresses) {
if maps.Contains(xslices.ToSet(memberAddresses), nodeAddresses) {
found = true
break
@ -110,7 +110,7 @@ func (suite *DiscoverySuite) TestMembers() {
continue
}
memberByName := slices.ToMap(members,
memberByName := xslices.ToMap(members,
func(member *cluster.Member) (string, *cluster.Member) {
return member.Metadata().ID(), member
},
@ -283,7 +283,7 @@ func (suite *DiscoverySuite) getMembers(nodeCtx context.Context) []*cluster.Memb
items, err := safe.StateListAll[*cluster.Member](nodeCtx, suite.Client.COSI)
suite.Require().NoError(err)
it := safe.IteratorFromList(items)
it := items.Iterator()
for it.Next() {
result = append(result, it.Value())
@ -316,7 +316,7 @@ func (suite *DiscoverySuite) getKubeSpanPeerSpecs(nodeCtx context.Context) []*ku
items, err := safe.StateListAll[*kubespan.PeerSpec](nodeCtx, suite.Client.COSI)
suite.Require().NoError(err)
it := safe.IteratorFromList(items)
it := items.Iterator()
for it.Next() {
result = append(result, it.Value())
@ -331,7 +331,7 @@ func (suite *DiscoverySuite) getKubeSpanPeerStatuses(nodeCtx context.Context) []
items, err := safe.StateListAll[*kubespan.PeerStatus](nodeCtx, suite.Client.COSI)
suite.Require().NoError(err)
it := safe.IteratorFromList(items)
it := items.Iterator()
for it.Next() {
result = append(result, it.Value())

View File

@ -12,7 +12,7 @@ import (
"testing"
"time"
"github.com/siderolabs/gen/slices"
"github.com/siderolabs/gen/xslices"
"github.com/siderolabs/go-retry/retry"
"github.com/siderolabs/talos/internal/integration/base"
@ -210,8 +210,8 @@ func (suite *ResetSuite) TestResetWithSpecState() {
suite.Require().NoError(err)
suite.Require().NotEmpty(disks.Messages)
userDisksToWipe := slices.Map(
slices.Filter(disks.Messages[0].Disks, func(disk *storage.Disk) bool {
userDisksToWipe := xslices.Map(
xslices.Filter(disks.Messages[0].Disks, func(disk *storage.Disk) bool {
return !disk.SystemDisk
}),
func(disk *storage.Disk) string {

View File

@ -58,9 +58,7 @@ func (suite *ResourcesSuite) TestListResources() {
nsList, err := safe.StateListAll[*meta.Namespace](ctx, suite.Client.COSI)
suite.Require().NoError(err)
nsIt := safe.IteratorFromList(nsList)
for nsIt.Next() {
for nsIt := nsList.Iterator(); nsIt.Next(); {
namespaces = append(namespaces, nsIt.Value().Metadata().ID())
}
@ -69,9 +67,7 @@ func (suite *ResourcesSuite) TestListResources() {
rdList, err := safe.StateListAll[*meta.ResourceDefinition](ctx, suite.Client.COSI)
suite.Require().NoError(err)
rdIt := safe.IteratorFromList(rdList)
for rdIt.Next() {
for rdIt := rdList.Iterator(); rdIt.Next(); {
resourceTypes = append(resourceTypes, rdIt.Value().TypedSpec().Type)
}

View File

@ -7,7 +7,7 @@
package base
import (
"github.com/siderolabs/gen/slices"
"slices"
"github.com/siderolabs/talos/pkg/cluster"
"github.com/siderolabs/talos/pkg/machinery/config/machine"

Some files were not shown because too many files have changed in this diff Show More