-
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.
Merge pull request #1683 from dorzel/MULTIARCH-4975
Add NodeSelectors to Build and BuildRun objects
- Loading branch information
Showing
19 changed files
with
367 additions
and
34 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,42 @@ | ||
// 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" | ||
) | ||
|
||
// NodeSelectorRef contains all required fields | ||
// to validate a node selector | ||
type NodeSelectorRef struct { | ||
Build *build.Build // build instance for analysis | ||
} | ||
|
||
func NewNodeSelector(build *build.Build) *NodeSelectorRef { | ||
return &NodeSelectorRef{build} | ||
} | ||
|
||
// ValidatePath implements BuildPath interface and validates | ||
// that NodeSelector keys/values are valid labels | ||
func (b *NodeSelectorRef) ValidatePath(_ context.Context) error { | ||
for key, value := range b.Build.Spec.NodeSelector { | ||
if errs := validation.IsQualifiedName(key); len(errs) > 0 { | ||
b.Build.Status.Reason = ptr.To(build.NodeSelectorNotValid) | ||
b.Build.Status.Message = ptr.To(strings.Join(errs, ", ")) | ||
} | ||
if errs := validation.IsValidLabelValue(value); len(errs) > 0 { | ||
b.Build.Status.Reason = ptr.To(build.NodeSelectorNotValid) | ||
b.Build.Status.Message = ptr.To(strings.Join(errs, ", ")) | ||
} | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.