-
Notifications
You must be signed in to change notification settings - Fork 6
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
1 parent
f52e02d
commit 4e590a0
Showing
3 changed files
with
44 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package controller | ||
|
||
import ( | ||
"context" | ||
|
||
"k8s.io/client-go/rest" | ||
) | ||
|
||
// StaticController is a controller that manages a static set of clusters. | ||
type StaticController struct { | ||
clusterToConfig map[string]*rest.Config | ||
addUpdateHandler func(string, *rest.Config) error | ||
} | ||
|
||
func NewStaticController(clusterToConfig map[string]*rest.Config) *StaticController { | ||
return &StaticController{ | ||
clusterToConfig: clusterToConfig, | ||
} | ||
} | ||
|
||
func (c *StaticController) Run(stopCh <-chan struct{}) error { | ||
if c.addUpdateHandler == nil { | ||
return nil | ||
} | ||
|
||
for cluster, config := range c.clusterToConfig { | ||
if err := c.addUpdateHandler(cluster, config); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (c *StaticController) AddEventHandler(addUpdateHandler func(string, *rest.Config) error, deleteHandler func(string)) { | ||
c.addUpdateHandler = addUpdateHandler | ||
} | ||
|
||
func (c *StaticController) WaitForSynced(ctx context.Context) bool { | ||
return true | ||
} |
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