-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Custom Scheduler Name to Build and BuildRun objects
Signed-off-by: Dylan Orzel <dorzel@redhat.com>
- Loading branch information
Showing
10 changed files
with
79 additions
and
1 deletion.
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
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
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 @@ | ||
// Copyright The Shipwright Contributors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package validate | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"k8s.io/apimachinery/pkg/util/validation" | ||
"k8s.io/utils/ptr" | ||
|
||
build "github.com/shipwright-io/build/pkg/apis/build/v1beta1" | ||
) | ||
|
||
// SchedulerNameRef contains all required fields | ||
// to validate a Scheduler name | ||
type SchedulerNameRef struct { | ||
Build *build.Build // build instance for analysis | ||
} | ||
|
||
func NewSchedulerName(build *build.Build) *SchedulerNameRef { | ||
return &SchedulerNameRef{build} | ||
} | ||
|
||
// ValidatePath implements BuildPath interface and validates | ||
// that SchedulerName values are valid | ||
func (b *SchedulerNameRef) ValidatePath(_ context.Context) error { | ||
if b.Build.Spec.SchedulerName != "" { | ||
if errs := validation.IsQualifiedName(b.Build.Spec.SchedulerName); len(errs) > 0 { | ||
b.Build.Status.Reason = ptr.To(build.SchedulerNameNotValid) | ||
b.Build.Status.Message = ptr.To(strings.Join(errs, ", ")) | ||
} | ||
} | ||
return nil | ||
} |
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