-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Introduce optional "refspec" to git PipelineResource, refactor #2320
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ var ( | |
) | ||
|
||
const ( | ||
// PipelineResourceTypeGit indicates that this source is a GitHub repo. | ||
// PipelineResourceTypeGit indicates that this source is a Git repo. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice :) |
||
PipelineResourceTypeGit PipelineResourceType = resource.PipelineResourceTypeGit | ||
|
||
// PipelineResourceTypeStorage indicates that this source is a storage blob resource. | ||
|
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 |
---|---|---|
|
@@ -52,6 +52,7 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "test", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 1, | ||
|
@@ -72,6 +73,50 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 1, | ||
SSLVerify: true, | ||
HTTPProxy: "", | ||
HTTPSProxy: "", | ||
NOProxy: "", | ||
}, | ||
}, { | ||
desc: "With Refspec", | ||
pipelineResource: tb.PipelineResource("git-resource", "default", | ||
tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeGit, | ||
tb.PipelineResourceSpecParam("URL", "[email protected]:test/test.git"), | ||
tb.PipelineResourceSpecParam("Refspec", "refs/changes/22/222134"), | ||
), | ||
), | ||
want: &git.Resource{ | ||
Name: "git-resource", | ||
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "refs/changes/22/222134", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 1, | ||
SSLVerify: true, | ||
HTTPProxy: "", | ||
HTTPSProxy: "", | ||
NOProxy: "", | ||
}, | ||
}, { | ||
desc: "Without Refspec", | ||
pipelineResource: tb.PipelineResource("git-resource", "default", | ||
tb.PipelineResourceSpec(resourcev1alpha1.PipelineResourceTypeGit, | ||
tb.PipelineResourceSpecParam("URL", "[email protected]:test/test.git"), | ||
), | ||
), | ||
want: &git.Resource{ | ||
Name: "git-resource", | ||
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 1, | ||
|
@@ -93,6 +138,7 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "test", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 1, | ||
|
@@ -115,6 +161,7 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "test", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: false, | ||
Depth: 1, | ||
|
@@ -137,6 +184,7 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "test", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 8, | ||
|
@@ -159,6 +207,7 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "test", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 0, | ||
|
@@ -182,6 +231,7 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "test", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 0, | ||
|
@@ -205,6 +255,7 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "test", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 0, | ||
|
@@ -228,6 +279,7 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "test", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 0, | ||
|
@@ -251,6 +303,7 @@ func TestNewGitResource_Valid(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "test", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 0, | ||
|
@@ -279,6 +332,8 @@ func TestGitResource_Replacements(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
Submodules: false, | ||
Depth: 16, | ||
SSLVerify: false, | ||
HTTPProxy: "http-proxy.git.com", | ||
|
@@ -291,6 +346,8 @@ func TestGitResource_Replacements(t *testing.T) { | |
"type": string(resourcev1alpha1.PipelineResourceTypeGit), | ||
"url": "[email protected]:test/test.git", | ||
"revision": "master", | ||
"refspec": "", | ||
"submodules": "false", | ||
"depth": "16", | ||
"sslVerify": "false", | ||
"httpProxy": "http-proxy.git.com", | ||
|
@@ -319,6 +376,7 @@ func TestGitResource_GetDownloadTaskModifier(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 1, | ||
|
@@ -354,6 +412,7 @@ func TestGitResource_GetDownloadTaskModifier(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: false, | ||
Depth: 1, | ||
|
@@ -390,6 +449,7 @@ func TestGitResource_GetDownloadTaskModifier(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: true, | ||
Depth: 8, | ||
|
@@ -427,6 +487,7 @@ func TestGitResource_GetDownloadTaskModifier(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: false, | ||
Depth: 1, | ||
|
@@ -464,6 +525,7 @@ func TestGitResource_GetDownloadTaskModifier(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: false, | ||
Depth: 1, | ||
|
@@ -499,6 +561,7 @@ func TestGitResource_GetDownloadTaskModifier(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: false, | ||
Depth: 1, | ||
|
@@ -534,6 +597,7 @@ func TestGitResource_GetDownloadTaskModifier(t *testing.T) { | |
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "", | ||
GitImage: "override-with-git:latest", | ||
Submodules: false, | ||
Depth: 1, | ||
|
@@ -562,6 +626,45 @@ func TestGitResource_GetDownloadTaskModifier(t *testing.T) { | |
{Name: "HTTPS_PROXY", Value: "https-proxy.git.com"}, | ||
}, | ||
}, | ||
}, { | ||
desc: "With Refspec", | ||
gitResource: &git.Resource{ | ||
Name: "git-resource", | ||
Type: resourcev1alpha1.PipelineResourceTypeGit, | ||
URL: "[email protected]:test/test.git", | ||
Revision: "master", | ||
Refspec: "refs/tags/v1.0:refs/tags/v1.0 refs/heads/master:refs/heads/master", | ||
GitImage: "override-with-git:latest", | ||
Submodules: false, | ||
Depth: 1, | ||
SSLVerify: true, | ||
HTTPProxy: "http-proxy.git.com", | ||
HTTPSProxy: "https-proxy.git.com", | ||
NOProxy: "no-proxy.git.com", | ||
}, | ||
want: corev1.Container{ | ||
Name: "git-source-git-resource-l22wn", | ||
Image: "override-with-git:latest", | ||
Command: []string{"/ko-app/git-init"}, | ||
Args: []string{ | ||
"-url", | ||
"[email protected]:test/test.git", | ||
"-revision", | ||
"master", | ||
"-path", | ||
"/test/test", | ||
"-refspec", | ||
"refs/tags/v1.0:refs/tags/v1.0 refs/heads/master:refs/heads/master", | ||
"-submodules=false", | ||
}, | ||
WorkingDir: "/workspace", | ||
Env: []corev1.EnvVar{ | ||
{Name: "TEKTON_RESOURCE_NAME", Value: "git-resource"}, | ||
{Name: "HTTP_PROXY", Value: "http-proxy.git.com"}, | ||
{Name: "HTTPS_PROXY", Value: "https-proxy.git.com"}, | ||
{Name: "NO_PROXY", Value: "no-proxy.git.com"}, | ||
}, | ||
}, | ||
}} { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
ts := pipelinev1alpha1.TaskSpec{} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change does not seem to be needed for this patch, but I guess it makes sense anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually needed for the patch, to pass the submodule setting to git.go and prevent --recurse-submodules from being appended to the fetch command when
the user specified submodule: "false"