-
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
1 parent
bda9800
commit 62b98d5
Showing
3 changed files
with
103 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package condition | ||
|
||
import ( | ||
"github.com/go-logr/logr" | ||
"github.com/opendatahub-io/odh-platform/controllers/authorization" | ||
"github.com/opendatahub-io/odh-platform/pkg/spi" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
) | ||
|
||
/* | ||
# Initial | ||
* Load Config | ||
* Register Conditional pr GAV pr Capability | ||
* Start | ||
# Update | ||
* Load Config | ||
* Register Conditional pr GAV pr Capability | ||
* If existing but changed; kill to reload everything | ||
* If removed?; kill to reload everything | ||
* If exisitng but not changed; all ready running? | ||
* If new, just add to start | ||
*/ | ||
|
||
type When func() bool | ||
type Do func() error | ||
type Conditional func() (When, Do) | ||
|
||
type ConditionalEngine struct { | ||
conditions []Conditional | ||
} | ||
|
||
func (c *ConditionalEngine) Add(condition Conditional) { | ||
c.conditions = append(c.conditions, condition) | ||
} | ||
|
||
func (c *ConditionalEngine) Start() { | ||
|
||
/* | ||
Check failure on line 45 in pkg/condition/condition.go
|
||
for i, con := range c.conditions { | ||
if con.When() { | ||
con.Do() | ||
// remove con | ||
} | ||
} | ||
if len(c.conditions) > 0 { | ||
Sleep(500) | ||
c.Start() | ||
} | ||
*/ | ||
|
||
} | ||
|
||
func Authorization(mgr manager.Manager, log logr.Logger, component spi.AuthorizationComponent) Conditional { | ||
return func() (When, Do) { | ||
return WhenGAVExists(mgr.GetClient(), component), | ||
DoSetupAuthorization(mgr, log, component) | ||
} | ||
} | ||
|
||
func WhenGAVExists(cli client.Client, component spi.AuthorizationComponent) When { | ||
return func() bool { | ||
return false // TODO: check CRD | ||
} | ||
} | ||
|
||
func DoSetupAuthorization(mgr manager.Manager, log logr.Logger, component spi.AuthorizationComponent) Do { | ||
return func() error { | ||
return authorization.NewPlatformAuthorizationReconciler(mgr.GetClient(), log, component). | ||
SetupWithManager(mgr) | ||
} | ||
} |
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