Skip to content

Commit

Permalink
fix panic when timeout is nil in gitlab cloneOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
yudong2015 authored and ks-ci-bot committed Oct 26, 2023
1 parent 6afb8d9 commit 1229356
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/client/devops/jenkins/internal/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ func GetGitlabSourceFromEtree(source *etree.Element) (gitSource *devopsv1alpha3.
if value, err := strconv.ParseBool(cloneExtension.SelectElement("shallow").Text()); err == nil {
gitSource.CloneOption.Shallow = value
}
if value, err := strconv.ParseInt(cloneExtension.SelectElement("timeout").Text(), 10, 32); err == nil {
gitSource.CloneOption.Timeout = int(value)
if timeout := cloneExtension.SelectElement("timeout"); timeout != nil {
if value, err := strconv.ParseInt(timeout.Text(), 10, 32); err == nil {
gitSource.CloneOption.Timeout = int(value)
}
}
if value, err := strconv.ParseInt(cloneExtension.SelectElement("depth").Text(), 10, 32); err == nil {
gitSource.CloneOption.Depth = int(value)
if depth := cloneExtension.SelectElement("depth"); depth != nil {
if value, err := strconv.ParseInt(depth.Text(), 10, 32); err == nil {
gitSource.CloneOption.Depth = int(value)
}
}
}
}
Expand Down

0 comments on commit 1229356

Please sign in to comment.