Skip to content

Commit 8b197c7

Browse files
committed
fixes
On-behalf-of: @SAP [email protected]
1 parent 2e389b4 commit 8b197c7

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

cmd/api-syncagent/kcp.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import (
2222
"fmt"
2323
"regexp"
2424

25-
"github.com/kcp-dev/api-syncagent/internal/kcp"
2625
"github.com/kcp-dev/logicalcluster/v3"
2726

27+
"github.com/kcp-dev/api-syncagent/internal/kcp"
28+
2829
kcpdevv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1"
2930
kcpdevcore "github.com/kcp-dev/kcp/sdk/apis/core"
3031
kcpdevcorev1alpha1 "github.com/kcp-dev/kcp/sdk/apis/core/v1alpha1"
@@ -53,7 +54,7 @@ import (
5354
// either the APIExport or the APIExportEndpointSlice.
5455
func setupEndpointKcpCluster(endpoint *syncEndpoint) (cluster.Cluster, error) {
5556
// no need for a dedicated endpoint cluster
56-
if endpoint.APIExport.Cluster == endpoint.EndpointSlice.Cluster {
57+
if endpoint.EndpointSlice == nil || endpoint.EndpointSlice.Cluster == endpoint.APIExport.Cluster {
5758
return nil, nil
5859
}
5960

cmd/api-syncagent/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import (
3636
"github.com/kcp-dev/api-syncagent/internal/version"
3737
syncagentv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/syncagent/v1alpha1"
3838

39+
kcpdevv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1"
40+
3941
corev1 "k8s.io/api/core/v1"
4042
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
4143
"k8s.io/apimachinery/pkg/runtime"
@@ -177,10 +179,15 @@ func run(ctx context.Context, log *zap.SugaredLogger, opts *Options) error {
177179
cluster = managedKcpCluster
178180
}
179181

182+
var endpointSlice *kcpdevv1alpha1.APIExportEndpointSlice
183+
if endpoint.EndpointSlice != nil {
184+
endpointSlice = endpoint.EndpointSlice.APIExportEndpointSlice
185+
}
186+
180187
// It doesn't matter which rest config we specify, as the URL will be overwritten with the
181188
// virtual workspace URL anyway.
182189

183-
return syncmanager.Add(ctx, mgr, cluster, kcpRestConfig, log, endpoint.APIExport.APIExport, endpoint.EndpointSlice.APIExportEndpointSlice, opts.PublishedResourceSelector, opts.Namespace, opts.AgentName)
190+
return syncmanager.Add(ctx, mgr, cluster, kcpRestConfig, log, endpoint.APIExport.APIExport, endpointSlice, opts.PublishedResourceSelector, opts.Namespace, opts.AgentName)
184191
}); err != nil {
185192
return err
186193
}

test/utils/fixtures.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ func CreateAPIExport(t *testing.T, ctx context.Context, client ctrlruntimeclient
160160
Resources: []string{"events"},
161161
Verbs: []string{"get", "create", "update", "patch"},
162162
},
163+
{
164+
APIGroups: []string{"apis.kcp.io"},
165+
Resources: []string{"apiexportendpointslices"},
166+
Verbs: []string{"get", "list", "watch"},
167+
},
163168
{
164169
APIGroups: []string{"apis.kcp.io"},
165170
Resources: []string{"apiresourceschemas"},

0 commit comments

Comments
 (0)