Skip to content

Commit 8e4d97b

Browse files
committed
Move services.syncagent.kcp.io to syncagent.kcp.io
Signed-off-by: Marvin Beckers <[email protected]>
1 parent 1100047 commit 8e4d97b

File tree

77 files changed

+1955
-360
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1955
-360
lines changed

deploy/crd/kcp.io/services.syncagent.kcp.io_publishedresources.yaml renamed to deploy/crd/kcp.io/syncagent.kcp.io_publishedresources.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ kind: CustomResourceDefinition
55
metadata:
66
annotations:
77
controller-gen.kubebuilder.io/version: v0.16.5
8-
name: publishedresources.services.syncagent.kcp.io
8+
name: publishedresources.syncagent.kcp.io
99
spec:
10-
group: services.syncagent.kcp.io
10+
group: syncagent.kcp.io
1111
names:
1212
kind: PublishedResource
1313
listKind: PublishedResourceList

docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# The kcp Sync Agent
1+
# Documentation
22

3-
The Sync Agent is a Kubernetes agent responsible for integrating external Kubernetes clusters.
3+
kcp-api-syncagent is a Kubernetes agent responsible for integrating external Kubernetes clusters.
44
It runs on a Kubernetes cluster, is configured with credentials to a kcp instance and will then
55
synchronize data out of kcp (i.e. out of kcp workspaces) onto the local cluster, and vice versa.
66

docs/publish-resources.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ resources that need to be synced down to the service cluster.
3838
In its simplest form (which is rarely practical) a `PublishedResource` looks like this:
3939

4040
```yaml
41-
apiVersion: services.syncagent.kcp.io/v1alpha1
41+
apiVersion: syncagent.kcp.io/v1alpha1
4242
kind: PublishedResource
4343
metadata:
4444
name: publish-certmanager-certs # name can be freely chosen
@@ -57,7 +57,7 @@ The Sync Agent can be instructed to only work on a subset of resources in kcp. T
5757
by namespace and/or label selector.
5858
5959
```yaml
60-
apiVersion: services.syncagent.kcp.io/v1alpha1
60+
apiVersion: syncagent.kcp.io/v1alpha1
6161
kind: PublishedResource
6262
metadata:
6363
name: publish-certmanager-certs # name can be freely chosen
@@ -96,7 +96,7 @@ It is also possible to change the scope of resources, i.e. turning a namespaced
9696
cluster-wide. This should be used carefully and might require extensive mutations.
9797

9898
```yaml
99-
apiVersion: services.syncagent.kcp.io/v1alpha1
99+
apiVersion: syncagent.kcp.io/v1alpha1
100100
kind: PublishedResource
101101
metadata:
102102
name: publish-certmanager-certs # name can be freely chosen
@@ -138,7 +138,7 @@ the platform will create a namespace on the local cluster, with a combination of
138138
name hashes used for the actual resource names.
139139

140140
```yaml
141-
apiVersion: services.syncagent.kcp.io/v1alpha1
141+
apiVersion: syncagent.kcp.io/v1alpha1
142142
kind: PublishedResource
143143
metadata:
144144
name: publish-certmanager-certs # name can be freely chosen
@@ -170,7 +170,7 @@ Mutation is always done as a series of steps. Each step does exactly one thing a
170170
be configured per step.
171171

172172
```yaml
173-
apiVersion: services.syncagent.kcp.io/v1alpha1
173+
apiVersion: syncagent.kcp.io/v1alpha1
174174
kind: PublishedResource
175175
metadata:
176176
name: publish-certmanager-certs # name can be freely chosen
@@ -262,7 +262,7 @@ and `"jk...."` as the name on the service cluster. Once the object exists with t
262262
originating side, the Sync Agent will begin to sync it to the other side.
263263

264264
```yaml
265-
apiVersion: services.syncagent.kcp.io/v1alpha1
265+
apiVersion: syncagent.kcp.io/v1alpha1
266266
kind: PublishedResource
267267
metadata:
268268
name: publish-certmanager-certs
@@ -337,7 +337,7 @@ spec: {}
337337
```
338338

339339
```yaml
340-
apiVersion: services.syncagent.kcp.io/v1alpha1
340+
apiVersion: syncagent.kcp.io/v1alpha1
341341
kind: PublishedResource
342342
metadata:
343343
name: publish-certmanager-certs

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module github.com/kcp-dev/api-syncagent
22

33
go 1.22.0
44

