1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 // Package railsproxy implements Arvados APIs by proxying to the
6 // RailsAPI server on the local machine.
14 "git.arvados.org/arvados.git/lib/controller/rpc"
15 "git.arvados.org/arvados.git/sdk/go/arvados"
18 // For now, FindRailsAPI always uses the rails API running on this
20 func FindRailsAPI(cluster *arvados.Cluster) (*url.URL, bool, error) {
22 for target := range cluster.Services.RailsAPI.InternalURLs {
23 target := url.URL(target)
25 if strings.HasPrefix(target.Host, "localhost:") || strings.HasPrefix(target.Host, "127.0.0.1:") || strings.HasPrefix(target.Host, "[::1]:") {
30 return nil, false, fmt.Errorf("Services.RailsAPI.InternalURLs is empty")
32 return best, cluster.TLS.Insecure, nil
35 func NewConn(cluster *arvados.Cluster) *rpc.Conn {
36 url, insecure, err := FindRailsAPI(cluster)
40 return rpc.NewConn(cluster.ClusterID, url, insecure, rpc.PassthroughTokenProvider)