Skip to content

Commit

Permalink
Rename local/broker transformers for clarity
Browse files Browse the repository at this point in the history
This makes the direction of transformers and syncers explicit. The
documentation is updated to match.

Signed-off-by: Stephen Kitt <[email protected]>
  • Loading branch information
skitt committed Mar 24, 2023
1 parent fb38f16 commit 9fdb22a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions pkg/syncer/broker/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ type ResourceConfig struct {
// LocalResourceType the type of the local resources to sync to the broker.
LocalResourceType runtime.Object

// LocalTransform function used to transform a local resource to the equivalent broker resource.
LocalTransform syncer.TransformFunc
// TransformLocalToBroker function used to transform a local resource to the equivalent broker resource.
TransformLocalToBroker syncer.TransformFunc

// OnSuccessfulSync function invoked after a successful sync operation to the broker.
LocalOnSuccessfulSync syncer.OnSuccessfulSyncFunc
// OnSuccessfulSyncToBroker function invoked after a successful sync operation to the broker.
OnSuccessfulSyncToBroker syncer.OnSuccessfulSyncFunc

// LocalResourcesEquivalent function to compare two local resources for equivalence. See ResourceSyncerConfig.ResourcesEquivalent
// for more details.
Expand All @@ -74,11 +74,11 @@ type ResourceConfig struct {
// BrokerResourceType the type of the broker resources to sync to the local source.
BrokerResourceType runtime.Object

// BrokerTransform function used to transform a broker resource to the equivalent local resource.
BrokerTransform syncer.TransformFunc
// TransformBrokerToLocal function used to transform a broker resource to the equivalent local resource.
TransformBrokerToLocal syncer.TransformFunc

// OnSuccessfulSync function invoked after a successful sync operation from the broker.
BrokerOnSuccessfulSync syncer.OnSuccessfulSyncFunc
// OnSuccessfulSyncFromBroker function invoked after a successful sync operation from the broker.
OnSuccessfulSyncFromBroker syncer.OnSuccessfulSyncFunc

// BrokerResourcesEquivalent function to compare two broker resources for equivalence. See ResourceSyncerConfig.ResourcesEquivalent
// for more details.
Expand Down Expand Up @@ -211,8 +211,8 @@ func NewSyncer(config SyncerConfig) (*Syncer, error) { //nolint:gocritic // Mini
RestMapper: config.RestMapper,
Federator: brokerSyncer.remoteFederator,
ResourceType: rc.LocalResourceType,
Transform: rc.LocalTransform,
OnSuccessfulSync: rc.LocalOnSuccessfulSync,
Transform: rc.TransformLocalToBroker,
OnSuccessfulSync: rc.OnSuccessfulSyncToBroker,
ResourcesEquivalent: rc.LocalResourcesEquivalent,
ShouldProcess: rc.LocalShouldProcess,
WaitForCacheSync: rc.LocalWaitForCacheSync,
Expand Down Expand Up @@ -244,8 +244,8 @@ func NewSyncer(config SyncerConfig) (*Syncer, error) { //nolint:gocritic // Mini
RestMapper: config.RestMapper,
Federator: brokerSyncer.localFederator,
ResourceType: rc.BrokerResourceType,
Transform: rc.BrokerTransform,
OnSuccessfulSync: rc.BrokerOnSuccessfulSync,
Transform: rc.TransformBrokerToLocal,
OnSuccessfulSync: rc.OnSuccessfulSyncFromBroker,
ResourcesEquivalent: rc.BrokerResourcesEquivalent,
WaitForCacheSync: waitForCacheSync,
Scheme: config.Scheme,
Expand Down
4 changes: 2 additions & 2 deletions pkg/syncer/broker/syncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ var _ = Describe("Broker Syncer", func() {
When("a local transform function is specified", func() {
BeforeEach(func() {
transformed = test.NewPodWithImage(config.LocalNamespace, "transformed")
config.ResourceConfigs[0].LocalTransform = func(from runtime.Object, numRequeues int,
config.ResourceConfigs[0].TransformLocalToBroker = func(from runtime.Object, numRequeues int,
op sync.Operation,
) (runtime.Object, bool) {
return transformed, false
Expand All @@ -238,7 +238,7 @@ var _ = Describe("Broker Syncer", func() {
When("a broker transform function is specified", func() {
BeforeEach(func() {
transformed = test.NewPodWithImage(config.LocalNamespace, "transformed")
config.ResourceConfigs[0].BrokerTransform = func(from runtime.Object, numRequeues int,
config.ResourceConfigs[0].TransformBrokerToLocal = func(from runtime.Object, numRequeues int,
op sync.Operation,
) (runtime.Object, bool) {
return transformed, false
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/syncer/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (t *testDriver) newSyncer(cluster framework.ClusterIndex) *broker.Syncer {
LocalSourceNamespace: t.localSourceNamespace,
LocalSourceLabelSelector: t.labelSelector,
LocalSourceFieldSelector: t.fieldSelector,
LocalTransform: t.localTransform,
TransformLocalToBroker: t.localTransform,
BrokerResourceType: t.brokerResourceType,
},
},
Expand Down

0 comments on commit 9fdb22a

Please sign in to comment.