Skip to content

Commit 030a95b

Browse files
author
OpenShift Bot
authored
Merge pull request #12463 from bparees/git_ssh
Merged by openshift-bot
2 parents 2cfc860 + cd8299b commit 030a95b

File tree

2 files changed

+0
-56
lines changed

2 files changed

+0
-56
lines changed

Diff for: pkg/build/api/validation/validation.go

-15
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,6 @@ const (
202202
maxJenkinsfileLengthBytes = 100 * 1000
203203
)
204204

205-
func hasProxy(source *buildapi.GitBuildSource) bool {
206-
return (source.HTTPProxy != nil && len(*source.HTTPProxy) > 0) || (source.HTTPSProxy != nil && len(*source.HTTPSProxy) > 0)
207-
}
208-
209205
func validateSource(input *buildapi.BuildSource, isCustomStrategy, isDockerStrategy, isJenkinsPipelineStrategyFromRepo bool, fldPath *field.Path) field.ErrorList {
210206
allErrs := field.ErrorList{}
211207

@@ -273,14 +269,6 @@ func validateSecretRef(ref *kapi.LocalObjectReference, fldPath *field.Path) fiel
273269
return allErrs
274270
}
275271

276-
func isHTTPScheme(in string) bool {
277-
u, err := url.Parse(in)
278-
if err != nil {
279-
return false
280-
}
281-
return u.Scheme == "http" || u.Scheme == "https"
282-
}
283-
284272
func validateGitSource(git *buildapi.GitBuildSource, fldPath *field.Path) field.ErrorList {
285273
allErrs := field.ErrorList{}
286274
if len(git.URI) == 0 {
@@ -294,9 +282,6 @@ func validateGitSource(git *buildapi.GitBuildSource, fldPath *field.Path) field.
294282
if git.HTTPSProxy != nil && len(*git.HTTPSProxy) != 0 && !IsValidURL(*git.HTTPSProxy) {
295283
allErrs = append(allErrs, field.Invalid(fldPath.Child("httpsproxy"), *git.HTTPSProxy, "proxy is not a valid url"))
296284
}
297-
if hasProxy(git) && !isHTTPScheme(git.URI) {
298-
allErrs = append(allErrs, field.Invalid(fldPath.Child("uri"), git.URI, "only http:// and https:// GIT protocols are allowed with HTTP or HTTPS proxy set"))
299-
}
300285
return allErrs
301286
}
302287

Diff for: pkg/build/api/validation/validation_test.go

-41
Original file line numberDiff line numberDiff line change
@@ -396,47 +396,6 @@ func TestValidateBuildUpdate(t *testing.T) {
396396
}
397397
}
398398

399-
func TestBuildConfigGitSourceWithProxyFailure(t *testing.T) {
400-
proxyAddress := "127.0.0.1:3128"
401-
buildConfig := &buildapi.BuildConfig{
402-
ObjectMeta: kapi.ObjectMeta{Name: "config-id", Namespace: "namespace"},
403-
Spec: buildapi.BuildConfigSpec{
404-
RunPolicy: buildapi.BuildRunPolicySerial,
405-
CommonSpec: buildapi.CommonSpec{
406-
Source: buildapi.BuildSource{
407-
Git: &buildapi.GitBuildSource{
408-
URI: "git://github.com/my/repository",
409-
ProxyConfig: buildapi.ProxyConfig{
410-
HTTPProxy: &proxyAddress,
411-
HTTPSProxy: &proxyAddress,
412-
},
413-
},
414-
},
415-
Strategy: buildapi.BuildStrategy{
416-
DockerStrategy: &buildapi.DockerBuildStrategy{},
417-
},
418-
Output: buildapi.BuildOutput{
419-
To: &kapi.ObjectReference{
420-
Kind: "DockerImage",
421-
Name: "repository/data",
422-
},
423-
},
424-
},
425-
},
426-
}
427-
errors := ValidateBuildConfig(buildConfig)
428-
if len(errors) != 1 {
429-
t.Errorf("Expected one error, got %d", len(errors))
430-
}
431-
err := errors[0]
432-
if err.Type != field.ErrorTypeInvalid {
433-
t.Errorf("Expected invalid value validation error, got %q", err.Type)
434-
}
435-
if err.Detail != "only http:// and https:// GIT protocols are allowed with HTTP or HTTPS proxy set" {
436-
t.Errorf("Exptected git:// protocol with proxy validation error, got: %q", err.Detail)
437-
}
438-
}
439-
440399
// TestBuildConfigDockerStrategyImageChangeTrigger ensures that it is invalid to
441400
// have a BuildConfig with Docker strategy and an ImageChangeTrigger where
442401
// neither DockerStrategy.From nor ImageChange.From are defined.

0 commit comments

Comments
 (0)