Compare commits
10 Commits
Author | SHA1 | Date |
---|---|---|
|
5e304aa681 | |
|
c9da5bb517 | |
|
c471ca2d9e | |
|
07720115fd | |
|
aa1022267e | |
|
939c1fb08d | |
|
3062696970 | |
|
de7dc27cf8 | |
|
aa4bbaca87 | |
|
79698166a1 |
|
@ -59,7 +59,7 @@ func (k *ResolvedKeychain) Resolve(resource authn.Resource) (authn.Authenticator
|
|||
if ok {
|
||||
authConfig, err := authHeaderToConfig(header)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "parsing auth header '%s'", header)
|
||||
return nil, errors.Wrap(err, "parsing auth header")
|
||||
}
|
||||
|
||||
return &providedAuth{config: authConfig}, nil
|
||||
|
@ -118,10 +118,11 @@ func buildAuthMap(keychain authn.Keychain, images ...string) map[string]string {
|
|||
continue
|
||||
}
|
||||
|
||||
registryAuths[reference.Context().Registry.Name()], err = authConfigToHeader(authConfig)
|
||||
header, err := authConfigToHeader(authConfig)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
registryAuths[reference.Context().Registry.Name()] = header
|
||||
}
|
||||
|
||||
return registryAuths
|
||||
|
@ -176,7 +177,7 @@ func authHeaderToConfig(header string) (*authn.AuthConfig, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
return nil, errors.Errorf("unknown auth type from header: %s", header)
|
||||
return nil, errors.New("unknown auth type from header")
|
||||
}
|
||||
|
||||
// ReferenceForRepoName returns a reference and an authenticator for a given image name and keychain.
|
||||
|
|
|
@ -155,6 +155,7 @@ func testEnvKeychain(t *testing.T, when spec.G, it spec.S) {
|
|||
resolvedKeychain = auth.ResolvedKeychain{Auths: map[string]string{
|
||||
"basic-registry.com": "Basic some-basic-auth=",
|
||||
"bearer-registry.com": "Bearer some-bearer-auth=",
|
||||
"bad-header.com": "Some Bad Header",
|
||||
}}
|
||||
})
|
||||
|
||||
|
@ -184,6 +185,18 @@ func testEnvKeychain(t *testing.T, when spec.G, it spec.S) {
|
|||
|
||||
h.AssertEq(t, header, &authn.AuthConfig{RegistryToken: "some-bearer-auth="})
|
||||
})
|
||||
|
||||
when("error parsing header", func() {
|
||||
it("doesn't print the header in the error message", func() {
|
||||
registry, err := name.NewRegistry("bad-header.com", name.WeakValidation)
|
||||
h.AssertNil(t, err)
|
||||
|
||||
_, err = resolvedKeychain.Resolve(registry)
|
||||
h.AssertNotNil(t, err)
|
||||
h.AssertStringContains(t, err.Error(), "parsing auth header")
|
||||
h.AssertStringDoesNotContain(t, err.Error(), "Some Bad Header")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
when("auth header is not found", func() {
|
||||
|
|
|
@ -83,7 +83,7 @@ func (b *Descriptor) Detect(config *DetectConfig) DetectRun {
|
|||
}
|
||||
var t DetectRun
|
||||
if _, err := toml.DecodeFile(planPath, &t); err != nil {
|
||||
return DetectRun{Code: -1, Err: err}
|
||||
return DetectRun{Code: -1, Err: err, Output: out.Bytes()}
|
||||
}
|
||||
if api.MustParse(b.API).Equal(api.MustParse("0.2")) {
|
||||
if t.hasInconsistentVersions() || t.Or.hasInconsistentVersions() {
|
||||
|
|
|
@ -117,6 +117,17 @@ func testDetect(t *testing.T, when spec.G, it spec.S) {
|
|||
}
|
||||
})
|
||||
|
||||
it("should fail and print the output if the buildpack plan file has a bad format", func() {
|
||||
toappfile("\nbad=toml", "detect-plan-A-v1.toml")
|
||||
|
||||
detectRun := bpTOML.Detect(&detectConfig)
|
||||
|
||||
h.AssertEq(t, detectRun.Code, -1)
|
||||
h.AssertStringContains(t, string(detectRun.Output), "detect out: A@v1") // the output from the buildpack detect script
|
||||
err := detectRun.Err
|
||||
h.AssertEq(t, err.Error(), `Near line 2 (last key parsed 'bad'): expected value but found "toml" instead`)
|
||||
})
|
||||
|
||||
it("should fail if buildpacks have both a top level version and a metadata version", func() {
|
||||
toappfile("\n[[requires]]\n name = \"dep2\"\n version = \"some-version\"", "detect-plan-A-v1.toml")
|
||||
toappfile("\n[requires.metadata]\n version = \"some-version\"", "detect-plan-A-v1.toml")
|
||||
|
|
2
go.mod
2
go.mod
|
@ -4,7 +4,7 @@ require (
|
|||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 // indirect
|
||||
github.com/apex/log v1.9.0
|
||||
github.com/buildpacks/imgutil v0.0.0-20210426134414-c5ab3dea4e00
|
||||
github.com/buildpacks/imgutil v0.0.0-20210510154637-009f91f52918
|
||||
github.com/containerd/containerd v1.3.3 // indirect
|
||||
github.com/docker/cli v0.0.0-20200312141509-ef2f64abbd37 // indirect
|
||||
github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7
|
||||
|
|
4
go.sum
4
go.sum
|
@ -47,8 +47,8 @@ github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN
|
|||
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
|
||||
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
||||
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
|
||||
github.com/buildpacks/imgutil v0.0.0-20210426134414-c5ab3dea4e00 h1:+CL2ZuzycHsLWbJLlLt5efbRxbcyUh7jBs9w1KOvOCY=
|
||||
github.com/buildpacks/imgutil v0.0.0-20210426134414-c5ab3dea4e00/go.mod h1:ZQdcfsoyeqJvSdnUcCiS3Njhj0SZgBllJBnx5ojmgaQ=
|
||||
github.com/buildpacks/imgutil v0.0.0-20210510154637-009f91f52918 h1:SzI5Uwnus3g/HQCFri+svWNiht4y8+jE2+QR8kzLPps=
|
||||
github.com/buildpacks/imgutil v0.0.0-20210510154637-009f91f52918/go.mod h1:ZQdcfsoyeqJvSdnUcCiS3Njhj0SZgBllJBnx5ojmgaQ=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
|
|
|
@ -4,7 +4,7 @@ go 1.15
|
|||
|
||||
require (
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/buildpacks/imgutil v0.0.0-20210426134414-c5ab3dea4e00
|
||||
github.com/buildpacks/imgutil v0.0.0-20210510154637-009f91f52918
|
||||
github.com/buildpacks/lifecycle v0.9.2
|
||||
github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7
|
||||
github.com/golang/mock v1.5.0
|
||||
|
|
|
@ -62,8 +62,8 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
|
|||
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
|
||||
github.com/bombsimon/wsl/v3 v3.1.0 h1:E5SRssoBgtVFPcYWUOFJEcgaySgdtTNYzsSKDOY7ss8=
|
||||
github.com/bombsimon/wsl/v3 v3.1.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc=
|
||||
github.com/buildpacks/imgutil v0.0.0-20210426134414-c5ab3dea4e00 h1:+CL2ZuzycHsLWbJLlLt5efbRxbcyUh7jBs9w1KOvOCY=
|
||||
github.com/buildpacks/imgutil v0.0.0-20210426134414-c5ab3dea4e00/go.mod h1:ZQdcfsoyeqJvSdnUcCiS3Njhj0SZgBllJBnx5ojmgaQ=
|
||||
github.com/buildpacks/imgutil v0.0.0-20210510154637-009f91f52918 h1:SzI5Uwnus3g/HQCFri+svWNiht4y8+jE2+QR8kzLPps=
|
||||
github.com/buildpacks/imgutil v0.0.0-20210510154637-009f91f52918/go.mod h1:ZQdcfsoyeqJvSdnUcCiS3Njhj0SZgBllJBnx5ojmgaQ=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
|
|
Loading…
Reference in New Issue