-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
130 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package sync | ||
|
||
import "github.com/icinga/icinga-kubernetes/pkg/contracts" | ||
|
||
// syncOption is a functional option for NewSync. | ||
type syncOption func(options *syncOptions) | ||
|
||
// syncOptions stores options for sync. | ||
type syncOptions struct { | ||
forwardUpserts chan<- contracts.KUpsert | ||
forwardDeletes chan<- contracts.KDelete | ||
} | ||
|
||
// newSyncOptions returns a new syncOptions initialized with the given options. | ||
func newSyncOptions(options ...syncOption) *syncOptions { | ||
syncOpts := &syncOptions{} | ||
|
||
for _, option := range options { | ||
option(syncOpts) | ||
} | ||
|
||
return syncOpts | ||
} | ||
|
||
// WithForwardUpserts forwards added and updated Kubernetes resources to the specific channel. | ||
func WithForwardUpserts(channel chan<- contracts.KUpsert) syncOption { | ||
return func(options *syncOptions) { | ||
options.forwardUpserts = channel | ||
} | ||
} | ||
|
||
// WithForwardDeletes forwards deleted Kubernetes resources to the specific channel. | ||
func WithForwardDeletes(channel chan<- contracts.KDelete) syncOption { | ||
return func(options *syncOptions) { | ||
options.forwardDeletes = channel | ||
} | ||
} |
Oops, something went wrong.