Merge pull request #820 from roboll/fix-incorrect-remote-cache-on-miss
fix: clean up invalid remote state file cache
This commit is contained in:
		
						commit
						b58e082a8f
					
				
							
								
								
									
										4
									
								
								Makefile
								
								
								
								
							
							
						
						
									
										4
									
								
								Makefile
								
								
								
								
							| 
						 | 
				
			
			@ -26,11 +26,11 @@ integration:
 | 
			
		|||
.PHONY: integration
 | 
			
		||||
 | 
			
		||||
cross:
 | 
			
		||||
	env CGO_ENABLED=0 gox -os '!freebsd !netbsd' -arch '!arm' -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags '-X main.Version=${TAG}' ${TARGETS}
 | 
			
		||||
	env CGO_ENABLED=0 gox -os '!openbsd !freebsd !netbsd' -arch '!arm !mips !mipsle !mips64 !mips64le' -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags '-X main.Version=${TAG}' ${TARGETS}
 | 
			
		||||
.PHONY: cross
 | 
			
		||||
 | 
			
		||||
static-linux:
 | 
			
		||||
	env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "dist/helmfile_linux_amd64" -ldflags '-X main.Version=${TAG}' ${TARGETS}
 | 
			
		||||
	env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOFLAGS=-mod=vendor go build -o "dist/helmfile_linux_amd64" -ldflags '-X main.Version=${TAG}' ${TARGETS}
 | 
			
		||||
.PHONY: linux
 | 
			
		||||
 | 
			
		||||
install:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										2
									
								
								go.mod
								
								
								
								
							| 
						 | 
				
			
			@ -16,7 +16,7 @@ require (
 | 
			
		|||
	github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939
 | 
			
		||||
	github.com/urfave/cli v0.0.0-20160620154522-6011f165dc28
 | 
			
		||||
	go.uber.org/atomic v1.3.2 // indirect
 | 
			
		||||
	go.uber.org/multierr v1.1.0 // indirect
 | 
			
		||||
	go.uber.org/multierr v1.1.0
 | 
			
		||||
	go.uber.org/zap v1.8.0
 | 
			
		||||
	gopkg.in/yaml.v2 v2.2.1
 | 
			
		||||
	gotest.tools v2.2.0+incompatible
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										2
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										2
									
								
								go.sum
								
								
								
								
							| 
						 | 
				
			
			@ -171,6 +171,7 @@ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJ
 | 
			
		|||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/sys v0.0.0-20181213200352-4d1cda033e06 h1:0oC8rFnE+74kEmuHZ46F6KHsMr5Gx2gUQPuNz28iQZM=
 | 
			
		||||
golang.org/x/sys v0.0.0-20181213200352-4d1cda033e06/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 | 
			
		||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 | 
			
		||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=
 | 
			
		||||
| 
						 | 
				
			
			@ -185,6 +186,7 @@ google.golang.org/api v0.1.0 h1:K6z2u68e86TPdSdefXdzvXgR1zEMa+459vBSfWYAZkI=
 | 
			
		|||
google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y=
 | 
			
		||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
 | 
			
		||||
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
 | 
			
		||||
google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk=
 | 
			
		||||
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
 | 
			
		||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
 | 
			
		||||
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,8 +6,10 @@ import (
 | 
			
		|||
	"fmt"
 | 
			
		||||
	"github.com/hashicorp/go-getter"
 | 
			
		||||
	"github.com/hashicorp/go-getter/helper/url"
 | 
			
		||||
	"go.uber.org/multierr"
 | 
			
		||||
	"go.uber.org/zap"
 | 
			
		||||
	"gopkg.in/yaml.v2"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -180,8 +182,10 @@ func (r *Remote) Fetch(goGetterSrc string) (string, error) {
 | 
			
		|||
 | 
			
		||||
	cached := false
 | 
			
		||||
 | 
			
		||||
	// e.g. .helmfile/cache/https_github_com_cloudposse_helmfiles_git.ref=0.xx.0
 | 
			
		||||
	getterDst := filepath.Join(cacheBaseDir, cacheKey)
 | 
			
		||||
 | 
			
		||||
	// e.g. $PWD/.helmfile/cache/https_github_com_cloudposse_helmfiles_git.ref=0.xx.0
 | 
			
		||||
	cacheDirPath := filepath.Join(r.Home, getterDst)
 | 
			
		||||
 | 
			
		||||
	r.Logger.Debugf("home: %s", r.Home)
 | 
			
		||||
| 
						 | 
				
			
			@ -217,6 +221,10 @@ func (r *Remote) Fetch(goGetterSrc string) (string, error) {
 | 
			
		|||
		r.Logger.Debugf("downloading %s to %s", getterSrc, getterDst)
 | 
			
		||||
 | 
			
		||||
		if err := r.Getter.Get(r.Home, getterSrc, getterDst); err != nil {
 | 
			
		||||
			rmerr := os.RemoveAll(cacheDirPath)
 | 
			
		||||
			if rmerr != nil {
 | 
			
		||||
				return "", multierr.Append(err, rmerr)
 | 
			
		||||
			}
 | 
			
		||||
			return "", err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue