package federation
import (
+ "bytes"
"context"
"crypto/md5"
+ "encoding/json"
"errors"
"fmt"
"net/http"
"regexp"
"strings"
+ "git.curoverse.com/arvados.git/lib/config"
"git.curoverse.com/arvados.git/lib/controller/railsproxy"
"git.curoverse.com/arvados.git/lib/controller/rpc"
"git.curoverse.com/arvados.git/sdk/go/arvados"
return fmt.Sprintf("%x+%d", h.Sum(nil), size)
}
+func (conn *Conn) ConfigGet(ctx context.Context) (json.RawMessage, error) {
+ var buf bytes.Buffer
+ err := config.ExportJSON(&buf, conn.cluster)
+ return json.RawMessage(buf.Bytes()), err
+}
+
func (conn *Conn) CollectionGet(ctx context.Context, options arvados.GetOptions) (arvados.Collection, error) {
if len(options.UUID) == 27 {
// UUID is really a UUID
package controller
import (
- "bytes"
"context"
"database/sql"
"errors"
"fmt"
- "io"
"net/http"
"net/url"
"strings"
"sync"
"time"
- "git.curoverse.com/arvados.git/lib/config"
"git.curoverse.com/arvados.git/lib/controller/federation"
"git.curoverse.com/arvados.git/lib/controller/railsproxy"
"git.curoverse.com/arvados.git/lib/controller/router"
Routes: health.Routes{"ping": func() error { _, err := h.db(&http.Request{}); return err }},
})
- mux.Handle("/arvados/v1/config", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- var buf bytes.Buffer
- err := config.ExportJSON(&buf, h.Cluster)
- if err != nil {
- httpserver.Error(w, err.Error(), http.StatusInternalServerError)
- return
- }
- w.Header().Set("Content-Type", "application/json")
- io.Copy(w, &buf)
- }))
+ rtr := router.New(federation.New(h.Cluster))
+ mux.Handle("/arvados/v1/config", rtr)
if h.Cluster.EnableBetaController14287 {
- rtr := router.New(federation.New(h.Cluster))
mux.Handle("/arvados/v1/collections", rtr)
mux.Handle("/arvados/v1/collections/", rtr)
}
resp := httptest.NewRecorder()
s.handler.ServeHTTP(resp, req)
c.Check(resp.Code, check.Equals, http.StatusOK)
+ c.Check(resp.Header().Get("Access-Control-Allow-Origin"), check.Equals, `*`)
+ c.Check(resp.Header().Get("Access-Control-Allow-Methods"), check.Matches, `.*\bGET\b.*`)
+ c.Check(resp.Header().Get("Access-Control-Allow-Headers"), check.Matches, `.+`)
var cluster arvados.Cluster
c.Log(resp.Body.String())
err := json.Unmarshal(resp.Body.Bytes(), &cluster)
defaultOpts func() interface{}
exec routableFunc
}{
+ {
+ arvados.EndpointConfigGet,
+ func() interface{} { return &struct{}{} },
+ func(ctx context.Context, opts interface{}) (interface{}, error) {
+ return rtr.fed.ConfigGet(ctx)
+ },
+ },
{
arvados.EndpointCollectionCreate,
func() interface{} { return &arvados.CreateOptions{} },
return aClient.RequestAndDecodeContext(ctx, dst, ep.Method, path, body, params)
}
+func (conn *Conn) ConfigGet(ctx context.Context) (json.RawMessage, error) {
+ ep := arvados.EndpointConfigGet
+ var resp json.RawMessage
+ err := conn.requestAndDecode(ctx, &resp, ep, nil, nil)
+ return resp, err
+}
+
func (conn *Conn) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
ep := arvados.EndpointCollectionCreate
var resp arvados.Collection
package arvados
-import "context"
+import (
+ "context"
+ "encoding/json"
+)
type APIEndpoint struct {
Method string
}
var (
+ EndpointConfigGet = APIEndpoint{"GET", "arvados/v1/config", ""}
EndpointCollectionCreate = APIEndpoint{"POST", "arvados/v1/collections", "collection"}
EndpointCollectionUpdate = APIEndpoint{"PATCH", "arvados/v1/collections/:uuid", "collection"}
EndpointCollectionGet = APIEndpoint{"GET", "arvados/v1/collections/:uuid", ""}
}
type API interface {
+ ConfigGet(ctx context.Context) (json.RawMessage, error)
CollectionCreate(ctx context.Context, options CreateOptions) (Collection, error)
CollectionUpdate(ctx context.Context, options UpdateOptions) (Collection, error)
CollectionGet(ctx context.Context, options GetOptions) (Collection, error)
import (
"context"
+ "encoding/json"
"errors"
"reflect"
"runtime"
mtx sync.Mutex
}
+func (as *APIStub) ConfigGet(ctx context.Context) (json.RawMessage, error) {
+ as.appendCall(as.ConfigGet, ctx, nil)
+ return nil, as.Error
+}
func (as *APIStub) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
as.appendCall(as.CollectionCreate, ctx, options)
return arvados.Collection{}, as.Error