Skip to content

Commit edc66be

Browse files
add retry on push (#104)
1 parent 3fc51ac commit edc66be

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.0.100
1+
VERSION=v0.0.101
22
OUT_DIR=dist
33
YEAR?=$(shell date +"%Y")
44

cmd/commands/git-source.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ package commands
1616

1717
import (
1818
"context"
19+
"errors"
1920
"fmt"
2021
"os"
2122
"time"
@@ -35,6 +36,7 @@ import (
3536
wf "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow"
3637
wfv1alpha1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
3738
"github.com/go-git/go-billy/v5/memfs"
39+
"github.com/go-git/go-git/v5/plumbing/transport"
3840
"github.com/spf13/cobra"
3941
v1 "k8s.io/api/core/v1"
4042
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -169,12 +171,23 @@ func RunGitSourceCreate(ctx context.Context, opts *GitSourceCreateOptions) error
169171
return fmt.Errorf("failed to create demo workflowTemplate: %w", err)
170172
}
171173

172-
_, err = gsRepo.Persist(ctx, &git.PushOptions{
174+
pOpts := &git.PushOptions{
173175
CommitMsg: fmt.Sprintf("Created demo workflow template in %s Directory", opts.gsCloneOpts.Path()),
174-
})
176+
}
175177

178+
_, err = gsRepo.Persist(ctx, pOpts)
176179
if err != nil {
177-
return fmt.Errorf("failed to push changes. Err: %w", err)
180+
if errors.Is(err, transport.ErrRepositoryNotFound) {
181+
log.G(ctx).Warn("failed to persist git-source repo, trying again in 3 seconds...")
182+
time.Sleep(time.Second * 3)
183+
184+
_, err = gsRepo.Persist(ctx, pOpts)
185+
if err != nil {
186+
return fmt.Errorf("failed to push changes. Err: %w", err)
187+
}
188+
} else {
189+
return fmt.Errorf("failed to push changes. Err: %w", err)
190+
}
178191
}
179192
}
180193

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ cf version
2020
### Linux
2121
```bash
2222
# download and extract the binary
23-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.100/cf-linux-amd64.tar.gz | tar zx
23+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.101/cf-linux-amd64.tar.gz | tar zx
2424

2525
# move the binary to your $PATH
2626
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -32,7 +32,7 @@ cf version
3232
### Mac
3333
```bash
3434
# download and extract the binary
35-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.100/cf-darwin-amd64.tar.gz | tar zx
35+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.0.101/cf-darwin-amd64.tar.gz | tar zx
3636

3737
# move the binary to your $PATH
3838
mv ./cf-darwin-amd64 /usr/local/bin/cf

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
github.com/fatih/color v1.12.0
1515
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
1616
github.com/go-git/go-billy/v5 v5.3.1
17+
github.com/go-git/go-git/v5 v5.4.1
1718
github.com/gobuffalo/packr v1.30.1
1819
github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a
1920
github.com/lunixbochs/vtclean v1.0.0 // indirect

manifests/runtime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
namespace: "{{ namespace }}"
66
spec:
77
defVersion: 1.0.0
8-
version: 0.0.100
8+
version: 0.0.101
99
bootstrapSpecifier: github.com/codefresh-io/cli-v2/manifests/argo-cd
1010
components:
1111
- name: events

0 commit comments

Comments
 (0)