Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Go resolver should return strings as is on any kind of error #446

Merged
merged 1 commit into from
Oct 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions k8s/go/cmd/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ func resolveString(r *resolver, s string) (string, error) {
}
auth, err := authn.DefaultKeychain.Resolve(t.Context())
if err != nil {
return "", fmt.Errorf("unable to get the authenticator using the default keychain for image %v: %v", t, auth)
return s, nil
smukherj1 marked this conversation as resolved.
Show resolved Hide resolved
}
desc, err := remote.Get(t, remote.WithAuth(auth))
if err != nil {
return "", fmt.Errorf("unable to get image %v from registry: %v", t, err)
return s, nil
}
resolved := fmt.Sprintf("%s/%s@%v", t.Context().RegistryStr(), t.Context().RepositoryStr(), desc.Digest)
r.resolvedImages[s] = resolved
Expand Down Expand Up @@ -265,7 +265,7 @@ func (r *resolver) resolveList(l []interface{}) ([]interface{}, error) {
for _, i := range l {
o, err := r.resolveItem(i)
if err != nil {
return nil, err
return nil, fmt.Errorf("error resolving item %v in list: %v", i, err)
}
result = append(result, o)
}
Expand All @@ -278,11 +278,11 @@ func (r *resolver) resolveMap(m map[interface{}]interface{}) (map[interface{}]in
for k, v := range m {
rk, err := r.resolveItem(k)
if err != nil {
return nil, err
return nil, fmt.Errorf("error resolving key %v in map: %v", k, err)
}
rv, err := r.resolveItem(v)
if err != nil {
return nil, err
return nil, fmt.Errorf("error resolving value %v in map: %v", v, err)
}
result[rk] = rv
}
Expand Down Expand Up @@ -369,6 +369,9 @@ func (r *resolver) resolveYAML(t io.Reader) ([]byte, error) {
}
done := err == io.EOF
o, err := r.resolveItem(y.val())
if err != nil {
return nil, fmt.Errorf("error resolving YAML template: %v", err)
}
if o != nil {
r.numDocs++
err = e.Encode(o)
Expand Down