client: avoid checking token cap on default case

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
v0.8
Tonis Tiigi 2020-09-16 19:29:06 -07:00
parent a2563079f7
commit 6b145fa964
1 changed files with 9 additions and 2 deletions

View File

@ -233,11 +233,15 @@ func Git(remote, ref string, opts ...GitOption) State {
}
if gi.AuthTokenSecret != "" {
attrs[pb.AttrAuthTokenSecret] = gi.AuthTokenSecret
addCap(&gi.Constraints, pb.CapSourceGitHTTPAuth)
if gi.addAuthCap {
addCap(&gi.Constraints, pb.CapSourceGitHTTPAuth)
}
}
if gi.AuthHeaderSecret != "" {
attrs[pb.AttrAuthHeaderSecret] = gi.AuthHeaderSecret
addCap(&gi.Constraints, pb.CapSourceGitHTTPAuth)
if gi.addAuthCap {
addCap(&gi.Constraints, pb.CapSourceGitHTTPAuth)
}
}
addCap(&gi.Constraints, pb.CapSourceGit)
@ -260,6 +264,7 @@ type GitInfo struct {
KeepGitDir bool
AuthTokenSecret string
AuthHeaderSecret string
addAuthCap bool
}
func KeepGitDir() GitOption {
@ -271,12 +276,14 @@ func KeepGitDir() GitOption {
func AuthTokenSecret(v string) GitOption {
return gitOptionFunc(func(gi *GitInfo) {
gi.AuthTokenSecret = v
gi.addAuthCap = true
})
}
func AuthHeaderSecret(v string) GitOption {
return gitOptionFunc(func(gi *GitInfo) {
gi.AuthHeaderSecret = v
gi.addAuthCap = true
})
}