func (conn *Conn) localOrLoginCluster() backend {
if conn.cluster.Login.LoginCluster != "" {
return conn.chooseBackend(conn.cluster.Login.LoginCluster)
- } else {
- return conn.local
}
+ return conn.local
}
// Call fn with the local backend; then, if fn returned 404, call fn
c.ManifestText = rewriteManifest(c.ManifestText, options.UUID[:5])
}
return c, err
- } else {
- // UUID is a PDH
- first := make(chan arvados.Collection, 1)
- err := conn.tryLocalThenRemotes(ctx, options.ForwardedFor, func(ctx context.Context, remoteID string, be backend) error {
- remoteOpts := options
- remoteOpts.ForwardedFor = conn.cluster.ClusterID + "-" + options.ForwardedFor
- c, err := be.CollectionGet(ctx, remoteOpts)
- if err != nil {
- return err
- }
- // options.UUID is either hash+size or
- // hash+size+hints; only hash+size need to
- // match the computed PDH.
- if pdh := arvados.PortableDataHash(c.ManifestText); pdh != options.UUID && !strings.HasPrefix(options.UUID, pdh+"+") {
- err = httpErrorf(http.StatusBadGateway, "bad portable data hash %q received from remote %q (expected %q)", pdh, remoteID, options.UUID)
- ctxlog.FromContext(ctx).Warn(err)
- return err
- }
- if remoteID != "" {
- c.ManifestText = rewriteManifest(c.ManifestText, remoteID)
- }
- select {
- case first <- c:
- return nil
- default:
- // lost race, return value doesn't matter
- return nil
- }
- })
+ }
+ // UUID is a PDH
+ first := make(chan arvados.Collection, 1)
+ err := conn.tryLocalThenRemotes(ctx, options.ForwardedFor, func(ctx context.Context, remoteID string, be backend) error {
+ remoteOpts := options
+ remoteOpts.ForwardedFor = conn.cluster.ClusterID + "-" + options.ForwardedFor
+ c, err := be.CollectionGet(ctx, remoteOpts)
if err != nil {
- return arvados.Collection{}, err
+ return err
}
- return <-first, nil
+ // options.UUID is either hash+size or
+ // hash+size+hints; only hash+size need to
+ // match the computed PDH.
+ if pdh := arvados.PortableDataHash(c.ManifestText); pdh != options.UUID && !strings.HasPrefix(options.UUID, pdh+"+") {
+ err = httpErrorf(http.StatusBadGateway, "bad portable data hash %q received from remote %q (expected %q)", pdh, remoteID, options.UUID)
+ ctxlog.FromContext(ctx).Warn(err)
+ return err
+ }
+ if remoteID != "" {
+ c.ManifestText = rewriteManifest(c.ManifestText, remoteID)
+ }
+ select {
+ case first <- c:
+ return nil
+ default:
+ // lost race, return value doesn't matter
+ return nil
+ }
+ })
+ if err != nil {
+ return arvados.Collection{}, err
}
+ return <-first, nil
}
func (conn *Conn) CollectionList(ctx context.Context, options arvados.ListOptions) (arvados.CollectionList, error) {
return arvados.UserList{}, err
}
return resp, nil
- } else {
- return conn.generated_UserList(ctx, options)
}
+ return conn.generated_UserList(ctx, options)
}
func (conn *Conn) UserCreate(ctx context.Context, options arvados.CreateOptions) (arvados.User, error) {
func errStatus(err error) int {
if httpErr, ok := err.(interface{ HTTPStatus() int }); ok {
return httpErr.HTTPStatus()
- } else {
- return http.StatusInternalServerError
}
+ return http.StatusInternalServerError
}