-
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.
Multiple items, most important ones: - Reintroduce source validation for Build - Reintroduce test case when retention is removed from Build - Fix Build Update predicate for AtBuildDeletion
- Loading branch information
Showing
23 changed files
with
250 additions
and
61 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
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,60 @@ | ||
// Copyright The Shipwright Contributors | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package validate | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
build "github.com/shipwright-io/build/pkg/apis/build/v1beta1" | ||
) | ||
|
||
// SourcesRef implements RuntimeRef interface to add validations for `build.spec.source`. | ||
type SourceRef struct { | ||
Build *build.Build // build instance for analysis | ||
} | ||
|
||
// ValidatePath executes the validation routine, inspecting the `build.spec.source` path | ||
func (s *SourceRef) ValidatePath(_ context.Context) error { | ||
|
||
if err := s.validateSourceEntry(s.Build.Spec.Source); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// validateSourceEntry inspect informed entry, probes all required attributes. | ||
func (s *SourceRef) validateSourceEntry(source build.Source) error { | ||
|
||
// dont bail out if the Source object is empty, we preserve the old behaviour as in v1alpha1 | ||
if source.Type == "" && source.GitSource == nil && | ||
source.OCIArtifact == nil && source.LocalSource == nil { | ||
return nil | ||
} | ||
|
||
switch source.Type { | ||
case "Git": | ||
if source.GitSource == nil { | ||
return fmt.Errorf("type does not match the source") | ||
} | ||
case "OCI": | ||
if source.OCIArtifact == nil { | ||
return fmt.Errorf("type does not match the source") | ||
} | ||
case "Local": | ||
if source.LocalSource == nil { | ||
return fmt.Errorf("type does not match the source") | ||
} | ||
case "": | ||
return fmt.Errorf("type definition is missing") | ||
} | ||
return nil | ||
} | ||
|
||
// NewSourcesRef instantiate a new SourcesRef passing the build object pointer along. | ||
func NewSourceRef(b *build.Build) *SourceRef { | ||
return &SourceRef{Build: b} | ||
} |
Oops, something went wrong.