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 // FindRailsAPI always uses the rails API running on this node, for now.
19 func FindRailsAPI(cluster *arvados.Cluster) (*url.URL, bool, error) {
21 for target := range cluster.Services.RailsAPI.InternalURLs {
22 target := url.URL(target)
24 if strings.HasPrefix(target.Host, "localhost:") || strings.HasPrefix(target.Host, "127.0.0.1:") || strings.HasPrefix(target.Host, "[::1]:") {
29 return nil, false, fmt.Errorf("Services.RailsAPI.InternalURLs is empty")
31 return best, cluster.TLS.Insecure, nil
34 func NewConn(cluster *arvados.Cluster) *rpc.Conn {
35 url, insecure, err := FindRailsAPI(cluster)
39 return rpc.NewConn(cluster.ClusterID, url, insecure, rpc.PassthroughTokenProvider)