mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-10 19:50:30 +00:00
organization and repository are now exclusive
This commit is contained in:
@@ -66,6 +66,12 @@ func (r *RunnerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
|
||||
return ctrl.Result{}, client.IgnoreNotFound(err)
|
||||
}
|
||||
|
||||
err := validateRunnerSpec(&runner.Spec)
|
||||
if err != nil {
|
||||
log.Info("Failed to validate runner spec", "error", err.Error())
|
||||
return ctrl.Result{}, nil
|
||||
}
|
||||
|
||||
if runner.ObjectMeta.DeletionTimestamp.IsZero() {
|
||||
finalizers, added := addFinalizer(runner.ObjectMeta.Finalizers)
|
||||
|
||||
@@ -439,3 +445,15 @@ func removeFinalizer(finalizers []string) ([]string, bool) {
|
||||
|
||||
return result, removed
|
||||
}
|
||||
|
||||
// organization & repository are both exclusive - however this cannot be checked with kubebuilder
|
||||
// therefore have an additional check here to log an error in case spec is invalid
|
||||
func validateRunnerSpec(spec *v1alpha1.RunnerSpec) error {
|
||||
if len(spec.Organization) == 0 && len(spec.Repository) == 0 {
|
||||
return fmt.Errorf("RunnerSpec needs organization or repository")
|
||||
}
|
||||
if len(spec.Organization) > 0 && len(spec.Repository) > 0 {
|
||||
return fmt.Errorf("RunnerSpec cannot have both organization and repository")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user