Skip to content

Commit

Permalink
feat(libhttp): import libhttp from CE EE-5475 (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
andres-portainer committed Sep 4, 2023
1 parent e47aa0d commit 4a29697
Show file tree
Hide file tree
Showing 36 changed files with 67 additions and 68 deletions.
6 changes: 3 additions & 3 deletions edge/registry/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/portainer/agent"
"github.com/portainer/agent/edge"
"github.com/portainer/agent/edge/aws"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"

"github.com/gorilla/mux"
"github.com/rs/zerolog/log"
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b
github.com/pkg/errors v0.9.1
github.com/portainer/libhttp v0.0.0-20230615144939-a999f666d9a9
github.com/portainer/portainer v0.6.1-0.20230901222702-8cc5e0796c4a
github.com/rs/zerolog v1.29.0
github.com/stretchr/testify v1.8.2
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/portainer/libhttp v0.0.0-20230615144939-a999f666d9a9 h1:Jq8g/pDcFL1Z/DnZgn6DyaWu29y9+RiB5aOJ/Xw4960=
github.com/portainer/libhttp v0.0.0-20230615144939-a999f666d9a9/go.mod h1:H49JLiywwLt2rrJVroafEWy8fIs0i7mThAThK40sbb8=
github.com/portainer/portainer v0.6.1-0.20230901222702-8cc5e0796c4a h1:Vdq9a9Iivgo8oTXJW4HlNNbDRSaye6USkWvtUfDAcfw=
github.com/portainer/portainer v0.6.1-0.20230901222702-8cc5e0796c4a/go.mod h1:D4E7gtKZg0hnP2fyAEHxFd97xnXCCp7DswMRQOWSG3Y=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
Expand Down
4 changes: 2 additions & 2 deletions http/handler/agent/agent_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"errors"
"net/http"

httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/response"
)

func (handler *Handler) agentList(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
Expand Down
2 changes: 1 addition & 1 deletion http/handler/agent/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gorilla/mux"
"github.com/portainer/agent"
"github.com/portainer/agent/http/security"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// Handler is the HTTP handler used to handle agent operations.
Expand Down
6 changes: 3 additions & 3 deletions http/handler/browse/browse_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"net/http"

"github.com/portainer/agent/filesystem"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
)

// DELETE request on /browse/delete?volumeID=:id&path=:path
Expand Down
4 changes: 2 additions & 2 deletions http/handler/browse/browse_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"net/http"

"github.com/portainer/agent/filesystem"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
)

// GET request on /browse/get?volumeID=:id&path=:path
Expand Down
6 changes: 3 additions & 3 deletions http/handler/browse/browse_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"net/http"

"github.com/portainer/agent/filesystem"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
)

// GET request on /browse/ls?volumeID=:id&path=:path
Expand Down
6 changes: 3 additions & 3 deletions http/handler/browse/browse_put.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"net/http"

"github.com/portainer/agent/filesystem"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
)

type browsePutPayload struct {
Expand Down
6 changes: 3 additions & 3 deletions http/handler/browse/browse_rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

"github.com/asaskevich/govalidator"
"github.com/portainer/agent/filesystem"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
)

type browseRenamePayload struct {
Expand Down
2 changes: 1 addition & 1 deletion http/handler/browse/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gorilla/mux"
"github.com/portainer/agent/http/proxy"
"github.com/portainer/agent/http/security"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// Handler is the HTTP handler used to handle volume browsing operations.
Expand Down
4 changes: 2 additions & 2 deletions http/handler/docker/docker_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/portainer/agent"
"github.com/portainer/agent/http/proxy"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/response"

"github.com/rs/zerolog/log"
)
Expand Down
2 changes: 1 addition & 1 deletion http/handler/docker/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/portainer/agent"
"github.com/portainer/agent/http/proxy"
"github.com/portainer/agent/http/security"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// Handler represents an HTTP API handler for proxying requests to the Docker API.
Expand Down
6 changes: 3 additions & 3 deletions http/handler/dockerhub/dockerhub_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"strings"
"time"

httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion http/handler/dockerhub/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gorilla/mux"

"github.com/portainer/agent/http/security"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// Handler represents an HTTP API Handler for host specific actions
Expand Down
2 changes: 1 addition & 1 deletion http/handler/host/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/portainer/agent"
"github.com/portainer/agent/http/proxy"
"github.com/portainer/agent/http/security"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// Handler represents an HTTP API Handler for host specific actions
Expand Down
4 changes: 2 additions & 2 deletions http/handler/host/host_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"net/http"

"github.com/portainer/agent"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/response"
)

func (handler *Handler) hostInfo(rw http.ResponseWriter, r *http.Request) *httperror.HandlerError {
Expand Down
2 changes: 1 addition & 1 deletion http/handler/key/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gorilla/mux"
"github.com/portainer/agent/edge"
"github.com/portainer/agent/http/security"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// Handler is the HTTP handler used to handle Edge key operations.
Expand Down
6 changes: 3 additions & 3 deletions http/handler/key/key_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"errors"
"net/http"

httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"

"github.com/rs/zerolog/log"
)
Expand Down
4 changes: 2 additions & 2 deletions http/handler/key/key_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"errors"
"net/http"

httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/response"
)

type keyInspectResponse struct {
Expand Down
2 changes: 1 addition & 1 deletion http/handler/kubernetes/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gorilla/mux"
"github.com/portainer/agent/exec"
"github.com/portainer/agent/http/security"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// Handler is the HTTP handler used to handle volume browsing operations.
Expand Down
6 changes: 3 additions & 3 deletions http/handler/kubernetes/kubernetes_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (

"github.com/portainer/agent"

httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/portainer/portainer/pkg/libhttp/response"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion http/handler/kubernetesproxy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/gorilla/mux"
"github.com/portainer/agent/http/proxy"
"github.com/portainer/agent/http/security"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// Handler represents an HTTP API handler for proxying requests to the Kubernetes API.
Expand Down
2 changes: 1 addition & 1 deletion http/handler/kubernetesproxy/kubernetes_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"os"

"github.com/portainer/agent"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

func (handler *Handler) kubernetesOperation(rw http.ResponseWriter, request *http.Request) *httperror.HandlerError {
Expand Down
2 changes: 1 addition & 1 deletion http/handler/nomadproxy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/gorilla/mux"
"github.com/portainer/agent/http/proxy"
"github.com/portainer/agent/http/security"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// Handler represents an HTTP API handler for proxying requests to the Nomad API.
Expand Down
2 changes: 1 addition & 1 deletion http/handler/nomadproxy/nomad_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/portainer/agent"

httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

func (handler *Handler) nomadOperation(rw http.ResponseWriter, request *http.Request) *httperror.HandlerError {
Expand Down
3 changes: 2 additions & 1 deletion http/handler/ping/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package ping
import (
"net/http"

httperror "github.com/portainer/portainer/pkg/libhttp/error"

"github.com/gorilla/mux"
httperror "github.com/portainer/libhttp/error"
)

// Handler represents an HTTP API Handler executing a ping operation
Expand Down
4 changes: 2 additions & 2 deletions http/handler/ping/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ping
import (
"net/http"

httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/response"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/response"
)

func (h *Handler) ping(rw http.ResponseWriter, request *http.Request) *httperror.HandlerError {
Expand Down
7 changes: 3 additions & 4 deletions http/handler/websocket/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import (
"net/http/httputil"
"time"

"github.com/asaskevich/govalidator"
"github.com/portainer/libhttp/request"

"github.com/portainer/agent"
"github.com/portainer/agent/http/proxy"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"

"github.com/asaskevich/govalidator"
"github.com/gorilla/websocket"
httperror "github.com/portainer/libhttp/error"
)

func (handler *Handler) websocketAttach(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
Expand Down
9 changes: 5 additions & 4 deletions http/handler/websocket/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"net/http/httputil"
"time"

"github.com/asaskevich/govalidator"
"github.com/gorilla/websocket"
"github.com/portainer/agent"
"github.com/portainer/agent/http/proxy"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"

"github.com/asaskevich/govalidator"
"github.com/gorilla/websocket"
)

func (handler *Handler) websocketExec(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
Expand Down
7 changes: 4 additions & 3 deletions http/handler/websocket/handler.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package websocket

import (
"github.com/gorilla/mux"
"github.com/gorilla/websocket"
"github.com/portainer/agent"
"github.com/portainer/agent/http/security"
"github.com/portainer/agent/kubernetes"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"

"github.com/gorilla/mux"
"github.com/gorilla/websocket"
)

type (
Expand Down
4 changes: 2 additions & 2 deletions http/handler/websocket/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"

"github.com/portainer/agent"
httperror "github.com/portainer/libhttp/error"
"github.com/portainer/libhttp/request"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/portainer/portainer/pkg/libhttp/request"

"github.com/gorilla/websocket"
"github.com/rs/zerolog/log"
Expand Down
2 changes: 1 addition & 1 deletion http/proxy/agentproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"

"github.com/portainer/agent"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"

"github.com/rs/zerolog/log"
)
Expand Down
2 changes: 1 addition & 1 deletion http/proxy/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io"
"net/http"

httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

// LocalProxy is a service used to proxy requests to a Unix socket (Linux) or named pipe (Windows).
Expand Down
2 changes: 1 addition & 1 deletion http/security/notary.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"

"github.com/portainer/agent"
httperror "github.com/portainer/libhttp/error"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
)

type NotaryService struct {
Expand Down
2 changes: 1 addition & 1 deletion http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/portainer/agent/exec"
"github.com/portainer/agent/http/handler"
"github.com/portainer/agent/kubernetes"
httpError "github.com/portainer/libhttp/error"
httpError "github.com/portainer/portainer/pkg/libhttp/error"

"github.com/rs/zerolog/log"
)
Expand Down

0 comments on commit 4a29697

Please sign in to comment.