5-
toolchain go1.22.5
6-
75
require (
86
github.com/Masterminds/sprig/v3 v3.3.0
97
github.com/evanphx/json-patch/v5 v5.9.0

hack/download-tool.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fi
4444
mkdir -p tmp
4545
cd tmp
4646

47-
echo "Downloading $BINARY version $VERSION" >&2
47+
echo "Downloading $BINARY version $VERSION " >&2
4848
curl --fail --silent -LO "$URL"
4949
archive="$(ls)"
5050

hack/update-codegen-crds.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ go run sigs.k8s.io/controller-tools/cmd/controller-gen \
5555
beautify() {
5656
_tools/yq --inplace --no-doc 'del(.metadata.creationTimestamp)' "$1"
5757

58-
# kcp 0.24 added support for conversions, but as long as our integration tests run on <0.24,
59-
# we must remove any possible conversion field or else older kcp versions will not be able to
60-
# load the generated ARS.
61-
# TODO: Remove this hack once everything in this repository is kcp 0.24+.
62-
_tools/yq --inplace --no-doc 'del(.spec.conversion)' "$1"
63-
6458
mv "$1" "$1.bak"
6559
echo -e "# This file has been generated by hack/update-codegen-crds.sh, DO NOT EDIT.\n" > "$1"
6660
cat "$1.bak" >> "$1"

hack/update-codegen-sdk.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ go run k8s.io/code-generator/cmd/applyconfiguration-gen \
3434
--go-header-file "$BOILERPLATE_HEADER" \
3535
--output-dir $SDK_DIR/applyconfiguration \
3636
--output-pkg $SDK_PKG/applyconfiguration \
37-
$APIS_PKG/services/v1alpha1
37+
$APIS_PKG/v1alpha1
3838

3939
go run k8s.io/code-generator/cmd/client-gen \
4040
--input-base "" \
41-
--input $APIS_PKG/services/v1alpha1 \
41+
--input $APIS_PKG/v1alpha1 \
4242
--clientset-name versioned \
4343
--go-header-file "$BOILERPLATE_HEADER" \
4444
--output-dir $SDK_DIR/clientset \

internal/controller/apiexport/controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/kcp-dev/api-syncagent/internal/controllerutil"
2727
predicateutil "github.com/kcp-dev/api-syncagent/internal/controllerutil/predicate"
2828
"github.com/kcp-dev/api-syncagent/internal/resources/reconciling"
29-
servicesv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/services/v1alpha1"
29+
syncagentv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/v1alpha1"
3030

3131
kcpdevv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1"
3232

@@ -82,7 +82,7 @@ func Add(
8282
}
8383

8484
hasARS := predicate.NewPredicateFuncs(func(object ctrlruntimeclient.Object) bool {
85-
publishedResource, ok := object.(*servicesv1alpha1.PublishedResource)
85+
publishedResource, ok := object.(*syncagentv1alpha1.PublishedResource)
8686
if !ok {
8787
return false
8888
}
@@ -101,7 +101,7 @@ func Add(
101101
// so there is no need here to add an additional filter.
102102
WatchesRawSource(source.Kind(platformCluster.GetCache(), &kcpdevv1alpha1.APIExport{}, controllerutil.EnqueueConst[*kcpdevv1alpha1.APIExport]("dummy"))).
103103
// Watch for changes to PublishedResources on the local service cluster
104-
Watches(&servicesv1alpha1.PublishedResource{}, controllerutil.EnqueueConst[ctrlruntimeclient.Object]("dummy"), builder.WithPredicates(predicateutil.ByLabels(prFilter), hasARS)).
104+
Watches(&syncagentv1alpha1.PublishedResource{}, controllerutil.EnqueueConst[ctrlruntimeclient.Object]("dummy"), builder.WithPredicates(predicateutil.ByLabels(prFilter), hasARS)).
105105
Build(reconciler)
106106
return err
107107
}
@@ -113,15 +113,15 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
113113

114114
func (r *Reconciler) reconcile(ctx context.Context) error {
115115
// find all PublishedResources
116-
pubResources := &servicesv1alpha1.PublishedResourceList{}
116+
pubResources := &syncagentv1alpha1.PublishedResourceList{}
117117
if err := r.localClient.List(ctx, pubResources, &ctrlruntimeclient.ListOptions{
118118
LabelSelector: r.prFilter,
119119
}); err != nil {
120120
return fmt.Errorf("failed to list PublishedResources: %w", err)
121121
}
122122

123123
// filter out those PRs that have not yet been processed into an ARS
124-
filteredPubResources := []servicesv1alpha1.PublishedResource{}
124+
filteredPubResources := []syncagentv1alpha1.PublishedResource{}
125125
for i, pubResource := range pubResources.Items {
126126
if pubResource.Status.ResourceSchemaName != "" {
127127
filteredPubResources = append(filteredPubResources, pubResources.Items[i])

internal/controller/apiexport/reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"slices"
2222

2323
"github.com/kcp-dev/api-syncagent/internal/resources/reconciling"
24-
"github.com/kcp-dev/api-syncagent/sdk/apis/services"
24+
syncagentv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/v1alpha1"
2525

2626
kcpdevv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1"
2727

@@ -39,7 +39,7 @@ func (r *Reconciler) createAPIExportReconciler(availableResourceSchemas sets.Set
3939
if existing.Annotations == nil {
4040
existing.Annotations = map[string]string{}
4141
}
42-
existing.Annotations[services.AgentNameAnnotation] = agentName
42+
existing.Annotations[syncagentv1alpha1.AgentNameAnnotation] = agentName
4343

4444
// we only ever add new schemas
4545
result := known.Union(availableResourceSchemas)

internal/controller/apiresourceschema/controller.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ import (
3131
"github.com/kcp-dev/api-syncagent/internal/controllerutil/predicate"
3232
"github.com/kcp-dev/api-syncagent/internal/discovery"
3333
"github.com/kcp-dev/api-syncagent/internal/projection"
34-
"github.com/kcp-dev/api-syncagent/sdk/apis/services"
35-
servicesv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/services/v1alpha1"
34+
syncagentv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/v1alpha1"
3635

3736
kcpdevv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1"
3837

@@ -90,7 +89,7 @@ func Add(
9089
Named(ControllerName).
9190
WithOptions(controller.Options{MaxConcurrentReconciles: numWorkers}).
9291
// Watch for changes to PublishedResources on the local service cluster
93-
For(&servicesv1alpha1.PublishedResource{}, builder.WithPredicates(predicate.ByLabels(prFilter))).
92+
For(&syncagentv1alpha1.PublishedResource{}, builder.WithPredicates(predicate.ByLabels(prFilter))).
9493
Build(reconciler)
9594
return err
9695
}
@@ -99,7 +98,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
9998
log := r.log.With("publishedresource", request)
10099
log.Debug("Processing")
101100

102-
pubResource := &servicesv1alpha1.PublishedResource{}
101+
pubResource := &syncagentv1alpha1.PublishedResource{}
103102
if err := r.localClient.Get(ctx, request.NamespacedName, pubResource); err != nil {
104103
return reconcile.Result{}, ctrlruntimeclient.IgnoreNotFound(err)
105104
}
@@ -123,7 +122,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, request reconcile.Request) (
123122
return *result, err
124123
}
125124

126-
func (r *Reconciler) reconcile(ctx context.Context, log *zap.SugaredLogger, pubResource *servicesv1alpha1.PublishedResource) (*reconcile.Result, error) {
125+
func (r *Reconciler) reconcile(ctx context.Context, log *zap.SugaredLogger, pubResource *syncagentv1alpha1.PublishedResource) (*reconcile.Result, error) {
127126
// find the resource that the PublishedResource is referring to
128127
localGVK := projection.PublishedResourceSourceGVK(pubResource)
129128

@@ -180,11 +179,11 @@ func (r *Reconciler) createAPIResourceSchema(ctx context.Context, log *zap.Sugar
180179
ars := &kcpdevv1alpha1.APIResourceSchema{}
181180
ars.Name = arsName
182181
ars.Annotations = map[string]string{
183-
services.SourceGenerationAnnotation: fmt.Sprintf("%d", projectedCRD.Generation),
184-
services.AgentNameAnnotation: r.agentName,
182+
syncagentv1alpha1.SourceGenerationAnnotation: fmt.Sprintf("%d", projectedCRD.Generation),
183+
syncagentv1alpha1.AgentNameAnnotation: r.agentName,
185184
}
186185
ars.Labels = map[string]string{
187-
services.APIGroupLabel: apigroup,
186+
syncagentv1alpha1.APIGroupLabel: apigroup,
188187
}
189188
ars.Spec.Group = converted.Spec.Group
190189
ars.Spec.Names = converted.Spec.Names
@@ -196,7 +195,7 @@ func (r *Reconciler) createAPIResourceSchema(ctx context.Context, log *zap.Sugar
196195
return r.platformClient.Create(ctx, ars)
197196
}
198197

199-
func (r *Reconciler) projectResourceNames(apiGroup string, crd *apiextensionsv1.CustomResourceDefinition, projection *servicesv1alpha1.ResourceProjection) *apiextensionsv1.CustomResourceDefinition {
198+
func (r *Reconciler) projectResourceNames(apiGroup string, crd *apiextensionsv1.CustomResourceDefinition, projection *syncagentv1alpha1.ResourceProjection) *apiextensionsv1.CustomResourceDefinition {
200199
result := crd.DeepCopy()
201200
result.Spec.Group = apiGroup
202201

0 commit comments

Comments
 (0)