Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
uwedeportivo committed May 14, 2020
1 parent f183a79 commit 9f58a28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cmd/src/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ query ListRepos($cloneInProgress: Boolean!, $cloned: Boolean!, $notCloned: Boole
}
}`

func (vd *validator) listClonedRepos(filterNames interface{}) ([]string, error) {
fs := vd.convertStringList(filterNames)
func (vd *validator) listClonedReposImpl(fs []string) ([]string, error) {
var resp struct {
Repositories struct {
Nodes []struct {
Expand All @@ -261,20 +260,25 @@ func (vd *validator) listClonedRepos(filterNames interface{}) ([]string, error)
return names, err
}

func (vd *validator) waitRepoCloned(repoName string, sleepSeconds int, maxTries int) error {
func (vd *validator) listClonedRepos(filterNames interface{}) ([]string, error) {
fs := vd.convertStringList(filterNames)
return vd.listClonedReposImpl(fs)
}

func (vd *validator) waitRepoCloned(repoName string, sleepSeconds int, maxTries int) (bool, error) {
nameFilter := []string{repoName}

for i := 0; i < maxTries; i++ {
names, err := vd.listClonedRepos(nameFilter)
names, err := vd.listClonedReposImpl(nameFilter)
if err != nil {
return err
return false, err
}
if len(names) == 1 {
return nil
return true, nil
}
time.Sleep(time.Second * time.Duration(sleepSeconds))
}
return fmt.Errorf("repo %s not cloned after %d tries", repoName, maxTries)
return false, nil
}

func (vd *validator) log(line string) {
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
Expand Down

0 comments on commit 9f58a28

Please sign in to comment.