Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ Copyright (c) 2013 Dario Castañé. All rights reserved.
Copyright (c) 2012 The Go Authors. All rights reserved.
License - https://github.com/darccio/mergo/blob/master/LICENSE

gorilla/mux - https://github.com/gorilla/mux
Copyright (c) 2023 The Gorilla Authors. All rights reserved.
License - https://github.com/gorilla/mux/blob/main/LICENSE

palantir/pkg - https://github.com/palantir/pkg
Copyright (c) 2016, Palantir Technologies, Inc.
License - https://github.com/palantir/pkg/blob/master/LICENSE
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/invariant/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ Pattern = "POST /api/2.0/sql/statements/"
Response.Body = '{"status": {"state": "SUCCEEDED"}, "manifest": {"schema": {"columns": []}}}'

[[Server]]
Pattern = "DELETE /api/2.1/unity-catalog/tables/{name}"
Pattern = "DELETE /api/2.1/unity-catalog/tables/{full_name}"
Response.Body = '{"status": "OK"}'
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Pattern = "POST /api/2.0/sql/statements/"
Response.Body = '{"status": {"state": "SUCCEEDED"}, "manifest": {"schema": {"columns": []}}}'

[[Server]]
Pattern = "DELETE /api/2.1/unity-catalog/tables/{name}"
Pattern = "DELETE /api/2.1/unity-catalog/tables/{full_name}"
Response.Body = '{"status": "OK"}'
7 changes: 4 additions & 3 deletions acceptance/internal/prepare_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ func startLocalServer(t *testing.T,
killCountersMu := &sync.Mutex{}

for ind := range stubs {
// We want later stubs takes precedence, because then leaf configs take precedence over parent directory configs
// In gorilla/mux earlier handlers take precedence, so we need to reverse the order
// Later stubs take precedence over earlier ones (leaf configs override parent configs).
// The first handler registered for a given pattern wins, so we reverse the order.
stub := stubs[len(stubs)-1-ind]
require.NotEmpty(t, stub.Pattern)
items := strings.Split(stub.Pattern, " ")
Expand Down Expand Up @@ -226,7 +226,8 @@ func startLocalServer(t *testing.T,
})
}

// The earliest handlers take precedence, add default handlers last
// The first handler registered for a given pattern wins, so default
// handlers registered last serve as fallbacks.
testserver.AddDefaultHandlers(s)
return s.URL
}
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ require (
github.com/fatih/color v1.19.0 // MIT
github.com/google/jsonschema-go v0.4.2 // MIT
github.com/google/uuid v1.6.0 // BSD-3-Clause
github.com/gorilla/mux v1.8.1 // BSD-3-Clause
github.com/gorilla/websocket v1.5.3 // BSD-2-Clause
github.com/hashicorp/go-version v1.8.0 // MPL-2.0
github.com/hashicorp/hc-install v0.9.3 // MPL-2.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.11 h1:vAe81Msw+8tKUxi2Dq
github.com/googleapis/enterprise-certificate-proxy v0.3.11/go.mod h1:RFV7MUdlb7AgEq2v7FmMCfeSMCllAzWxFgRdusoGks8=
github.com/googleapis/gax-go/v2 v2.17.0 h1:RksgfBpxqff0EZkDWYuz9q/uWsTVz+kf43LsZ1J6SMc=
github.com/googleapis/gax-go/v2 v2.17.0/go.mod h1:mzaqghpQp4JDh3HvADwrat+6M3MOIDp5YKHhb9PAgDY=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
Expand Down
14 changes: 7 additions & 7 deletions libs/testserver/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func AddDefaultHandlers(server *Server) {
return ""
})

server.Handle("POST", "/api/2.0/workspace-files/import-file/{path:.*}", func(req Request) any {
server.Handle("POST", "/api/2.0/workspace-files/import-file/{path...}", func(req Request) any {
path := req.Vars["path"]
overwrite := req.URL.Query().Get("overwrite") == "true"
return req.Workspace.WorkspaceFilesImportFile(path, req.Body, overwrite)
Expand Down Expand Up @@ -145,12 +145,12 @@ func AddDefaultHandlers(server *Server) {
return req.Workspace.WorkspaceFilesImportFile(request.Path, decoded, request.Overwrite)
})

server.Handle("GET", "/api/2.0/workspace-files/{path:.*}", func(req Request) any {
server.Handle("GET", "/api/2.0/workspace-files/{path...}", func(req Request) any {
path := req.Vars["path"]
return req.Workspace.WorkspaceFilesExportFile(path)
})

server.Handle("HEAD", "/api/2.0/fs/directories/{path:.*}", func(req Request) any {
server.Handle("HEAD", "/api/2.0/fs/directories/{path...}", func(req Request) any {
dirPath := req.Vars["path"]
if !strings.HasPrefix(dirPath, "/") {
dirPath = "/" + dirPath
Expand All @@ -165,15 +165,15 @@ func AddDefaultHandlers(server *Server) {
return Response{StatusCode: 404}
})

server.Handle("HEAD", "/api/2.0/fs/files/{path:.*}", func(req Request) any {
server.Handle("HEAD", "/api/2.0/fs/files/{path...}", func(req Request) any {
path := req.Vars["path"]
if req.Workspace.FileExists(path) {
return Response{StatusCode: 200}
}
return Response{StatusCode: 404}
})

server.Handle("PUT", "/api/2.0/fs/directories/{path:.*}", func(req Request) any {
server.Handle("PUT", "/api/2.0/fs/directories/{path...}", func(req Request) any {
dirPath := req.Vars["path"]
if !strings.HasPrefix(dirPath, "/") {
dirPath = "/" + dirPath
Expand All @@ -194,13 +194,13 @@ func AddDefaultHandlers(server *Server) {
return Response{}
})

server.Handle("PUT", "/api/2.0/fs/files/{path:.*}", func(req Request) any {
server.Handle("PUT", "/api/2.0/fs/files/{path...}", func(req Request) any {
path := req.Vars["path"]
overwrite := req.URL.Query().Get("overwrite") == "true"
return req.Workspace.WorkspaceFilesImportFile(path, req.Body, overwrite)
})

server.Handle("GET", "/api/2.0/fs/files/{path:.*}", func(req Request) any {
server.Handle("GET", "/api/2.0/fs/files/{path...}", func(req Request) any {
path := req.Vars["path"]
data := req.Workspace.WorkspaceFilesExportFile(path)
if data == nil {
Expand Down
Loading
Loading