Skip to content

Commit 7bc8507

Browse files
committed
switch to logicalcluster.v3
1 parent 2dc1248 commit 7bc8507

File tree

10 files changed

+87
-87
lines changed

10 files changed

+87
-87
lines changed

pkg/internal/clientgen/clientset.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import (
5858
"net/http"
5959
6060
kcpclient "github.com/kcp-dev/apimachinery/pkg/client"
61-
"github.com/kcp-dev/logicalcluster/v2"
61+
"github.com/kcp-dev/logicalcluster/v3"
6262
6363
client "{{.singleClusterClientPackagePath}}"
6464
@@ -71,7 +71,7 @@ import (
7171
)
7272
7373
type ClusterInterface interface {
74-
Cluster(logicalcluster.Name) client.Interface
74+
Cluster(logicalcluster.Path) client.Interface
7575
Discovery() discovery.DiscoveryInterface
7676
{{range .groups}} {{.GroupGoName}}{{.Version}}() {{.PackageAlias}}.{{.GroupGoName}}{{.Version}}ClusterInterface
7777
{{end -}}
@@ -101,11 +101,11 @@ func (c *ClusterClientset) {{.GroupGoName}}{{.Version}}() {{.PackageAlias}}.{{.G
101101
{{end -}}
102102
103103
// Cluster scopes this clientset to one cluster.
104-
func (c *ClusterClientset) Cluster(name logicalcluster.Name) client.Interface {
105-
if name == logicalcluster.Wildcard {
104+
func (c *ClusterClientset) Cluster(clusterPath logicalcluster.Path) client.Interface {
105+
if clusterPath == logicalcluster.Wildcard {
106106
panic("A specific cluster must be provided when scoping, not the wildcard.")
107107
}
108-
return c.clientCache.ClusterOrDie(name)
108+
return c.clientCache.ClusterOrDie(clusterPath)
109109
}
110110
111111
// NewForConfig creates a new ClusterClientset for the given config.
@@ -145,7 +145,7 @@ func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*ClusterCli
145145
cache := kcpclient.NewCache(c, httpClient, &kcpclient.Constructor[*client.Clientset]{
146146
NewForConfigAndClient: client.NewForConfigAndClient,
147147
})
148-
if _, err := cache.Cluster(logicalcluster.New("root")); err != nil {
148+
if _, err := cache.Cluster(logicalcluster.Name("root").Path()); err != nil {
149149
return nil, err
150150
}
151151

pkg/internal/clientgen/fake_clientset.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ package fake
5656
import (
5757
kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing"
5858
kcpfakediscovery "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/discovery/fake"
59-
"github.com/kcp-dev/logicalcluster/v2"
59+
"github.com/kcp-dev/logicalcluster/v3"
6060
6161
"k8s.io/apimachinery/pkg/runtime"
6262
"k8s.io/client-go/discovery"
@@ -82,7 +82,7 @@ func NewSimpleClientset(objects ...runtime.Object) *ClusterClientset {
8282
o.AddAll(objects...)
8383
8484
cs := &ClusterClientset{Fake: &kcptesting.Fake{}, tracker: o}
85-
cs.discovery = &kcpfakediscovery.FakeDiscovery{Fake: cs.Fake, Cluster: logicalcluster.Wildcard}
85+
cs.discovery = &kcpfakediscovery.FakeDiscovery{Fake: cs.Fake, ClusterPath: logicalcluster.Wildcard}
8686
cs.AddReactor("*", "*", kcptesting.ObjectReaction(o))
8787
cs.AddWatchReactor("*", kcptesting.WatchReaction(o))
8888
@@ -115,15 +115,15 @@ func (c *ClusterClientset) {{.GroupGoName}}{{.Version}}() kcp{{.PackageAlias}}.{
115115
{{end -}}
116116
117117
// Cluster scopes this clientset to one cluster.
118-
func (c *ClusterClientset) Cluster(cluster logicalcluster.Name) client.Interface {
119-
if cluster == logicalcluster.Wildcard {
118+
func (c *ClusterClientset) Cluster(clusterPath logicalcluster.Path) client.Interface {
119+
if clusterPath == logicalcluster.Wildcard {
120120
panic("A specific cluster must be provided when scoping, not the wildcard.")
121121
}
122122
return &Clientset{
123123
Fake: c.Fake,
124-
discovery: &kcpfakediscovery.FakeDiscovery{Fake: c.Fake, Cluster: cluster},
125-
tracker: c.tracker.Cluster(cluster),
126-
cluster: cluster,
124+
discovery: &kcpfakediscovery.FakeDiscovery{Fake: c.Fake, ClusterPath: clusterPath},
125+
tracker: c.tracker.Cluster(clusterPath),
126+
clusterPath: clusterPath,
127127
}
128128
}
129129
@@ -134,7 +134,7 @@ type Clientset struct {
134134
*kcptesting.Fake
135135
discovery *kcpfakediscovery.FakeDiscovery
136136
tracker kcptesting.ScopedObjectTracker
137-
cluster logicalcluster.Name
137+
clusterPath logicalcluster.Path
138138
}
139139
140140
// Discovery retrieves the DiscoveryClient
@@ -149,7 +149,7 @@ func (c *Clientset) Tracker() kcptesting.ScopedObjectTracker {
149149
{{range .groups}}
150150
// {{.GroupGoName}}{{.Version}} retrieves the {{.GroupGoName}}{{.Version}}Client.
151151
func (c *Clientset) {{.GroupGoName}}{{.Version}}() {{.PackageAlias}}.{{.GroupGoName}}{{.Version}}Interface {
152-
return &fake{{.PackageAlias}}.{{.GroupGoName}}{{.Version}}Client{Fake: c.Fake, Cluster: c.cluster}
152+
return &fake{{.PackageAlias}}.{{.GroupGoName}}{{.Version}}Client{Fake: c.Fake, ClusterPath: c.clusterPath}
153153
}
154154
{{end -}}
155155
`

pkg/internal/clientgen/fake_group.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ package {{.group.Version.PackageName}}
5656
5757
import (
5858
kcptesting "github.com/kcp-dev/client-go/third_party/k8s.io/client-go/testing"
59-
"github.com/kcp-dev/logicalcluster/v2"
59+
"github.com/kcp-dev/logicalcluster/v3"
6060
6161
"k8s.io/client-go/rest"
6262
kcp{{.group.PackageAlias}} "{{.packagePath}}/typed/{{.group.Group.PackageName}}/{{.group.Version.PackageName}}"
@@ -69,11 +69,11 @@ type {{.group.GroupGoName}}{{.group.Version}}ClusterClient struct {
6969
*kcptesting.Fake
7070
}
7171
72-
func (c *{{.group.GroupGoName}}{{.group.Version}}ClusterClient) Cluster(cluster logicalcluster.Name) {{.group.PackageAlias}}.{{.group.GroupGoName}}{{.group.Version}}Interface {
73-
if cluster == logicalcluster.Wildcard {
72+
func (c *{{.group.GroupGoName}}{{.group.Version}}ClusterClient) Cluster(clusterPath logicalcluster.Path) {{.group.PackageAlias}}.{{.group.GroupGoName}}{{.group.Version}}Interface {
73+
if clusterPath == logicalcluster.Wildcard {
7474
panic("A specific cluster must be provided when scoping, not the wildcard.")
7575
}
76-
return &{{.group.GroupGoName}}{{.group.Version}}Client{Fake: c.Fake, Cluster: cluster}
76+
return &{{.group.GroupGoName}}{{.group.Version}}Client{Fake: c.Fake, ClusterPath: clusterPath}
7777
}
7878
7979
{{ range .kinds}}
@@ -86,7 +86,7 @@ var _ {{.group.PackageAlias}}.{{.group.GroupGoName}}{{.group.Version}}Interface
8686
8787
type {{.group.GroupGoName}}{{.group.Version}}Client struct {
8888
*kcptesting.Fake
89-
Cluster logicalcluster.Name
89+
ClusterPath logicalcluster.Path
9090
}
9191
9292
func (c *{{.group.GroupGoName}}{{.group.Version}}Client) RESTClient() rest.Interface {
@@ -96,7 +96,7 @@ func (c *{{.group.GroupGoName}}{{.group.Version}}Client) RESTClient() rest.Inter
9696
9797
{{ range .kinds}}
9898
func (c *{{$.group.GroupGoName}}{{$.group.Version}}Client) {{.Plural}}({{if .IsNamespaced}}namespace string{{end}}) {{$.group.PackageAlias}}.{{.String}}Interface {
99-
return &{{.Plural | lowerFirst}}Client{Fake: c.Fake, Cluster: c.Cluster{{if .IsNamespaced}}, Namespace: namespace{{end}}}
99+
return &{{.Plural | lowerFirst}}Client{Fake: c.Fake, ClusterPath: c.ClusterPath{{if .IsNamespaced}}, Namespace: namespace{{end}}}
100100
}
101101
{{end -}}
102102
`

0 commit comments

Comments
 (0)