Skip to content

Commit 7fd7500

Browse files
committed
rename pkg/utils to pkg/sync
On-behalf-of: @SAP christoph.mewes@sap.com
1 parent 48472c0 commit 7fd7500

File tree

10 files changed

+38
-22
lines changed

10 files changed

+38
-22
lines changed

.golangci.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ linters:
6868
linters:
6969
- revive
7070
text: "var-naming" # the package name `utils` is fine here
71-
- path: pkg/utils
72-
linters:
73-
- revive
74-
text: "var-naming" # yeah, utils is a bandaid
7571
settings:
7672
goheader:
7773
values:

pkg/generic/generic.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import (
4040

4141
brokerv1alpha1 "github.com/platform-mesh/resource-broker/api/broker/v1alpha1"
4242
"github.com/platform-mesh/resource-broker/pkg/kubernetes"
43-
brokerutils "github.com/platform-mesh/resource-broker/pkg/utils"
43+
"github.com/platform-mesh/resource-broker/pkg/sync"
4444
)
4545

4646
// Options are the options for the generic reconciler.
@@ -681,7 +681,7 @@ func (gr *genericReconciler) syncResource(ctx context.Context, providerName stri
681681
// TODO send conditions back to consumer cluster
682682
// TODO there should be two informers triggering this - one
683683
// for consumer and one for provider
684-
if cond, err := brokerutils.CopyResource(
684+
if cond, err := sync.CopyResource(
685685
ctx,
686686
gr.gvk,
687687
gr.req.NamespacedName,
@@ -719,7 +719,7 @@ func (gr *genericReconciler) syncRelatedResources(ctx context.Context, providerN
719719
// TODO handle resource drift when a related resource is removed in
720720
// the provider it needs to be removed in the consumer
721721
// maybe just a finalizer on the resources in the provider?
722-
relatedResources, err := brokerutils.CollectRelatedResources(ctx, providerCluster.GetClient(), gr.gvk, gr.req.NamespacedName)
722+
relatedResources, err := sync.CollectRelatedResources(ctx, providerCluster.GetClient(), gr.gvk, gr.req.NamespacedName)
723723
if err != nil {
724724
return fmt.Errorf("failed to collect related resources from provider cluster %q: %w", providerName, err)
725725
}
@@ -763,7 +763,7 @@ func (gr *genericReconciler) syncRelatedResource(ctx context.Context, providerCl
763763
}
764764

765765
// TODO conditions
766-
_, err := brokerutils.CopyResource(
766+
_, err := sync.CopyResource(
767767
ctx,
768768
relatedResource.SchemaGVK(),
769769
types.NamespacedName{
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
// Package utils contains utility functions and types for the project.
19-
// TODO: This should be split, it's more of a bandaid right now.
20-
package utils
18+
// Package kubernetes offers utility functions for working with Kubernetes
19+
// objects.
20+
package kubernetes

pkg/migration/migration.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import (
4242
mcreconcile "sigs.k8s.io/multicluster-runtime/pkg/reconcile"
4343

4444
brokerv1alpha1 "github.com/platform-mesh/resource-broker/api/broker/v1alpha1"
45-
brokerutils "github.com/platform-mesh/resource-broker/pkg/utils"
45+
"github.com/platform-mesh/resource-broker/pkg/sync"
4646
)
4747

4848
// MigrationOptions holds the options for the migration reconciler.
@@ -246,7 +246,7 @@ func (mr *migrationReconciler) copyRelatedResources(ctx context.Context, from br
246246
return err
247247
}
248248

249-
relatedResources, err := brokerutils.CollectRelatedResources(
249+
relatedResources, err := sync.CollectRelatedResources(
250250
ctx,
251251
cl.GetClient(),
252252
schema.GroupVersionKind{
@@ -298,7 +298,7 @@ func (mr *migrationReconciler) copyRelatedResource(ctx context.Context, source c
298298
return err
299299
}
300300

301-
targetObj := brokerutils.StripClusterMetadata(sourceObj)
301+
targetObj := sync.StripClusterMetadata(sourceObj)
302302
targetObj.SetName(prefix + relatedResource.Name)
303303
if relatedResource.Namespace != "" {
304304
targetObj.SetNamespace(relatedResource.Namespace) // TODO handle namespacing. all resources should probably be in the same namespace
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
package utils
18+
package sync
1919

2020
// ConditionType is a discrete, strongly-typed alias for metav1.Condition.Type
2121
// values used within this package. Defining a concrete type and named
@@ -25,8 +25,8 @@ type ConditionType string
2525
func (c ConditionType) String() string { return string(c) }
2626

2727
const (
28-
// ConditionResourceCopied indicates the resource was copied/created/updated on the
29-
// destination cluster.
28+
// ConditionResourceCopied indicates the resource was copied/created/updated
29+
// on the destination cluster.
3030
ConditionResourceCopied ConditionType = "Copied"
3131

3232
// ConditionStatusSynced indicates the status was copied back to the
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
package utils
18+
package sync
1919

2020
import (
2121
"testing"

pkg/sync/doc.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
Copyright The Platform Mesh Authors.
3+
SPDX-License-Identifier: Apache-2.0
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
// Package sync contains code related to synchronizing objects and handling
19+
// related resources, used by multiple controllers in the resource-broker.
20+
package sync
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
package utils
18+
package sync
1919

2020
import (
2121
"context"
@@ -50,7 +50,7 @@ func CollectRelatedResources(ctx context.Context, providerClient client.Client,
5050

5151
relatedResources := make(map[string]brokerv1alpha1.RelatedResource, len(relatedResourcesI))
5252
for key, rrI := range relatedResourcesI {
53-
rrMap, ok := rrI.(map[string]interface{})
53+
rrMap, ok := rrI.(map[string]any)
5454
if !ok {
5555
return nil, fmt.Errorf("failed to cast related resource %q from synced resource status", key)
5656
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
package utils
18+
package sync
1919

2020
import (
2121
"context"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
package utils
18+
package sync
1919

2020
import (
2121
"testing"

0 commit comments

Comments
 (0)