Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Build.spec.source.git.url required #1441

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deploy/crds/shipwright.io_buildruns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6703,6 +6703,8 @@ spec:
url:
description: URL describes the URL of the Git repository.
type: string
required:
- url
type: object
local:
description: LocalSource
Expand Down Expand Up @@ -10695,6 +10697,8 @@ spec:
url:
description: URL describes the URL of the Git repository.
type: string
required:
- url
type: object
local:
description: LocalSource
Expand Down
2 changes: 2 additions & 0 deletions deploy/crds/shipwright.io_builds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,8 @@ spec:
url:
description: URL describes the URL of the Git repository.
type: string
required:
- url
type: object
local:
description: LocalSource
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/build/v1beta1/build_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ func (dest *BuildSpec) ConvertFrom(orig *v1alpha1.BuildSpec) error {
if orig.Source.Credentials != nil {
specSource.OCIArtifact.PullSecret = &orig.Source.Credentials.Name
}
} else {
} else if orig.Source.URL != nil {
specSource.Type = GitType
specSource.GitSource = &Git{
URL: orig.Source.URL,
URL: *orig.Source.URL,
Revision: orig.Source.Revision,
}
if orig.Source.Credentials != nil {
Expand Down Expand Up @@ -434,7 +434,7 @@ func getAlphaBuildSource(src BuildSpec) v1alpha1.Source {
}
}
if src.Source.GitSource != nil {
source.URL = src.Source.GitSource.URL
source.URL = &src.Source.GitSource.URL
revision = src.Source.GitSource.Revision
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/apis/build/v1beta1/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ type Local struct {
// Git describes the git repository to pull
type Git struct {
// URL describes the URL of the Git repository.
//
// +optional
URL *string `json:"url,omitempty"`
URL string `json:"url"`

// Revision describes the Git revision (e.g., branch, tag, commit SHA,
// etc.) to fetch.
Expand Down
5 changes: 0 additions & 5 deletions pkg/apis/build/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/webhook/conversion/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ request:
Type: v1beta1.GitType,
ContextDir: &ctxDir,
GitSource: &v1beta1.Git{
URL: &url,
URL: url,
Revision: &revision,
CloneSecret: &secretName,
},
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/v1beta1/common_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (b *buildPrototype) SourceGit(repository string) *buildPrototype {
if b.build.Spec.Source.GitSource == nil {
b.build.Spec.Source.GitSource = &buildv1beta1.Git{}
}
b.build.Spec.Source.GitSource.URL = pointer.String(repository)
b.build.Spec.Source.GitSource.URL = repository
b.build.Spec.Source.OCIArtifact = nil
return b
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/v1beta1/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func amendSourceURL(b *buildv1beta1.Build, sourceURL string) {
if sourceURL == "" {
return
}
b.Spec.Source.GitSource.URL = &sourceURL
b.Spec.Source.GitSource.URL = sourceURL
}

// amendBuild make changes on build object.
Expand Down
18 changes: 12 additions & 6 deletions test/v1beta1_samples/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ func (c *Catalog) BuildWithClusterBuildStrategyAndFalseSourceAnnotation(name str
Spec: build.BuildSpec{
Source: build.Source{
GitSource: &build.Git{
URL: pointer.String("foobar"),
URL: "foobar",
},
Type: build.GitType,
},
Strategy: build.Strategy{
Name: strategyName,
Expand All @@ -125,8 +126,9 @@ func (c *Catalog) BuildWithClusterBuildStrategy(name string, ns string, strategy
Spec: build.BuildSpec{
Source: build.Source{
GitSource: &build.Git{
URL: pointer.String("https://github.com/shipwright-io/sample-go"),
URL: "https://github.com/shipwright-io/sample-go",
},
Type: build.GitType,
},
Strategy: build.Strategy{
Name: strategyName,
Expand All @@ -152,9 +154,10 @@ func (c *Catalog) BuildWithClusterBuildStrategyAndSourceSecret(name string, ns s
Spec: build.BuildSpec{
Source: build.Source{
GitSource: &build.Git{
URL: pointer.String("https://github.com/shipwright-io/sample-go"),
URL: "https://github.com/shipwright-io/sample-go",
CloneSecret: &secret,
},
Type: build.GitType,
},
Strategy: build.Strategy{
Name: strategyName,
Expand All @@ -178,8 +181,9 @@ func (c *Catalog) BuildWithBuildStrategy(name string, ns string, strategyName st
Spec: build.BuildSpec{
Source: build.Source{
GitSource: &build.Git{
URL: pointer.String("https://github.com/shipwright-io/sample-go"),
URL: "https://github.com/shipwright-io/sample-go",
},
Type: build.GitType,
},
Strategy: build.Strategy{
Name: strategyName,
Expand All @@ -199,8 +203,9 @@ func (c *Catalog) BuildWithNilBuildStrategyKind(name string, ns string, strategy
Spec: build.BuildSpec{
Source: build.Source{
GitSource: &build.Git{
URL: pointer.String("https://github.com/shipwright-io/sample-go"),
URL: "https://github.com/shipwright-io/sample-go",
},
Type: build.GitType,
},
Strategy: build.Strategy{
Name: strategyName,
Expand All @@ -219,8 +224,9 @@ func (c *Catalog) BuildWithOutputSecret(name string, ns string, secretName strin
Spec: build.BuildSpec{
Source: build.Source{
GitSource: &build.Git{
URL: pointer.String("https://github.com/shipwright-io/sample-go"),
URL: "https://github.com/shipwright-io/sample-go",
},
Type: build.GitType,
},
Output: build.Image{
PushSecret: &secretName,
Expand Down