From 8cc5e0796c4ac8e5e8e4310ca5b4230c32371bcd Mon Sep 17 00:00:00 2001 From: andres-portainer <91705312+andres-portainer@users.noreply.github.com> Date: Fri, 1 Sep 2023 19:27:02 -0300 Subject: [PATCH] feat(libhttp): move into the Portainer repository EE-5475 (#10231) --- api/.golangci.yaml | 2 + api/adminmonitor/admin_monitor.go | 2 +- api/http/errors/tx.go | 2 +- api/http/handler/auth/authenticate.go | 6 +- api/http/handler/auth/authenticate_oauth.go | 4 +- api/http/handler/auth/handler.go | 2 +- api/http/handler/auth/logout.go | 4 +- api/http/handler/backup/backup.go | 4 +- api/http/handler/backup/handler.go | 2 +- api/http/handler/backup/restore.go | 4 +- .../customtemplates/customtemplate_create.go | 9 +- .../customtemplates/customtemplate_delete.go | 7 +- .../customtemplates/customtemplate_file.go | 6 +- .../customtemplate_git_fetch.go | 6 +- .../customtemplates/customtemplate_inspect.go | 6 +- .../customtemplates/customtemplate_list.go | 4 +- .../customtemplates/customtemplate_update.go | 6 +- api/http/handler/customtemplates/handler.go | 2 +- .../containers/container_gpus_inspect.go | 9 +- api/http/handler/docker/containers/handler.go | 2 +- .../handler/docker/containers/recreate.go | 6 +- api/http/handler/docker/handler.go | 10 +- .../handler/edgegroups/edgegroup_create.go | 4 +- .../handler/edgegroups/edgegroup_delete.go | 6 +- .../handler/edgegroups/edgegroup_inspect.go | 4 +- api/http/handler/edgegroups/edgegroup_list.go | 2 +- .../handler/edgegroups/edgegroup_update.go | 4 +- api/http/handler/edgegroups/handler.go | 4 +- api/http/handler/edgejobs/edgejob_create.go | 4 +- api/http/handler/edgejobs/edgejob_delete.go | 6 +- api/http/handler/edgejobs/edgejob_file.go | 6 +- api/http/handler/edgejobs/edgejob_inspect.go | 6 +- api/http/handler/edgejobs/edgejob_list.go | 4 +- .../edgejobs/edgejob_tasklogs_clear.go | 6 +- .../edgejobs/edgejob_tasklogs_collect.go | 6 +- .../edgejobs/edgejob_tasklogs_inspect.go | 6 +- .../handler/edgejobs/edgejob_tasks_list.go | 4 +- api/http/handler/edgejobs/edgejob_update.go | 4 +- api/http/handler/edgejobs/handler.go | 4 +- .../handler/edgestacks/edgestack_create.go | 6 +- .../edgestacks/edgestack_create_file.go | 2 +- .../edgestacks/edgestack_create_git.go | 2 +- .../edgestacks/edgestack_create_string.go | 2 +- .../handler/edgestacks/edgestack_delete.go | 6 +- api/http/handler/edgestacks/edgestack_file.go | 6 +- .../handler/edgestacks/edgestack_inspect.go | 6 +- api/http/handler/edgestacks/edgestack_list.go | 4 +- .../edgestacks/edgestack_status_delete.go | 6 +- .../edgestacks/edgestack_status_update.go | 8 +- .../handler/edgestacks/edgestack_update.go | 9 +- api/http/handler/edgestacks/handler.go | 5 +- .../edgetemplates/edgetemplate_list.go | 4 +- api/http/handler/edgetemplates/handler.go | 6 +- .../endpointedge/endpointedge_job_logs.go | 6 +- .../endpointedge_stack_inspect.go | 8 +- .../endpointedge_status_inspect.go | 6 +- api/http/handler/endpointedge/handler.go | 2 +- .../endpointgroups/endpointgroup_create.go | 6 +- .../endpointgroups/endpointgroup_delete.go | 6 +- .../endpointgroup_endpoint_add.go | 6 +- .../endpointgroup_endpoint_delete.go | 6 +- .../endpointgroups/endpointgroup_inspect.go | 6 +- .../endpointgroups/endpointgroup_list.go | 4 +- .../endpointgroups/endpointgroup_update.go | 6 +- api/http/handler/endpointgroups/handler.go | 4 +- api/http/handler/endpointproxy/handler.go | 2 +- api/http/handler/endpointproxy/proxy_azure.go | 7 +- .../handler/endpointproxy/proxy_docker.go | 4 +- .../handler/endpointproxy/proxy_kubernetes.go | 4 +- .../endpoints/endpoint_agent_versions.go | 4 +- .../endpoints/endpoint_association_delete.go | 6 +- api/http/handler/endpoints/endpoint_create.go | 9 +- .../endpoints/endpoint_create_global_key.go | 4 +- api/http/handler/endpoints/endpoint_delete.go | 6 +- .../endpoints/endpoint_dockerhub_status.go | 6 +- .../handler/endpoints/endpoint_inspect.go | 6 +- api/http/handler/endpoints/endpoint_list.go | 6 +- .../endpoints/endpoint_registries_list.go | 6 +- .../endpoints/endpoint_registry_access.go | 6 +- .../endpoints/endpoint_settings_update.go | 6 +- .../handler/endpoints/endpoint_snapshot.go | 6 +- .../handler/endpoints/endpoint_snapshots.go | 4 +- .../endpoints/endpoint_status_inspect.go | 4 +- api/http/handler/endpoints/endpoint_update.go | 6 +- .../endpoints/endpoint_update_relations.go | 9 +- api/http/handler/endpoints/filter.go | 5 +- api/http/handler/endpoints/handler.go | 6 +- .../handler/gitops/git_repo_file_preview.go | 9 +- api/http/handler/gitops/handler.go | 5 +- api/http/handler/helm/handler.go | 5 +- api/http/handler/helm/helm_delete.go | 6 +- api/http/handler/helm/helm_install.go | 9 +- api/http/handler/helm/helm_list.go | 6 +- api/http/handler/helm/helm_repo_search.go | 5 +- api/http/handler/helm/helm_show.go | 4 +- api/http/handler/helm/user_helm_repos.go | 13 +- .../handler/hostmanagement/fdo/configure.go | 6 +- api/http/handler/hostmanagement/fdo/fdo.go | 6 +- .../handler/hostmanagement/fdo/handler.go | 6 +- api/http/handler/hostmanagement/fdo/list.go | 4 +- .../hostmanagement/fdo/profile_create.go | 6 +- .../hostmanagement/fdo/profile_delete.go | 6 +- .../hostmanagement/fdo/profile_duplicate.go | 6 +- .../hostmanagement/fdo/profile_inspect.go | 6 +- .../hostmanagement/fdo/profile_list.go | 4 +- .../hostmanagement/fdo/profile_update.go | 6 +- .../handler/hostmanagement/fdo/register.go | 6 +- .../hostmanagement/openamt/amtactivation.go | 6 +- .../openamt/amtconfiguration.go | 6 +- .../hostmanagement/openamt/amtdevices.go | 6 +- .../handler/hostmanagement/openamt/amtrpc.go | 6 +- .../handler/hostmanagement/openamt/handler.go | 2 +- api/http/handler/kubernetes/config.go | 7 +- .../kubernetes/configmaps_and_secrets.go | 6 +- api/http/handler/kubernetes/handler.go | 10 +- api/http/handler/kubernetes/ingresses.go | 6 +- api/http/handler/kubernetes/metrics.go | 7 +- api/http/handler/kubernetes/namespaces.go | 6 +- api/http/handler/kubernetes/nodes_limits.go | 6 +- api/http/handler/kubernetes/rbac.go | 6 +- api/http/handler/kubernetes/services.go | 6 +- api/http/handler/kubernetes/toggle_system.go | 6 +- api/http/handler/ldap/handler.go | 5 +- api/http/handler/ldap/ldap_check.go | 6 +- api/http/handler/motd/motd.go | 2 +- api/http/handler/registries/handler.go | 7 +- api/http/handler/registries/proxy_gitlab.go | 2 +- .../handler/registries/registry_configure.go | 6 +- .../handler/registries/registry_create.go | 9 +- .../handler/registries/registry_delete.go | 6 +- .../handler/registries/registry_inspect.go | 7 +- api/http/handler/registries/registry_list.go | 4 +- .../handler/registries/registry_update.go | 9 +- api/http/handler/resourcecontrols/handler.go | 5 +- .../resourcecontrol_create.go | 9 +- .../resourcecontrol_delete.go | 6 +- .../resourcecontrol_update.go | 6 +- api/http/handler/roles/handler.go | 5 +- api/http/handler/roles/role_list.go | 4 +- api/http/handler/settings/handler.go | 5 +- api/http/handler/settings/settings_inspect.go | 4 +- api/http/handler/settings/settings_public.go | 4 +- api/http/handler/settings/settings_update.go | 6 +- api/http/handler/ssl/handler.go | 5 +- api/http/handler/ssl/ssl_inspect.go | 4 +- api/http/handler/ssl/ssl_update.go | 6 +- .../handler/stacks/create_compose_stack.go | 4 +- .../handler/stacks/create_kubernetes_stack.go | 12 +- api/http/handler/stacks/create_swarm_stack.go | 10 +- api/http/handler/stacks/handler.go | 9 +- api/http/handler/stacks/stack_associate.go | 6 +- api/http/handler/stacks/stack_create.go | 9 +- api/http/handler/stacks/stack_delete.go | 9 +- api/http/handler/stacks/stack_file.go | 9 +- api/http/handler/stacks/stack_inspect.go | 9 +- api/http/handler/stacks/stack_list.go | 9 +- api/http/handler/stacks/stack_migrate.go | 6 +- api/http/handler/stacks/stack_start.go | 7 +- api/http/handler/stacks/stack_stop.go | 6 +- api/http/handler/stacks/stack_update.go | 6 +- api/http/handler/stacks/stack_update_git.go | 9 +- .../stacks/stack_update_git_redeploy.go | 9 +- .../handler/stacks/update_kubernetes_stack.go | 4 +- api/http/handler/stacks/webhook_invoke.go | 6 +- api/http/handler/system/handler.go | 5 +- api/http/handler/system/nodes_count.go | 5 +- api/http/handler/system/status.go | 5 +- api/http/handler/system/system_info.go | 4 +- api/http/handler/system/system_upgrade.go | 9 +- api/http/handler/system/version.go | 2 +- api/http/handler/tags/handler.go | 4 +- api/http/handler/tags/tag_create.go | 7 +- api/http/handler/tags/tag_delete.go | 6 +- api/http/handler/tags/tag_list.go | 4 +- api/http/handler/teammemberships/handler.go | 2 +- .../teammemberships/teammembership_create.go | 6 +- .../teammemberships/teammembership_delete.go | 6 +- .../teammemberships/teammembership_list.go | 4 +- .../teammemberships/teammembership_update.go | 6 +- api/http/handler/teams/handler.go | 5 +- api/http/handler/teams/team_create.go | 9 +- api/http/handler/teams/team_delete.go | 9 +- api/http/handler/teams/team_inspect.go | 6 +- api/http/handler/teams/team_list.go | 6 +- api/http/handler/teams/team_memberships.go | 6 +- api/http/handler/teams/team_update.go | 6 +- api/http/handler/templates/handler.go | 5 +- api/http/handler/templates/template_file.go | 8 +- api/http/handler/templates/template_list.go | 2 +- api/http/handler/upload/handler.go | 6 +- api/http/handler/upload/upload_tls.go | 6 +- api/http/handler/users/admin_check.go | 7 +- api/http/handler/users/admin_init.go | 9 +- api/http/handler/users/handler.go | 6 +- api/http/handler/users/user_create.go | 9 +- .../handler/users/user_create_access_token.go | 9 +- api/http/handler/users/user_delete.go | 6 +- .../handler/users/user_get_access_tokens.go | 6 +- api/http/handler/users/user_inspect.go | 6 +- api/http/handler/users/user_list.go | 6 +- api/http/handler/users/user_memberships.go | 6 +- .../handler/users/user_remove_access_token.go | 6 +- api/http/handler/users/user_update.go | 6 +- .../handler/users/user_update_password.go | 6 +- api/http/handler/webhooks/handler.go | 2 +- api/http/handler/webhooks/webhook_create.go | 9 +- api/http/handler/webhooks/webhook_delete.go | 9 +- api/http/handler/webhooks/webhook_execute.go | 8 +- api/http/handler/webhooks/webhook_list.go | 9 +- api/http/handler/webhooks/webhook_update.go | 9 +- api/http/handler/websocket/attach.go | 4 +- api/http/handler/websocket/exec.go | 4 +- api/http/handler/websocket/handler.go | 7 +- api/http/handler/websocket/pod.go | 4 +- api/http/handler/websocket/shell_pod.go | 4 +- api/http/middlewares/demo.go | 5 +- api/http/middlewares/endpoint.go | 8 +- api/http/middlewares/featureflag.go | 5 +- api/http/middlewares/withitem.go | 7 +- api/http/offlinegate/offlinegate.go | 2 +- api/http/proxy/factory/docker.go | 2 +- api/http/security/bouncer.go | 2 +- api/http/security/rate_limiter.go | 5 +- api/stacks/deployments/autoupdate.go | 2 +- .../compose_file_content_builder.go | 2 +- .../compose_file_upload_builder.go | 2 +- .../stackbuilders/compose_git_builder.go | 2 +- api/stacks/stackbuilders/director.go | 4 +- .../stackbuilders/k8s_file_content_builder.go | 2 +- api/stacks/stackbuilders/k8s_git_builder.go | 2 +- api/stacks/stackbuilders/k8s_url_builder.go | 2 +- api/stacks/stackbuilders/stack_builder.go | 2 +- .../stack_file_content_builder.go | 2 +- .../stack_file_upload_builder.go | 2 +- api/stacks/stackbuilders/stack_git_builder.go | 2 +- api/stacks/stackbuilders/stack_url_builder.go | 2 +- .../swarm_file_content_builder.go | 2 +- .../swarm_file_upload_builder.go | 2 +- api/stacks/stackbuilders/swarm_git_builder.go | 2 +- go.mod | 1 - go.sum | 2 - pkg/libhttp/LICENSE | 17 ++ pkg/libhttp/README.md | 5 + pkg/libhttp/error/error.go | 46 ++++++ pkg/libhttp/error/status.go | 42 +++++ pkg/libhttp/request/payload.go | 37 +++++ pkg/libhttp/request/payload_test.go | 43 +++++ pkg/libhttp/request/request.go | 152 ++++++++++++++++++ pkg/libhttp/response/response.go | 45 ++++++ 249 files changed, 1059 insertions(+), 639 deletions(-) create mode 100644 pkg/libhttp/LICENSE create mode 100644 pkg/libhttp/README.md create mode 100644 pkg/libhttp/error/error.go create mode 100644 pkg/libhttp/error/status.go create mode 100644 pkg/libhttp/request/payload.go create mode 100644 pkg/libhttp/request/payload_test.go create mode 100644 pkg/libhttp/request/request.go create mode 100644 pkg/libhttp/response/response.go diff --git a/api/.golangci.yaml b/api/.golangci.yaml index 64a1ef9bf..7ceb659d9 100644 --- a/api/.golangci.yaml +++ b/api/.golangci.yaml @@ -15,6 +15,8 @@ linters-settings: packages: - github.com/sirupsen/logrus - golang.org/x/exp + - github.com/portainer/libcrypto + - github.com/portainer/libhttp packages-with-error-message: - github.com/sirupsen/logrus: 'logging is allowed only by github.com/rs/zerolog' ignore-file-rules: diff --git a/api/adminmonitor/admin_monitor.go b/api/adminmonitor/admin_monitor.go index 3aa3711be..2162e1cad 100644 --- a/api/adminmonitor/admin_monitor.go +++ b/api/adminmonitor/admin_monitor.go @@ -7,9 +7,9 @@ import ( "sync" "time" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/rs/zerolog/log" ) diff --git a/api/http/errors/tx.go b/api/http/errors/tx.go index 037cb95d0..1db484247 100644 --- a/api/http/errors/tx.go +++ b/api/http/errors/tx.go @@ -3,7 +3,7 @@ package errors import ( "errors" - httperror "github.com/portainer/libhttp/error" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) func TxResponse(err error, validResponse func() *httperror.HandlerError) *httperror.HandlerError { diff --git a/api/http/handler/auth/authenticate.go b/api/http/handler/auth/authenticate.go index 3a5cacb04..87d075d49 100644 --- a/api/http/handler/auth/authenticate.go +++ b/api/http/handler/auth/authenticate.go @@ -4,12 +4,12 @@ import ( "net/http" "strings" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/internal/authorization" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/asaskevich/govalidator" "github.com/pkg/errors" diff --git a/api/http/handler/auth/authenticate_oauth.go b/api/http/handler/auth/authenticate_oauth.go index 7122e0021..58f18dd0e 100644 --- a/api/http/handler/auth/authenticate_oauth.go +++ b/api/http/handler/auth/authenticate_oauth.go @@ -4,10 +4,10 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" "github.com/rs/zerolog/log" diff --git a/api/http/handler/auth/handler.go b/api/http/handler/auth/handler.go index 60c3fc259..877b55ad9 100644 --- a/api/http/handler/auth/handler.go +++ b/api/http/handler/auth/handler.go @@ -3,12 +3,12 @@ package auth import ( "net/http" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/proxy" "github.com/portainer/portainer/api/http/proxy/factory/kubernetes" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/gorilla/mux" ) diff --git a/api/http/handler/auth/logout.go b/api/http/handler/auth/logout.go index afadc05c0..95508b1ed 100644 --- a/api/http/handler/auth/logout.go +++ b/api/http/handler/auth/logout.go @@ -3,9 +3,9 @@ package auth import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id Logout diff --git a/api/http/handler/backup/backup.go b/api/http/handler/backup/backup.go index 49d5aac9c..108c94096 100644 --- a/api/http/handler/backup/backup.go +++ b/api/http/handler/backup/backup.go @@ -6,9 +6,9 @@ import ( "os" "path/filepath" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" operations "github.com/portainer/portainer/api/backup" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" ) type ( diff --git a/api/http/handler/backup/handler.go b/api/http/handler/backup/handler.go index 102427342..1ed95eafa 100644 --- a/api/http/handler/backup/handler.go +++ b/api/http/handler/backup/handler.go @@ -4,13 +4,13 @@ import ( "context" "net/http" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/adminmonitor" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/demo" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/api/http/offlinegate" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/gorilla/mux" ) diff --git a/api/http/handler/backup/restore.go b/api/http/handler/backup/restore.go index 7728ba4ce..bbb70f9b0 100644 --- a/api/http/handler/backup/restore.go +++ b/api/http/handler/backup/restore.go @@ -6,9 +6,9 @@ import ( "net/http" "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" operations "github.com/portainer/portainer/api/backup" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" ) type restorePayload struct { diff --git a/api/http/handler/customtemplates/customtemplate_create.go b/api/http/handler/customtemplates/customtemplate_create.go index 7a7cfde1d..b22f9ba27 100644 --- a/api/http/handler/customtemplates/customtemplate_create.go +++ b/api/http/handler/customtemplates/customtemplate_create.go @@ -8,16 +8,17 @@ import ( "regexp" "strconv" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/filesystem" gittypes "github.com/portainer/portainer/api/git/types" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/authorization" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/asaskevich/govalidator" "github.com/rs/zerolog/log" ) diff --git a/api/http/handler/customtemplates/customtemplate_delete.go b/api/http/handler/customtemplates/customtemplate_delete.go index 6b19d20ee..c047c72dc 100644 --- a/api/http/handler/customtemplates/customtemplate_delete.go +++ b/api/http/handler/customtemplates/customtemplate_delete.go @@ -4,12 +4,13 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + 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" ) diff --git a/api/http/handler/customtemplates/customtemplate_file.go b/api/http/handler/customtemplates/customtemplate_file.go index b82c3c96e..317170689 100644 --- a/api/http/handler/customtemplates/customtemplate_file.go +++ b/api/http/handler/customtemplates/customtemplate_file.go @@ -3,10 +3,10 @@ package customtemplates import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type fileResponse struct { diff --git a/api/http/handler/customtemplates/customtemplate_git_fetch.go b/api/http/handler/customtemplates/customtemplate_git_fetch.go index 3913d91df..64132e56e 100644 --- a/api/http/handler/customtemplates/customtemplate_git_fetch.go +++ b/api/http/handler/customtemplates/customtemplate_git_fetch.go @@ -6,11 +6,11 @@ import ( "os" "sync" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/stacks/stackutils" + 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" ) diff --git a/api/http/handler/customtemplates/customtemplate_inspect.go b/api/http/handler/customtemplates/customtemplate_inspect.go index a22ba4b63..1aa0ffa7b 100644 --- a/api/http/handler/customtemplates/customtemplate_inspect.go +++ b/api/http/handler/customtemplates/customtemplate_inspect.go @@ -4,12 +4,12 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id CustomTemplateInspect diff --git a/api/http/handler/customtemplates/customtemplate_list.go b/api/http/handler/customtemplates/customtemplate_list.go index 8d1a2a762..b9150a5c2 100644 --- a/api/http/handler/customtemplates/customtemplate_list.go +++ b/api/http/handler/customtemplates/customtemplate_list.go @@ -5,11 +5,11 @@ import ( "strconv" "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/authorization" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id CustomTemplateList diff --git a/api/http/handler/customtemplates/customtemplate_update.go b/api/http/handler/customtemplates/customtemplate_update.go index b8eeacd78..221bafa7c 100644 --- a/api/http/handler/customtemplates/customtemplate_update.go +++ b/api/http/handler/customtemplates/customtemplate_update.go @@ -6,15 +6,15 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/git" gittypes "github.com/portainer/portainer/api/git/types" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/asaskevich/govalidator" ) diff --git a/api/http/handler/customtemplates/handler.go b/api/http/handler/customtemplates/handler.go index 875f4110d..0da63d81f 100644 --- a/api/http/handler/customtemplates/handler.go +++ b/api/http/handler/customtemplates/handler.go @@ -5,10 +5,10 @@ import ( "sync" "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) // Handler is the HTTP handler used to handle environment(endpoint) group operations. diff --git a/api/http/handler/docker/containers/container_gpus_inspect.go b/api/http/handler/docker/containers/container_gpus_inspect.go index 2623a0fa4..504322025 100644 --- a/api/http/handler/docker/containers/container_gpus_inspect.go +++ b/api/http/handler/docker/containers/container_gpus_inspect.go @@ -4,13 +4,14 @@ import ( "net/http" "strings" - containertypes "github.com/docker/docker/api/types/container" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/api/internal/slices" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + containertypes "github.com/docker/docker/api/types/container" ) type containerGpusResponse struct { diff --git a/api/http/handler/docker/containers/handler.go b/api/http/handler/docker/containers/handler.go index 21019e3bb..c2bb79350 100644 --- a/api/http/handler/docker/containers/handler.go +++ b/api/http/handler/docker/containers/handler.go @@ -4,11 +4,11 @@ import ( "net/http" "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/docker" dockerclient "github.com/portainer/portainer/api/docker/client" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type Handler struct { diff --git a/api/http/handler/docker/containers/recreate.go b/api/http/handler/docker/containers/recreate.go index 313192d63..17bfd9523 100644 --- a/api/http/handler/docker/containers/recreate.go +++ b/api/http/handler/docker/containers/recreate.go @@ -3,14 +3,14 @@ package containers import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/docker/consts" "github.com/portainer/portainer/api/docker/images" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/api/internal/authorization" + 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" ) diff --git a/api/http/handler/docker/handler.go b/api/http/handler/docker/handler.go index b0b520bb2..3ea61ce12 100644 --- a/api/http/handler/docker/handler.go +++ b/api/http/handler/docker/handler.go @@ -4,17 +4,17 @@ import ( "errors" "net/http" + "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/docker" dockerclient "github.com/portainer/portainer/api/docker/client" - "github.com/portainer/portainer/api/internal/endpointutils" - - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/handler/docker/containers" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/authorization" + "github.com/portainer/portainer/api/internal/endpointutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler which will natively deal with to external environments(endpoints). diff --git a/api/http/handler/edgegroups/edgegroup_create.go b/api/http/handler/edgegroups/edgegroup_create.go index 989599eba..28443883b 100644 --- a/api/http/handler/edgegroups/edgegroup_create.go +++ b/api/http/handler/edgegroups/edgegroup_create.go @@ -4,11 +4,11 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/endpointutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" ) diff --git a/api/http/handler/edgegroups/edgegroup_delete.go b/api/http/handler/edgegroups/edgegroup_delete.go index 061594af3..074be2bf7 100644 --- a/api/http/handler/edgegroups/edgegroup_delete.go +++ b/api/http/handler/edgegroups/edgegroup_delete.go @@ -4,12 +4,12 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EdgeGroupDelete diff --git a/api/http/handler/edgegroups/edgegroup_inspect.go b/api/http/handler/edgegroups/edgegroup_inspect.go index d062a932a..533b46a3f 100644 --- a/api/http/handler/edgegroups/edgegroup_inspect.go +++ b/api/http/handler/edgegroups/edgegroup_inspect.go @@ -3,11 +3,11 @@ package edgegroups import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" ) // @id EdgeGroupInspect diff --git a/api/http/handler/edgegroups/edgegroup_list.go b/api/http/handler/edgegroups/edgegroup_list.go index 1fea62c4b..a69b58121 100644 --- a/api/http/handler/edgegroups/edgegroup_list.go +++ b/api/http/handler/edgegroups/edgegroup_list.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/slices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type decoratedEdgeGroup struct { diff --git a/api/http/handler/edgegroups/edgegroup_update.go b/api/http/handler/edgegroups/edgegroup_update.go index b3cd4aabd..02756268f 100644 --- a/api/http/handler/edgegroups/edgegroup_update.go +++ b/api/http/handler/edgegroups/edgegroup_update.go @@ -4,14 +4,14 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/api/internal/endpointutils" "github.com/portainer/portainer/api/internal/slices" "github.com/portainer/portainer/api/internal/unique" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" ) diff --git a/api/http/handler/edgegroups/handler.go b/api/http/handler/edgegroups/handler.go index 806efb81a..77075c772 100644 --- a/api/http/handler/edgegroups/handler.go +++ b/api/http/handler/edgegroups/handler.go @@ -4,11 +4,11 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/gorilla/mux" ) diff --git a/api/http/handler/edgejobs/edgejob_create.go b/api/http/handler/edgejobs/edgejob_create.go index 2d94aab0d..c8d80ccf1 100644 --- a/api/http/handler/edgejobs/edgejob_create.go +++ b/api/http/handler/edgejobs/edgejob_create.go @@ -7,14 +7,14 @@ import ( "strings" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/api/internal/endpointutils" "github.com/portainer/portainer/api/internal/maps" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" ) diff --git a/api/http/handler/edgejobs/edgejob_delete.go b/api/http/handler/edgejobs/edgejob_delete.go index b1878e56c..8f47a6977 100644 --- a/api/http/handler/edgejobs/edgejob_delete.go +++ b/api/http/handler/edgejobs/edgejob_delete.go @@ -5,14 +5,14 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/api/internal/maps" "github.com/portainer/portainer/pkg/featureflags" + 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" ) diff --git a/api/http/handler/edgejobs/edgejob_file.go b/api/http/handler/edgejobs/edgejob_file.go index 0cc8fb141..f8924204b 100644 --- a/api/http/handler/edgejobs/edgejob_file.go +++ b/api/http/handler/edgejobs/edgejob_file.go @@ -3,10 +3,10 @@ package edgejobs import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type edgeJobFileResponse struct { diff --git a/api/http/handler/edgejobs/edgejob_inspect.go b/api/http/handler/edgejobs/edgejob_inspect.go index 52a82ebf5..2407b2b4f 100644 --- a/api/http/handler/edgejobs/edgejob_inspect.go +++ b/api/http/handler/edgejobs/edgejob_inspect.go @@ -3,10 +3,10 @@ package edgejobs import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type edgeJobInspectResponse struct { diff --git a/api/http/handler/edgejobs/edgejob_list.go b/api/http/handler/edgejobs/edgejob_list.go index f54b8d091..f28c58fef 100644 --- a/api/http/handler/edgejobs/edgejob_list.go +++ b/api/http/handler/edgejobs/edgejob_list.go @@ -3,8 +3,8 @@ package edgejobs 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" ) // @id EdgeJobList diff --git a/api/http/handler/edgejobs/edgejob_tasklogs_clear.go b/api/http/handler/edgejobs/edgejob_tasklogs_clear.go index e54c59029..0e137e576 100644 --- a/api/http/handler/edgejobs/edgejob_tasklogs_clear.go +++ b/api/http/handler/edgejobs/edgejob_tasklogs_clear.go @@ -5,14 +5,14 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/api/internal/slices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EdgeJobTasksClear diff --git a/api/http/handler/edgejobs/edgejob_tasklogs_collect.go b/api/http/handler/edgejobs/edgejob_tasklogs_collect.go index d3767784d..dfb10e350 100644 --- a/api/http/handler/edgejobs/edgejob_tasklogs_collect.go +++ b/api/http/handler/edgejobs/edgejob_tasklogs_collect.go @@ -4,13 +4,13 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/api/internal/slices" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EdgeJobTasksCollect diff --git a/api/http/handler/edgejobs/edgejob_tasklogs_inspect.go b/api/http/handler/edgejobs/edgejob_tasklogs_inspect.go index 4f45f39c2..1a91fb994 100644 --- a/api/http/handler/edgejobs/edgejob_tasklogs_inspect.go +++ b/api/http/handler/edgejobs/edgejob_tasklogs_inspect.go @@ -4,9 +4,9 @@ import ( "net/http" "strconv" - 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 fileResponse struct { diff --git a/api/http/handler/edgejobs/edgejob_tasks_list.go b/api/http/handler/edgejobs/edgejob_tasks_list.go index f7099eeca..c7ba5eafb 100644 --- a/api/http/handler/edgejobs/edgejob_tasks_list.go +++ b/api/http/handler/edgejobs/edgejob_tasks_list.go @@ -4,13 +4,13 @@ import ( "fmt" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/api/internal/maps" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" ) type taskContainer struct { diff --git a/api/http/handler/edgejobs/edgejob_update.go b/api/http/handler/edgejobs/edgejob_update.go index 5cf92aa03..537f77ae7 100644 --- a/api/http/handler/edgejobs/edgejob_update.go +++ b/api/http/handler/edgejobs/edgejob_update.go @@ -5,8 +5,6 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge" @@ -14,6 +12,8 @@ import ( "github.com/portainer/portainer/api/internal/maps" "github.com/portainer/portainer/api/internal/slices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" ) diff --git a/api/http/handler/edgejobs/handler.go b/api/http/handler/edgejobs/handler.go index 9e45c6755..ab3d66b3b 100644 --- a/api/http/handler/edgejobs/handler.go +++ b/api/http/handler/edgejobs/handler.go @@ -4,11 +4,11 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/gorilla/mux" ) diff --git a/api/http/handler/edgestacks/edgestack_create.go b/api/http/handler/edgestacks/edgestack_create.go index 997234eb9..c0512dca5 100644 --- a/api/http/handler/edgestacks/edgestack_create.go +++ b/api/http/handler/edgestacks/edgestack_create.go @@ -3,14 +3,14 @@ package edgestacks import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) func (handler *Handler) edgeStackCreate(w http.ResponseWriter, r *http.Request) *httperror.HandlerError { diff --git a/api/http/handler/edgestacks/edgestack_create_file.go b/api/http/handler/edgestacks/edgestack_create_file.go index f6853e3c6..93e1b1ea6 100644 --- a/api/http/handler/edgestacks/edgestack_create_file.go +++ b/api/http/handler/edgestacks/edgestack_create_file.go @@ -3,10 +3,10 @@ package edgestacks import ( "net/http" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" httperrors "github.com/portainer/portainer/api/http/errors" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/pkg/errors" ) diff --git a/api/http/handler/edgestacks/edgestack_create_git.go b/api/http/handler/edgestacks/edgestack_create_git.go index 43373a117..2acdcc98c 100644 --- a/api/http/handler/edgestacks/edgestack_create_git.go +++ b/api/http/handler/edgestacks/edgestack_create_git.go @@ -4,12 +4,12 @@ import ( "fmt" "net/http" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" gittypes "github.com/portainer/portainer/api/git/types" httperrors "github.com/portainer/portainer/api/http/errors" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" "github.com/pkg/errors" diff --git a/api/http/handler/edgestacks/edgestack_create_string.go b/api/http/handler/edgestacks/edgestack_create_string.go index 45ee1240e..eb008c228 100644 --- a/api/http/handler/edgestacks/edgestack_create_string.go +++ b/api/http/handler/edgestacks/edgestack_create_string.go @@ -4,11 +4,11 @@ import ( "fmt" "net/http" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" httperrors "github.com/portainer/portainer/api/http/errors" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" "github.com/pkg/errors" diff --git a/api/http/handler/edgestacks/edgestack_delete.go b/api/http/handler/edgestacks/edgestack_delete.go index 11ce4216e..68de13140 100644 --- a/api/http/handler/edgestacks/edgestack_delete.go +++ b/api/http/handler/edgestacks/edgestack_delete.go @@ -4,12 +4,12 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EdgeStackDelete diff --git a/api/http/handler/edgestacks/edgestack_file.go b/api/http/handler/edgestacks/edgestack_file.go index 5640020db..3eb6e77e1 100644 --- a/api/http/handler/edgestacks/edgestack_file.go +++ b/api/http/handler/edgestacks/edgestack_file.go @@ -3,10 +3,10 @@ package edgestacks import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type stackFileResponse struct { diff --git a/api/http/handler/edgestacks/edgestack_inspect.go b/api/http/handler/edgestacks/edgestack_inspect.go index 5ca058cb4..a19b70a0e 100644 --- a/api/http/handler/edgestacks/edgestack_inspect.go +++ b/api/http/handler/edgestacks/edgestack_inspect.go @@ -3,10 +3,10 @@ package edgestacks import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EdgeStackInspect diff --git a/api/http/handler/edgestacks/edgestack_list.go b/api/http/handler/edgestacks/edgestack_list.go index 3c9d87b40..26fd7da05 100644 --- a/api/http/handler/edgestacks/edgestack_list.go +++ b/api/http/handler/edgestacks/edgestack_list.go @@ -3,8 +3,8 @@ package edgestacks 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" ) // @id EdgeStackList diff --git a/api/http/handler/edgestacks/edgestack_status_delete.go b/api/http/handler/edgestacks/edgestack_status_delete.go index d9fb9f952..fe09db311 100644 --- a/api/http/handler/edgestacks/edgestack_status_delete.go +++ b/api/http/handler/edgestacks/edgestack_status_delete.go @@ -5,13 +5,13 @@ import ( "net/http" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EdgeStackStatusDelete diff --git a/api/http/handler/edgestacks/edgestack_status_update.go b/api/http/handler/edgestacks/edgestack_status_update.go index 98d070c6f..f8d3103ca 100644 --- a/api/http/handler/edgestacks/edgestack_status_update.go +++ b/api/http/handler/edgestacks/edgestack_status_update.go @@ -5,15 +5,15 @@ import ( "net/http" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" - "github.com/rs/zerolog/log" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/asaskevich/govalidator" + "github.com/rs/zerolog/log" ) type updateStatusPayload struct { diff --git a/api/http/handler/edgestacks/edgestack_update.go b/api/http/handler/edgestacks/edgestack_update.go index e9488ac4a..afb510caa 100644 --- a/api/http/handler/edgestacks/edgestack_update.go +++ b/api/http/handler/edgestacks/edgestack_update.go @@ -4,15 +4,16 @@ import ( "net/http" "time" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/api/internal/set" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) type updateEdgeStackPayload struct { diff --git a/api/http/handler/edgestacks/handler.go b/api/http/handler/edgestacks/handler.go index 8d7810072..3ca757ce8 100644 --- a/api/http/handler/edgestacks/handler.go +++ b/api/http/handler/edgestacks/handler.go @@ -4,14 +4,15 @@ import ( "fmt" "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/api/http/security" edgestackservice "github.com/portainer/portainer/api/internal/edge/edgestacks" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle environment(endpoint) group operations. diff --git a/api/http/handler/edgetemplates/edgetemplate_list.go b/api/http/handler/edgetemplates/edgetemplate_list.go index b36c2a231..70f6b585c 100644 --- a/api/http/handler/edgetemplates/edgetemplate_list.go +++ b/api/http/handler/edgetemplates/edgetemplate_list.go @@ -4,10 +4,10 @@ import ( "encoding/json" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/client" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) type templateFileFormat struct { diff --git a/api/http/handler/edgetemplates/handler.go b/api/http/handler/edgetemplates/handler.go index fe37124ba..bf08aa400 100644 --- a/api/http/handler/edgetemplates/handler.go +++ b/api/http/handler/edgetemplates/handler.go @@ -3,11 +3,11 @@ package edgetemplates import ( "net/http" - httperror "github.com/portainer/libhttp/error" - - "github.com/gorilla/mux" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle edge environment(endpoint) operations. diff --git a/api/http/handler/endpointedge/endpointedge_job_logs.go b/api/http/handler/endpointedge/endpointedge_job_logs.go index 0a9d758f9..50389d96f 100644 --- a/api/http/handler/endpointedge/endpointedge_job_logs.go +++ b/api/http/handler/endpointedge/endpointedge_job_logs.go @@ -5,13 +5,13 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type logsPayload struct { diff --git a/api/http/handler/endpointedge/endpointedge_stack_inspect.go b/api/http/handler/endpointedge/endpointedge_stack_inspect.go index 3ee13d02d..fc9f208b0 100644 --- a/api/http/handler/endpointedge/endpointedge_stack_inspect.go +++ b/api/http/handler/endpointedge/endpointedge_stack_inspect.go @@ -2,17 +2,17 @@ package endpointedge import ( "errors" + "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/edge" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/api/internal/endpointutils" "github.com/portainer/portainer/api/kubernetes" - "net/http" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @summary Inspect an Edge Stack for an Environment(Endpoint) diff --git a/api/http/handler/endpointedge/endpointedge_status_inspect.go b/api/http/handler/endpointedge/endpointedge_status_inspect.go index 54c126d58..fc372c360 100644 --- a/api/http/handler/endpointedge/endpointedge_status_inspect.go +++ b/api/http/handler/endpointedge/endpointedge_status_inspect.go @@ -13,13 +13,13 @@ import ( "strings" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge/cache" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type stackStatusResponse struct { diff --git a/api/http/handler/endpointedge/handler.go b/api/http/handler/endpointedge/handler.go index 8676ccda1..626217cd3 100644 --- a/api/http/handler/endpointedge/handler.go +++ b/api/http/handler/endpointedge/handler.go @@ -3,11 +3,11 @@ package endpointedge import ( "net/http" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/gorilla/mux" ) diff --git a/api/http/handler/endpointgroups/endpointgroup_create.go b/api/http/handler/endpointgroups/endpointgroup_create.go index 8cbcc4de9..4f3eec5bb 100644 --- a/api/http/handler/endpointgroups/endpointgroup_create.go +++ b/api/http/handler/endpointgroups/endpointgroup_create.go @@ -4,12 +4,12 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/asaskevich/govalidator" ) diff --git a/api/http/handler/endpointgroups/endpointgroup_delete.go b/api/http/handler/endpointgroups/endpointgroup_delete.go index aa670e141..b33a142f7 100644 --- a/api/http/handler/endpointgroups/endpointgroup_delete.go +++ b/api/http/handler/endpointgroups/endpointgroup_delete.go @@ -4,12 +4,12 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EndpointGroupDelete diff --git a/api/http/handler/endpointgroups/endpointgroup_endpoint_add.go b/api/http/handler/endpointgroups/endpointgroup_endpoint_add.go index f682c5b70..61588a93f 100644 --- a/api/http/handler/endpointgroups/endpointgroup_endpoint_add.go +++ b/api/http/handler/endpointgroups/endpointgroup_endpoint_add.go @@ -4,12 +4,12 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EndpointGroupAddEndpoint diff --git a/api/http/handler/endpointgroups/endpointgroup_endpoint_delete.go b/api/http/handler/endpointgroups/endpointgroup_endpoint_delete.go index db7891b93..f277df70d 100644 --- a/api/http/handler/endpointgroups/endpointgroup_endpoint_delete.go +++ b/api/http/handler/endpointgroups/endpointgroup_endpoint_delete.go @@ -4,12 +4,12 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EndpointGroupDeleteEndpoint diff --git a/api/http/handler/endpointgroups/endpointgroup_inspect.go b/api/http/handler/endpointgroups/endpointgroup_inspect.go index 169473a1a..fd7356ff4 100644 --- a/api/http/handler/endpointgroups/endpointgroup_inspect.go +++ b/api/http/handler/endpointgroups/endpointgroup_inspect.go @@ -3,10 +3,10 @@ package endpointgroups import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @summary Inspect an Environment(Endpoint) group diff --git a/api/http/handler/endpointgroups/endpointgroup_list.go b/api/http/handler/endpointgroups/endpointgroup_list.go index fd15089f6..1b2ed5170 100644 --- a/api/http/handler/endpointgroups/endpointgroup_list.go +++ b/api/http/handler/endpointgroups/endpointgroup_list.go @@ -3,9 +3,9 @@ package endpointgroups import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EndpointGroupList diff --git a/api/http/handler/endpointgroups/endpointgroup_update.go b/api/http/handler/endpointgroups/endpointgroup_update.go index f3c3993a7..a422b398a 100644 --- a/api/http/handler/endpointgroups/endpointgroup_update.go +++ b/api/http/handler/endpointgroups/endpointgroup_update.go @@ -5,13 +5,13 @@ import ( "net/http" "reflect" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/tag" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type endpointGroupUpdatePayload struct { diff --git a/api/http/handler/endpointgroups/handler.go b/api/http/handler/endpointgroups/handler.go index 90f7a3278..e3284c457 100644 --- a/api/http/handler/endpointgroups/handler.go +++ b/api/http/handler/endpointgroups/handler.go @@ -4,11 +4,11 @@ import ( "net/http" "github.com/portainer/portainer/api/dataservices" + "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/authorization" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/portainer/api/http/security" ) // Handler is the HTTP handler used to handle environment(endpoint) group operations. diff --git a/api/http/handler/endpointproxy/handler.go b/api/http/handler/endpointproxy/handler.go index 90ec22b55..93271bc4d 100644 --- a/api/http/handler/endpointproxy/handler.go +++ b/api/http/handler/endpointproxy/handler.go @@ -2,11 +2,11 @@ package endpointproxy import ( "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/proxy" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) // Handler is the HTTP handler used to proxy requests to external APIs. diff --git a/api/http/handler/endpointproxy/proxy_azure.go b/api/http/handler/endpointproxy/proxy_azure.go index 23e1b8c91..b468c5034 100644 --- a/api/http/handler/endpointproxy/proxy_azure.go +++ b/api/http/handler/endpointproxy/proxy_azure.go @@ -1,13 +1,12 @@ package endpointproxy import ( + "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" - - "net/http" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" ) func (handler *Handler) proxyRequestsToAzureAPI(w http.ResponseWriter, r *http.Request) *httperror.HandlerError { diff --git a/api/http/handler/endpointproxy/proxy_docker.go b/api/http/handler/endpointproxy/proxy_docker.go index 9a3c698b6..db603880d 100644 --- a/api/http/handler/endpointproxy/proxy_docker.go +++ b/api/http/handler/endpointproxy/proxy_docker.go @@ -6,9 +6,9 @@ import ( "strconv" "strings" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" ) func (handler *Handler) proxyRequestsToDockerAPI(w http.ResponseWriter, r *http.Request) *httperror.HandlerError { diff --git a/api/http/handler/endpointproxy/proxy_kubernetes.go b/api/http/handler/endpointproxy/proxy_kubernetes.go index 73d39ac21..80643d94b 100644 --- a/api/http/handler/endpointproxy/proxy_kubernetes.go +++ b/api/http/handler/endpointproxy/proxy_kubernetes.go @@ -6,9 +6,9 @@ import ( "net/http" "strings" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" ) func (handler *Handler) proxyRequestsToKubernetesAPI(w http.ResponseWriter, r *http.Request) *httperror.HandlerError { diff --git a/api/http/handler/endpoints/endpoint_agent_versions.go b/api/http/handler/endpoints/endpoint_agent_versions.go index 71f9d98eb..00e83c640 100644 --- a/api/http/handler/endpoints/endpoint_agent_versions.go +++ b/api/http/handler/endpoints/endpoint_agent_versions.go @@ -3,10 +3,10 @@ package endpoints import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/set" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id AgentVersions diff --git a/api/http/handler/endpoints/endpoint_association_delete.go b/api/http/handler/endpoints/endpoint_association_delete.go index 06140b244..2fd889102 100644 --- a/api/http/handler/endpoints/endpoint_association_delete.go +++ b/api/http/handler/endpoints/endpoint_association_delete.go @@ -8,10 +8,10 @@ import ( "regexp" "strings" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EndpointAssociationDelete diff --git a/api/http/handler/endpoints/endpoint_create.go b/api/http/handler/endpoints/endpoint_create.go index 25d6d4da0..b2acded9a 100644 --- a/api/http/handler/endpoints/endpoint_create.go +++ b/api/http/handler/endpoints/endpoint_create.go @@ -8,10 +8,6 @@ import ( "strconv" "strings" - "github.com/gofrs/uuid" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/agent" "github.com/portainer/portainer/api/crypto" @@ -19,6 +15,11 @@ import ( "github.com/portainer/portainer/api/http/client" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/api/internal/endpointutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/gofrs/uuid" ) type endpointCreatePayload struct { diff --git a/api/http/handler/endpoints/endpoint_create_global_key.go b/api/http/handler/endpoints/endpoint_create_global_key.go index f09d276bd..559349313 100644 --- a/api/http/handler/endpoints/endpoint_create_global_key.go +++ b/api/http/handler/endpoints/endpoint_create_global_key.go @@ -4,9 +4,9 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) type endpointCreateGlobalKeyResponse struct { diff --git a/api/http/handler/endpoints/endpoint_delete.go b/api/http/handler/endpoints/endpoint_delete.go index 2e8c3118d..2cd0b17ae 100644 --- a/api/http/handler/endpoints/endpoint_delete.go +++ b/api/http/handler/endpoints/endpoint_delete.go @@ -5,14 +5,14 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/internal/endpointutils" "github.com/portainer/portainer/pkg/featureflags" + 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" ) diff --git a/api/http/handler/endpoints/endpoint_dockerhub_status.go b/api/http/handler/endpoints/endpoint_dockerhub_status.go index ab3972c25..cb4f8a6aa 100644 --- a/api/http/handler/endpoints/endpoint_dockerhub_status.go +++ b/api/http/handler/endpoints/endpoint_dockerhub_status.go @@ -9,12 +9,12 @@ import ( "strconv" "strings" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/client" "github.com/portainer/portainer/api/internal/endpointutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type dockerhubStatusResponse struct { diff --git a/api/http/handler/endpoints/endpoint_inspect.go b/api/http/handler/endpoints/endpoint_inspect.go index 8a495de2f..919a1788e 100644 --- a/api/http/handler/endpoints/endpoint_inspect.go +++ b/api/http/handler/endpoints/endpoint_inspect.go @@ -3,11 +3,11 @@ package endpoints import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/internal/endpointutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EndpointInspect diff --git a/api/http/handler/endpoints/endpoint_list.go b/api/http/handler/endpoints/endpoint_list.go index eba9a4c23..3f75b3aff 100644 --- a/api/http/handler/endpoints/endpoint_list.go +++ b/api/http/handler/endpoints/endpoint_list.go @@ -5,12 +5,12 @@ import ( "sort" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/endpointutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) const ( diff --git a/api/http/handler/endpoints/endpoint_registries_list.go b/api/http/handler/endpoints/endpoint_registries_list.go index e0ef82275..86140a81f 100644 --- a/api/http/handler/endpoints/endpoint_registries_list.go +++ b/api/http/handler/endpoints/endpoint_registries_list.go @@ -3,14 +3,14 @@ package endpoints import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/endpointutils" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/pkg/errors" ) diff --git a/api/http/handler/endpoints/endpoint_registry_access.go b/api/http/handler/endpoints/endpoint_registry_access.go index e6924d745..cd049caa2 100644 --- a/api/http/handler/endpoints/endpoint_registry_access.go +++ b/api/http/handler/endpoints/endpoint_registry_access.go @@ -4,13 +4,13 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type registryAccessPayload struct { diff --git a/api/http/handler/endpoints/endpoint_settings_update.go b/api/http/handler/endpoints/endpoint_settings_update.go index 34a9abf6a..91b668b0f 100644 --- a/api/http/handler/endpoints/endpoint_settings_update.go +++ b/api/http/handler/endpoints/endpoint_settings_update.go @@ -3,10 +3,10 @@ package endpoints import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type endpointSettingsUpdatePayload struct { diff --git a/api/http/handler/endpoints/endpoint_snapshot.go b/api/http/handler/endpoints/endpoint_snapshot.go index fa44a43e5..bf641f764 100644 --- a/api/http/handler/endpoints/endpoint_snapshot.go +++ b/api/http/handler/endpoints/endpoint_snapshot.go @@ -4,11 +4,11 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/internal/snapshot" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id EndpointSnapshot diff --git a/api/http/handler/endpoints/endpoint_snapshots.go b/api/http/handler/endpoints/endpoint_snapshots.go index a187fdbe2..0e6d4b188 100644 --- a/api/http/handler/endpoints/endpoint_snapshots.go +++ b/api/http/handler/endpoints/endpoint_snapshots.go @@ -3,10 +3,10 @@ package endpoints import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/internal/snapshot" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/rs/zerolog/log" ) diff --git a/api/http/handler/endpoints/endpoint_status_inspect.go b/api/http/handler/endpoints/endpoint_status_inspect.go index aebdf90b2..283556a59 100644 --- a/api/http/handler/endpoints/endpoint_status_inspect.go +++ b/api/http/handler/endpoints/endpoint_status_inspect.go @@ -4,8 +4,8 @@ import ( "fmt" "net/http" - 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" ) // DEPRECATED diff --git a/api/http/handler/endpoints/endpoint_update.go b/api/http/handler/endpoints/endpoint_update.go index 4d566968c..f691ae15c 100644 --- a/api/http/handler/endpoints/endpoint_update.go +++ b/api/http/handler/endpoints/endpoint_update.go @@ -6,12 +6,12 @@ import ( "strconv" "strings" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/client" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type endpointUpdatePayload struct { diff --git a/api/http/handler/endpoints/endpoint_update_relations.go b/api/http/handler/endpoints/endpoint_update_relations.go index a89e961b4..1557c3338 100644 --- a/api/http/handler/endpoints/endpoint_update_relations.go +++ b/api/http/handler/endpoints/endpoint_update_relations.go @@ -3,12 +3,13 @@ package endpoints import ( "net/http" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) type endpointUpdateRelationsPayload struct { diff --git a/api/http/handler/endpoints/filter.go b/api/http/handler/endpoints/filter.go index b001d7398..d3d9cfa7a 100644 --- a/api/http/handler/endpoints/filter.go +++ b/api/http/handler/endpoints/filter.go @@ -7,8 +7,6 @@ import ( "strings" "time" - "github.com/pkg/errors" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/handler/edgegroups" @@ -16,6 +14,9 @@ import ( "github.com/portainer/portainer/api/internal/endpointutils" "github.com/portainer/portainer/api/internal/slices" "github.com/portainer/portainer/api/internal/unique" + "github.com/portainer/portainer/pkg/libhttp/request" + + "github.com/pkg/errors" ) type EnvironmentsQuery struct { diff --git a/api/http/handler/endpoints/handler.go b/api/http/handler/endpoints/handler.go index af0a3d608..ac3f96dbf 100644 --- a/api/http/handler/endpoints/handler.go +++ b/api/http/handler/endpoints/handler.go @@ -1,7 +1,8 @@ package endpoints import ( - httperror "github.com/portainer/libhttp/error" + "net/http" + portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/demo" @@ -9,8 +10,7 @@ import ( "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/authorization" "github.com/portainer/portainer/api/kubernetes/cli" - - "net/http" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/gorilla/mux" ) diff --git a/api/http/handler/gitops/git_repo_file_preview.go b/api/http/handler/gitops/git_repo_file_preview.go index 227fadd83..0ce5b1cdc 100644 --- a/api/http/handler/gitops/git_repo_file_preview.go +++ b/api/http/handler/gitops/git_repo_file_preview.go @@ -5,11 +5,12 @@ import ( "fmt" "net/http" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" gittypes "github.com/portainer/portainer/api/git/types" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/asaskevich/govalidator" ) type fileResponse struct { diff --git a/api/http/handler/gitops/handler.go b/api/http/handler/gitops/handler.go index cfe96e7a7..6297fa7bf 100644 --- a/api/http/handler/gitops/handler.go +++ b/api/http/handler/gitops/handler.go @@ -3,11 +3,12 @@ package gitops import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle git repo operation diff --git a/api/http/handler/helm/handler.go b/api/http/handler/helm/handler.go index de71861e0..e95263e57 100644 --- a/api/http/handler/helm/handler.go +++ b/api/http/handler/helm/handler.go @@ -3,8 +3,6 @@ package helm import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/middlewares" @@ -12,6 +10,9 @@ import ( "github.com/portainer/portainer/api/kubernetes" "github.com/portainer/portainer/pkg/libhelm" "github.com/portainer/portainer/pkg/libhelm/options" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle environment(endpoint) group operations. diff --git a/api/http/handler/helm/helm_delete.go b/api/http/handler/helm/helm_delete.go index d92e7f63c..f22224303 100644 --- a/api/http/handler/helm/helm_delete.go +++ b/api/http/handler/helm/helm_delete.go @@ -3,10 +3,10 @@ package helm import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/pkg/libhelm/options" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id HelmDelete diff --git a/api/http/handler/helm/helm_install.go b/api/http/handler/helm/helm_install.go index 232050345..9d9d5b829 100644 --- a/api/http/handler/helm/helm_install.go +++ b/api/http/handler/helm/helm_install.go @@ -6,16 +6,17 @@ import ( "os" "strings" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/kubernetes" "github.com/portainer/portainer/api/kubernetes/validation" "github.com/portainer/portainer/pkg/libhelm/options" "github.com/portainer/portainer/pkg/libhelm/release" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/api/http/handler/helm/helm_list.go b/api/http/handler/helm/helm_list.go index 12565c4f0..12cdfee07 100644 --- a/api/http/handler/helm/helm_list.go +++ b/api/http/handler/helm/helm_list.go @@ -3,11 +3,11 @@ package helm import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/pkg/libhelm/options" _ "github.com/portainer/portainer/pkg/libhelm/release" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id HelmList diff --git a/api/http/handler/helm/helm_repo_search.go b/api/http/handler/helm/helm_repo_search.go index 7b9697bbf..aab9c523d 100644 --- a/api/http/handler/helm/helm_repo_search.go +++ b/api/http/handler/helm/helm_repo_search.go @@ -5,9 +5,10 @@ import ( "net/http" "net/url" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/pkg/libhelm/options" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/pkg/errors" ) // @id HelmRepoSearch diff --git a/api/http/handler/helm/helm_show.go b/api/http/handler/helm/helm_show.go index 5d33f95b8..591c57922 100644 --- a/api/http/handler/helm/helm_show.go +++ b/api/http/handler/helm/helm_show.go @@ -5,9 +5,9 @@ import ( "net/http" "net/url" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" "github.com/portainer/portainer/pkg/libhelm/options" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/pkg/errors" "github.com/rs/zerolog/log" diff --git a/api/http/handler/helm/user_helm_repos.go b/api/http/handler/helm/user_helm_repos.go index b45eba2fd..1c159955a 100644 --- a/api/http/handler/helm/user_helm_repos.go +++ b/api/http/handler/helm/user_helm_repos.go @@ -4,15 +4,14 @@ import ( "net/http" "strings" - "github.com/pkg/errors" - - "github.com/portainer/portainer/pkg/libhelm" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" + "github.com/portainer/portainer/pkg/libhelm" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) type helmUserRepositoryResponse struct { diff --git a/api/http/handler/hostmanagement/fdo/configure.go b/api/http/handler/hostmanagement/fdo/configure.go index e27d8e7a4..a22c4bac8 100644 --- a/api/http/handler/hostmanagement/fdo/configure.go +++ b/api/http/handler/hostmanagement/fdo/configure.go @@ -7,10 +7,10 @@ import ( "net/url" "strings" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/fxamacker/cbor/v2" "github.com/rs/zerolog/log" diff --git a/api/http/handler/hostmanagement/fdo/fdo.go b/api/http/handler/hostmanagement/fdo/fdo.go index c3106cece..eed8963df 100644 --- a/api/http/handler/hostmanagement/fdo/fdo.go +++ b/api/http/handler/hostmanagement/fdo/fdo.go @@ -8,11 +8,11 @@ import ( "strconv" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/hostmanagement/fdo" + 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" ) diff --git a/api/http/handler/hostmanagement/fdo/handler.go b/api/http/handler/hostmanagement/fdo/handler.go index bc8287601..a6304453d 100644 --- a/api/http/handler/hostmanagement/fdo/handler.go +++ b/api/http/handler/hostmanagement/fdo/handler.go @@ -3,12 +3,12 @@ package fdo import ( "net/http" - "github.com/gorilla/mux" - - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) type Handler struct { diff --git a/api/http/handler/hostmanagement/fdo/list.go b/api/http/handler/hostmanagement/fdo/list.go index 4151ff459..e51339009 100644 --- a/api/http/handler/hostmanagement/fdo/list.go +++ b/api/http/handler/hostmanagement/fdo/list.go @@ -3,8 +3,8 @@ package fdo 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" "github.com/rs/zerolog/log" ) diff --git a/api/http/handler/hostmanagement/fdo/profile_create.go b/api/http/handler/hostmanagement/fdo/profile_create.go index d83ad9b50..afe80a80d 100644 --- a/api/http/handler/hostmanagement/fdo/profile_create.go +++ b/api/http/handler/hostmanagement/fdo/profile_create.go @@ -7,10 +7,10 @@ import ( "strconv" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type createProfileFromFileContentPayload struct { diff --git a/api/http/handler/hostmanagement/fdo/profile_delete.go b/api/http/handler/hostmanagement/fdo/profile_delete.go index 18f380547..cffe09e84 100644 --- a/api/http/handler/hostmanagement/fdo/profile_delete.go +++ b/api/http/handler/hostmanagement/fdo/profile_delete.go @@ -4,10 +4,10 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id deleteProfile diff --git a/api/http/handler/hostmanagement/fdo/profile_duplicate.go b/api/http/handler/hostmanagement/fdo/profile_duplicate.go index 9485e9342..117ef1311 100644 --- a/api/http/handler/hostmanagement/fdo/profile_duplicate.go +++ b/api/http/handler/hostmanagement/fdo/profile_duplicate.go @@ -7,10 +7,10 @@ import ( "strconv" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id duplicate diff --git a/api/http/handler/hostmanagement/fdo/profile_inspect.go b/api/http/handler/hostmanagement/fdo/profile_inspect.go index 5c88341fb..eaad731fc 100644 --- a/api/http/handler/hostmanagement/fdo/profile_inspect.go +++ b/api/http/handler/hostmanagement/fdo/profile_inspect.go @@ -4,10 +4,10 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type fdoProfileResponse struct { diff --git a/api/http/handler/hostmanagement/fdo/profile_list.go b/api/http/handler/hostmanagement/fdo/profile_list.go index c122ce27c..3828b27c7 100644 --- a/api/http/handler/hostmanagement/fdo/profile_list.go +++ b/api/http/handler/hostmanagement/fdo/profile_list.go @@ -3,8 +3,8 @@ package fdo 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" ) // @id fdoProfileList diff --git a/api/http/handler/hostmanagement/fdo/profile_update.go b/api/http/handler/hostmanagement/fdo/profile_update.go index 77a86a3ea..5820d5b5c 100644 --- a/api/http/handler/hostmanagement/fdo/profile_update.go +++ b/api/http/handler/hostmanagement/fdo/profile_update.go @@ -6,10 +6,10 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id updateProfile diff --git a/api/http/handler/hostmanagement/fdo/register.go b/api/http/handler/hostmanagement/fdo/register.go index 20a1e0773..088a25394 100644 --- a/api/http/handler/hostmanagement/fdo/register.go +++ b/api/http/handler/hostmanagement/fdo/register.go @@ -3,9 +3,9 @@ package fdo import ( "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" ) diff --git a/api/http/handler/hostmanagement/openamt/amtactivation.go b/api/http/handler/hostmanagement/openamt/amtactivation.go index 0fd5c5066..204ed5228 100644 --- a/api/http/handler/hostmanagement/openamt/amtactivation.go +++ b/api/http/handler/hostmanagement/openamt/amtactivation.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/internal/endpointutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id openAMTActivate diff --git a/api/http/handler/hostmanagement/openamt/amtconfiguration.go b/api/http/handler/hostmanagement/openamt/amtconfiguration.go index ff8db308b..98b6d481e 100644 --- a/api/http/handler/hostmanagement/openamt/amtconfiguration.go +++ b/api/http/handler/hostmanagement/openamt/amtconfiguration.go @@ -7,10 +7,10 @@ import ( "net/http" "strings" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + 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" "software.sslmate.com/src/go-pkcs12" diff --git a/api/http/handler/hostmanagement/openamt/amtdevices.go b/api/http/handler/hostmanagement/openamt/amtdevices.go index aa99c04de..511340910 100644 --- a/api/http/handler/hostmanagement/openamt/amtdevices.go +++ b/api/http/handler/hostmanagement/openamt/amtdevices.go @@ -4,10 +4,10 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + 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" ) diff --git a/api/http/handler/hostmanagement/openamt/amtrpc.go b/api/http/handler/hostmanagement/openamt/amtrpc.go index 1d4176db9..07aa71320 100644 --- a/api/http/handler/hostmanagement/openamt/amtrpc.go +++ b/api/http/handler/hostmanagement/openamt/amtrpc.go @@ -8,11 +8,11 @@ import ( "net/http" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/hostmanagement/openamt" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" diff --git a/api/http/handler/hostmanagement/openamt/handler.go b/api/http/handler/hostmanagement/openamt/handler.go index 50597d26c..165af6a55 100644 --- a/api/http/handler/hostmanagement/openamt/handler.go +++ b/api/http/handler/hostmanagement/openamt/handler.go @@ -5,11 +5,11 @@ import ( "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" dockerclient "github.com/portainer/portainer/api/docker/client" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) // Handler is the HTTP handler used to handle OpenAMT operations. diff --git a/api/http/handler/kubernetes/config.go b/api/http/handler/kubernetes/config.go index 71a4c3903..ef5a6c097 100644 --- a/api/http/handler/kubernetes/config.go +++ b/api/http/handler/kubernetes/config.go @@ -5,13 +5,14 @@ import ( "fmt" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/endpointutils" kcli "github.com/portainer/portainer/api/kubernetes/cli" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + clientV1 "k8s.io/client-go/tools/clientcmd/api/v1" ) diff --git a/api/http/handler/kubernetes/configmaps_and_secrets.go b/api/http/handler/kubernetes/configmaps_and_secrets.go index fc2580875..5774df5f4 100644 --- a/api/http/handler/kubernetes/configmaps_and_secrets.go +++ b/api/http/handler/kubernetes/configmaps_and_secrets.go @@ -4,9 +4,9 @@ import ( "net/http" "strconv" - 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" ) func (handler *Handler) getKubernetesConfigMapsAndSecrets(w http.ResponseWriter, r *http.Request) *httperror.HandlerError { diff --git a/api/http/handler/kubernetes/handler.go b/api/http/handler/kubernetes/handler.go index 6156739c9..375f27f25 100644 --- a/api/http/handler/kubernetes/handler.go +++ b/api/http/handler/kubernetes/handler.go @@ -7,17 +7,17 @@ import ( "strconv" portainer "github.com/portainer/portainer/api" - "github.com/portainer/portainer/api/kubernetes" - - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/middlewares" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/authorization" "github.com/portainer/portainer/api/internal/endpointutils" + "github.com/portainer/portainer/api/kubernetes" "github.com/portainer/portainer/api/kubernetes/cli" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler which will natively deal with to external environments(endpoints). diff --git a/api/http/handler/kubernetes/ingresses.go b/api/http/handler/kubernetes/ingresses.go index f81189d52..ad3428279 100644 --- a/api/http/handler/kubernetes/ingresses.go +++ b/api/http/handler/kubernetes/ingresses.go @@ -4,12 +4,12 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" models "github.com/portainer/portainer/api/http/models/kubernetes" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id getKubernetesIngressControllers diff --git a/api/http/handler/kubernetes/metrics.go b/api/http/handler/kubernetes/metrics.go index 5d4ebe61b..e771f3376 100644 --- a/api/http/handler/kubernetes/metrics.go +++ b/api/http/handler/kubernetes/metrics.go @@ -3,10 +3,11 @@ package kubernetes import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/api/http/handler/kubernetes/namespaces.go b/api/http/handler/kubernetes/namespaces.go index 25e3a628a..13084d179 100644 --- a/api/http/handler/kubernetes/namespaces.go +++ b/api/http/handler/kubernetes/namespaces.go @@ -4,10 +4,10 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" models "github.com/portainer/portainer/api/http/models/kubernetes" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id getKubernetesNamespaces diff --git a/api/http/handler/kubernetes/nodes_limits.go b/api/http/handler/kubernetes/nodes_limits.go index 6db7f0f93..ba1c2fe08 100644 --- a/api/http/handler/kubernetes/nodes_limits.go +++ b/api/http/handler/kubernetes/nodes_limits.go @@ -3,10 +3,10 @@ package kubernetes import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id getKubernetesNodesLimits diff --git a/api/http/handler/kubernetes/rbac.go b/api/http/handler/kubernetes/rbac.go index 012ff4af8..2c3b79f09 100644 --- a/api/http/handler/kubernetes/rbac.go +++ b/api/http/handler/kubernetes/rbac.go @@ -4,9 +4,9 @@ import ( "net/http" "strconv" - 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" ) // @id IsRBACEnabled diff --git a/api/http/handler/kubernetes/services.go b/api/http/handler/kubernetes/services.go index 76fc5906f..c8bf12643 100644 --- a/api/http/handler/kubernetes/services.go +++ b/api/http/handler/kubernetes/services.go @@ -4,10 +4,10 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" models "github.com/portainer/portainer/api/http/models/kubernetes" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id getKubernetesServices diff --git a/api/http/handler/kubernetes/toggle_system.go b/api/http/handler/kubernetes/toggle_system.go index 4eeaaf11e..f08b636bb 100644 --- a/api/http/handler/kubernetes/toggle_system.go +++ b/api/http/handler/kubernetes/toggle_system.go @@ -3,10 +3,10 @@ package kubernetes import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/api/http/middlewares" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type namespacesToggleSystemPayload struct { diff --git a/api/http/handler/ldap/handler.go b/api/http/handler/ldap/handler.go index 7b1aadd31..6b407830a 100644 --- a/api/http/handler/ldap/handler.go +++ b/api/http/handler/ldap/handler.go @@ -3,12 +3,13 @@ package ldap import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle LDAP search Operations diff --git a/api/http/handler/ldap/ldap_check.go b/api/http/handler/ldap/ldap_check.go index eb6ae056b..cbee1857f 100644 --- a/api/http/handler/ldap/ldap_check.go +++ b/api/http/handler/ldap/ldap_check.go @@ -3,10 +3,10 @@ package ldap import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type checkPayload struct { diff --git a/api/http/handler/motd/motd.go b/api/http/handler/motd/motd.go index db93d3342..669f6e7b2 100644 --- a/api/http/handler/motd/motd.go +++ b/api/http/handler/motd/motd.go @@ -5,10 +5,10 @@ import ( "net/http" "strings" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/client" "github.com/portainer/portainer/pkg/libcrypto" + "github.com/portainer/portainer/pkg/libhttp/response" ) type motdResponse struct { diff --git a/api/http/handler/registries/handler.go b/api/http/handler/registries/handler.go index 37a9cfff9..3d9faec6a 100644 --- a/api/http/handler/registries/handler.go +++ b/api/http/handler/registries/handler.go @@ -3,14 +3,15 @@ package registries import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/proxy" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/kubernetes/cli" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + + "github.com/gorilla/mux" ) func hideFields(registry *portainer.Registry, hideAccesses bool) { diff --git a/api/http/handler/registries/proxy_gitlab.go b/api/http/handler/registries/proxy_gitlab.go index 9e8276a7c..0f13e4de8 100644 --- a/api/http/handler/registries/proxy_gitlab.go +++ b/api/http/handler/registries/proxy_gitlab.go @@ -3,7 +3,7 @@ package registries import ( "net/http" - httperror "github.com/portainer/libhttp/error" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) // request on /api/registries/proxies/gitlab diff --git a/api/http/handler/registries/registry_configure.go b/api/http/handler/registries/registry_configure.go index 717512459..24bdb55ba 100644 --- a/api/http/handler/registries/registry_configure.go +++ b/api/http/handler/registries/registry_configure.go @@ -5,12 +5,12 @@ import ( "net/http" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type registryConfigurePayload struct { diff --git a/api/http/handler/registries/registry_create.go b/api/http/handler/registries/registry_create.go index 4d6dcb4ca..9a3e92c8e 100644 --- a/api/http/handler/registries/registry_create.go +++ b/api/http/handler/registries/registry_create.go @@ -5,13 +5,14 @@ import ( "fmt" "net/http" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/asaskevich/govalidator" ) type registryCreatePayload struct { diff --git a/api/http/handler/registries/registry_delete.go b/api/http/handler/registries/registry_delete.go index 8b75441ff..5c5263f12 100644 --- a/api/http/handler/registries/registry_delete.go +++ b/api/http/handler/registries/registry_delete.go @@ -3,12 +3,12 @@ package registries import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id RegistryDelete diff --git a/api/http/handler/registries/registry_inspect.go b/api/http/handler/registries/registry_inspect.go index e2b3cb79f..21b4ee3d4 100644 --- a/api/http/handler/registries/registry_inspect.go +++ b/api/http/handler/registries/registry_inspect.go @@ -4,11 +4,10 @@ import ( "net/http" portainer "github.com/portainer/portainer/api" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" httperrors "github.com/portainer/portainer/api/http/errors" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id RegistryInspect diff --git a/api/http/handler/registries/registry_list.go b/api/http/handler/registries/registry_list.go index a76a58595..ee3a9dd45 100644 --- a/api/http/handler/registries/registry_list.go +++ b/api/http/handler/registries/registry_list.go @@ -3,10 +3,10 @@ package registries import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id RegistryList diff --git a/api/http/handler/registries/registry_update.go b/api/http/handler/registries/registry_update.go index 2de80eac6..120747fb3 100644 --- a/api/http/handler/registries/registry_update.go +++ b/api/http/handler/registries/registry_update.go @@ -4,14 +4,13 @@ import ( "errors" "net/http" - "github.com/portainer/portainer/api/internal/endpointutils" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + "github.com/portainer/portainer/api/internal/endpointutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type registryUpdatePayload struct { diff --git a/api/http/handler/resourcecontrols/handler.go b/api/http/handler/resourcecontrols/handler.go index 215c7b687..052945462 100644 --- a/api/http/handler/resourcecontrols/handler.go +++ b/api/http/handler/resourcecontrols/handler.go @@ -3,10 +3,11 @@ package resourcecontrols import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle resource control operations. diff --git a/api/http/handler/resourcecontrols/resourcecontrol_create.go b/api/http/handler/resourcecontrols/resourcecontrol_create.go index 5eeb2e873..1a8982a79 100644 --- a/api/http/handler/resourcecontrols/resourcecontrol_create.go +++ b/api/http/handler/resourcecontrols/resourcecontrol_create.go @@ -4,11 +4,12 @@ import ( "errors" "net/http" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/asaskevich/govalidator" ) type resourceControlCreatePayload struct { diff --git a/api/http/handler/resourcecontrols/resourcecontrol_delete.go b/api/http/handler/resourcecontrols/resourcecontrol_delete.go index da6141ade..2bb308129 100644 --- a/api/http/handler/resourcecontrols/resourcecontrol_delete.go +++ b/api/http/handler/resourcecontrols/resourcecontrol_delete.go @@ -3,10 +3,10 @@ package resourcecontrols import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id ResourceControlDelete diff --git a/api/http/handler/resourcecontrols/resourcecontrol_update.go b/api/http/handler/resourcecontrols/resourcecontrol_update.go index 1a99dee02..576ac6811 100644 --- a/api/http/handler/resourcecontrols/resourcecontrol_update.go +++ b/api/http/handler/resourcecontrols/resourcecontrol_update.go @@ -4,12 +4,12 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type resourceControlUpdatePayload struct { diff --git a/api/http/handler/roles/handler.go b/api/http/handler/roles/handler.go index a8a48fff1..5ff59dd5f 100644 --- a/api/http/handler/roles/handler.go +++ b/api/http/handler/roles/handler.go @@ -3,10 +3,11 @@ package roles import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle role operations. diff --git a/api/http/handler/roles/role_list.go b/api/http/handler/roles/role_list.go index 4900d4e19..425e1e776 100644 --- a/api/http/handler/roles/role_list.go +++ b/api/http/handler/roles/role_list.go @@ -3,8 +3,8 @@ package roles 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" ) // @id RoleList diff --git a/api/http/handler/settings/handler.go b/api/http/handler/settings/handler.go index 2e75e4f03..d966557a7 100644 --- a/api/http/handler/settings/handler.go +++ b/api/http/handler/settings/handler.go @@ -3,12 +3,13 @@ package settings import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/demo" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) func hideFields(settings *portainer.Settings) { diff --git a/api/http/handler/settings/settings_inspect.go b/api/http/handler/settings/settings_inspect.go index 33ba77301..ccee2cc5e 100644 --- a/api/http/handler/settings/settings_inspect.go +++ b/api/http/handler/settings/settings_inspect.go @@ -3,8 +3,8 @@ package settings 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" ) // @id SettingsInspect diff --git a/api/http/handler/settings/settings_public.go b/api/http/handler/settings/settings_public.go index 105fd5c68..6301f8c63 100644 --- a/api/http/handler/settings/settings_public.go +++ b/api/http/handler/settings/settings_public.go @@ -4,10 +4,10 @@ import ( "fmt" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) type publicSettingsResponse struct { diff --git a/api/http/handler/settings/settings_update.go b/api/http/handler/settings/settings_update.go index b770efc4f..e31d01f4f 100644 --- a/api/http/handler/settings/settings_update.go +++ b/api/http/handler/settings/settings_update.go @@ -5,15 +5,15 @@ import ( "strings" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/pkg/featureflags" "github.com/portainer/portainer/pkg/libhelm" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/asaskevich/govalidator" "github.com/pkg/errors" diff --git a/api/http/handler/ssl/handler.go b/api/http/handler/ssl/handler.go index 0226b1963..c78b2e12a 100644 --- a/api/http/handler/ssl/handler.go +++ b/api/http/handler/ssl/handler.go @@ -3,10 +3,11 @@ package ssl import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/ssl" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle MOTD operations. diff --git a/api/http/handler/ssl/ssl_inspect.go b/api/http/handler/ssl/ssl_inspect.go index ec509b8e0..2a3649435 100644 --- a/api/http/handler/ssl/ssl_inspect.go +++ b/api/http/handler/ssl/ssl_inspect.go @@ -3,8 +3,8 @@ package ssl 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" ) // @id SSLInspect diff --git a/api/http/handler/ssl/ssl_update.go b/api/http/handler/ssl/ssl_update.go index bd006584a..1e8d74543 100644 --- a/api/http/handler/ssl/ssl_update.go +++ b/api/http/handler/ssl/ssl_update.go @@ -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" ) type sslUpdatePayload struct { diff --git a/api/http/handler/stacks/create_compose_stack.go b/api/http/handler/stacks/create_compose_stack.go index 93d4bfdc3..5e0bf3982 100644 --- a/api/http/handler/stacks/create_compose_stack.go +++ b/api/http/handler/stacks/create_compose_stack.go @@ -4,8 +4,6 @@ import ( "fmt" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/git/update" @@ -13,6 +11,8 @@ import ( "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackbuilders" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" "github.com/pkg/errors" diff --git a/api/http/handler/stacks/create_kubernetes_stack.go b/api/http/handler/stacks/create_kubernetes_stack.go index 39b555155..2d66df1c8 100644 --- a/api/http/handler/stacks/create_kubernetes_stack.go +++ b/api/http/handler/stacks/create_kubernetes_stack.go @@ -4,12 +4,6 @@ import ( "fmt" "net/http" - "github.com/asaskevich/govalidator" - "github.com/pkg/errors" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/git/update" "github.com/portainer/portainer/api/internal/endpointutils" @@ -18,6 +12,12 @@ import ( "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackbuilders" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/asaskevich/govalidator" + "github.com/pkg/errors" ) type kubernetesStringDeploymentPayload struct { diff --git a/api/http/handler/stacks/create_swarm_stack.go b/api/http/handler/stacks/create_swarm_stack.go index e84b907bb..192ebdb1b 100644 --- a/api/http/handler/stacks/create_swarm_stack.go +++ b/api/http/handler/stacks/create_swarm_stack.go @@ -4,16 +4,16 @@ import ( "fmt" "net/http" - "github.com/asaskevich/govalidator" - "github.com/pkg/errors" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/git/update" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/stackbuilders" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + + "github.com/asaskevich/govalidator" + "github.com/pkg/errors" ) type swarmStackFromFileContentPayload struct { diff --git a/api/http/handler/stacks/handler.go b/api/http/handler/stacks/handler.go index e333393e5..e79651c39 100644 --- a/api/http/handler/stacks/handler.go +++ b/api/http/handler/stacks/handler.go @@ -7,10 +7,6 @@ import ( "strings" "sync" - "github.com/docker/docker/api/types" - "github.com/gorilla/mux" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" dockerclient "github.com/portainer/portainer/api/docker/client" @@ -21,6 +17,11 @@ import ( "github.com/portainer/portainer/api/scheduler" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/docker/docker/api/types" + "github.com/gorilla/mux" + "github.com/pkg/errors" ) // Handler is the HTTP handler used to handle stack operations. diff --git a/api/http/handler/stacks/stack_associate.go b/api/http/handler/stacks/stack_associate.go index 14cfd0553..5eaaae726 100644 --- a/api/http/handler/stacks/stack_associate.go +++ b/api/http/handler/stacks/stack_associate.go @@ -5,12 +5,12 @@ import ( "net/http" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id StackAssociate diff --git a/api/http/handler/stacks/stack_create.go b/api/http/handler/stacks/stack_create.go index f18d89981..cb297f9d7 100644 --- a/api/http/handler/stacks/stack_create.go +++ b/api/http/handler/stacks/stack_create.go @@ -3,14 +3,15 @@ package stacks import ( "net/http" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/authorization" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) func (handler *Handler) stackCreate(w http.ResponseWriter, r *http.Request) *httperror.HandlerError { diff --git a/api/http/handler/stacks/stack_delete.go b/api/http/handler/stacks/stack_delete.go index 947e0009c..0d8bb2fab 100644 --- a/api/http/handler/stacks/stack_delete.go +++ b/api/http/handler/stacks/stack_delete.go @@ -7,16 +7,17 @@ import ( "os" "strconv" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/filesystem" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" "github.com/rs/zerolog/log" ) diff --git a/api/http/handler/stacks/stack_file.go b/api/http/handler/stacks/stack_file.go index 19dbbab5e..45a7169b9 100644 --- a/api/http/handler/stacks/stack_file.go +++ b/api/http/handler/stacks/stack_file.go @@ -3,14 +3,15 @@ package stacks import ( "net/http" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) type stackFileResponse struct { diff --git a/api/http/handler/stacks/stack_inspect.go b/api/http/handler/stacks/stack_inspect.go index 0662636e0..40734021b 100644 --- a/api/http/handler/stacks/stack_inspect.go +++ b/api/http/handler/stacks/stack_inspect.go @@ -3,14 +3,15 @@ package stacks import ( "net/http" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) // @id StackInspect diff --git a/api/http/handler/stacks/stack_list.go b/api/http/handler/stacks/stack_list.go index 99f55e8ef..feba50843 100644 --- a/api/http/handler/stacks/stack_list.go +++ b/api/http/handler/stacks/stack_list.go @@ -3,14 +3,13 @@ package stacks import ( "net/http" - httperrors "github.com/portainer/portainer/api/http/errors" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/authorization" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type stackListOperationFilters struct { diff --git a/api/http/handler/stacks/stack_migrate.go b/api/http/handler/stacks/stack_migrate.go index 6657e88ce..61d60e149 100644 --- a/api/http/handler/stacks/stack_migrate.go +++ b/api/http/handler/stacks/stack_migrate.go @@ -5,14 +5,14 @@ import ( "fmt" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type stackMigratePayload struct { diff --git a/api/http/handler/stacks/stack_start.go b/api/http/handler/stacks/stack_start.go index 8c9d08383..868006499 100644 --- a/api/http/handler/stacks/stack_start.go +++ b/api/http/handler/stacks/stack_start.go @@ -11,10 +11,9 @@ import ( "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" - - 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" ) // @id StackStart diff --git a/api/http/handler/stacks/stack_stop.go b/api/http/handler/stacks/stack_stop.go index b0dd44de1..f6c22a830 100644 --- a/api/http/handler/stacks/stack_stop.go +++ b/api/http/handler/stacks/stack_stop.go @@ -5,14 +5,14 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id StackStop diff --git a/api/http/handler/stacks/stack_update.go b/api/http/handler/stacks/stack_update.go index 9211d86e4..ec7ac2ab4 100644 --- a/api/http/handler/stacks/stack_update.go +++ b/api/http/handler/stacks/stack_update.go @@ -5,14 +5,14 @@ import ( "strconv" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/asaskevich/govalidator" "github.com/pkg/errors" diff --git a/api/http/handler/stacks/stack_update_git.go b/api/http/handler/stacks/stack_update_git.go index d9a81ccdf..63218e6f8 100644 --- a/api/http/handler/stacks/stack_update_git.go +++ b/api/http/handler/stacks/stack_update_git.go @@ -4,10 +4,6 @@ import ( "net/http" "time" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" gittypes "github.com/portainer/portainer/api/git/types" "github.com/portainer/portainer/api/git/update" @@ -15,6 +11,11 @@ import ( "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) type stackGitUpdatePayload struct { diff --git a/api/http/handler/stacks/stack_update_git_redeploy.go b/api/http/handler/stacks/stack_update_git_redeploy.go index 7cf9be69c..764886610 100644 --- a/api/http/handler/stacks/stack_update_git_redeploy.go +++ b/api/http/handler/stacks/stack_update_git_redeploy.go @@ -4,10 +4,6 @@ import ( "net/http" "time" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/git" httperrors "github.com/portainer/portainer/api/http/errors" @@ -15,6 +11,11 @@ import ( k "github.com/portainer/portainer/api/kubernetes" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) type stackGitRedployPayload struct { diff --git a/api/http/handler/stacks/update_kubernetes_stack.go b/api/http/handler/stacks/update_kubernetes_stack.go index 10d63c321..f167ebc1e 100644 --- a/api/http/handler/stacks/update_kubernetes_stack.go +++ b/api/http/handler/stacks/update_kubernetes_stack.go @@ -6,8 +6,6 @@ import ( "os" "strconv" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/filesystem" gittypes "github.com/portainer/portainer/api/git/types" @@ -16,6 +14,8 @@ import ( "github.com/portainer/portainer/api/internal/registryutils" k "github.com/portainer/portainer/api/kubernetes" "github.com/portainer/portainer/api/stacks/deployments" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" "github.com/pkg/errors" diff --git a/api/http/handler/stacks/webhook_invoke.go b/api/http/handler/stacks/webhook_invoke.go index b73b6888d..d32fd67bf 100644 --- a/api/http/handler/stacks/webhook_invoke.go +++ b/api/http/handler/stacks/webhook_invoke.go @@ -4,10 +4,10 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/api/stacks/deployments" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/gofrs/uuid" ) diff --git a/api/http/handler/system/handler.go b/api/http/handler/system/handler.go index 5b1d9decf..515fe4390 100644 --- a/api/http/handler/system/handler.go +++ b/api/http/handler/system/handler.go @@ -3,13 +3,14 @@ package system import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/demo" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/upgrade" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle status operations. diff --git a/api/http/handler/system/nodes_count.go b/api/http/handler/system/nodes_count.go index 7334d4e45..23f78749a 100644 --- a/api/http/handler/system/nodes_count.go +++ b/api/http/handler/system/nodes_count.go @@ -3,10 +3,11 @@ package system import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" statusutil "github.com/portainer/portainer/api/internal/nodes" "github.com/portainer/portainer/api/internal/snapshot" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" + "github.com/rs/zerolog/log" ) diff --git a/api/http/handler/system/status.go b/api/http/handler/system/status.go index 162cb9592..c37d9b38b 100644 --- a/api/http/handler/system/status.go +++ b/api/http/handler/system/status.go @@ -3,10 +3,11 @@ package system import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/demo" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" + "github.com/rs/zerolog/log" ) diff --git a/api/http/handler/system/system_info.go b/api/http/handler/system/system_info.go index d39949cd4..afeda8385 100644 --- a/api/http/handler/system/system_info.go +++ b/api/http/handler/system/system_info.go @@ -3,10 +3,10 @@ package system import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/api/internal/endpointutils" plf "github.com/portainer/portainer/api/platform" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) type systemInfoResponse struct { diff --git a/api/http/handler/system/system_upgrade.go b/api/http/handler/system/system_upgrade.go index 0669a742d..5a9fc3bea 100644 --- a/api/http/handler/system/system_upgrade.go +++ b/api/http/handler/system/system_upgrade.go @@ -4,12 +4,13 @@ import ( "net/http" "regexp" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/platform" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) type systemUpgradePayload struct { diff --git a/api/http/handler/system/version.go b/api/http/handler/system/version.go index 807b8f954..374f4e0a8 100644 --- a/api/http/handler/system/version.go +++ b/api/http/handler/system/version.go @@ -4,10 +4,10 @@ import ( "encoding/json" "net/http" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/build" "github.com/portainer/portainer/api/http/client" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/coreos/go-semver/semver" "github.com/rs/zerolog/log" diff --git a/api/http/handler/tags/handler.go b/api/http/handler/tags/handler.go index e1b3071dc..5a1bd7623 100644 --- a/api/http/handler/tags/handler.go +++ b/api/http/handler/tags/handler.go @@ -4,10 +4,10 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/gorilla/mux" ) diff --git a/api/http/handler/tags/tag_create.go b/api/http/handler/tags/tag_create.go index 5e4675291..acb01ad50 100644 --- a/api/http/handler/tags/tag_create.go +++ b/api/http/handler/tags/tag_create.go @@ -4,12 +4,13 @@ import ( "errors" "net/http" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + + "github.com/asaskevich/govalidator" ) type tagCreatePayload struct { diff --git a/api/http/handler/tags/tag_delete.go b/api/http/handler/tags/tag_delete.go index c2648b69a..501de3cc3 100644 --- a/api/http/handler/tags/tag_delete.go +++ b/api/http/handler/tags/tag_delete.go @@ -4,13 +4,13 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/internal/edge" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id TagDelete diff --git a/api/http/handler/tags/tag_list.go b/api/http/handler/tags/tag_list.go index a53d0ad20..a0d7a8b74 100644 --- a/api/http/handler/tags/tag_list.go +++ b/api/http/handler/tags/tag_list.go @@ -3,8 +3,8 @@ package tags 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" ) // @id TagList diff --git a/api/http/handler/teammemberships/handler.go b/api/http/handler/teammemberships/handler.go index 38d5cbf61..0bf1b0b2d 100644 --- a/api/http/handler/teammemberships/handler.go +++ b/api/http/handler/teammemberships/handler.go @@ -3,9 +3,9 @@ package teammemberships import ( "net/http" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/gorilla/mux" ) diff --git a/api/http/handler/teammemberships/teammembership_create.go b/api/http/handler/teammemberships/teammembership_create.go index 099ae92a3..16899e6fd 100644 --- a/api/http/handler/teammemberships/teammembership_create.go +++ b/api/http/handler/teammemberships/teammembership_create.go @@ -4,12 +4,12 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type teamMembershipCreatePayload struct { diff --git a/api/http/handler/teammemberships/teammembership_delete.go b/api/http/handler/teammemberships/teammembership_delete.go index e945aec56..de2771ac7 100644 --- a/api/http/handler/teammemberships/teammembership_delete.go +++ b/api/http/handler/teammemberships/teammembership_delete.go @@ -3,12 +3,12 @@ package teammemberships import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id TeamMembershipDelete diff --git a/api/http/handler/teammemberships/teammembership_list.go b/api/http/handler/teammemberships/teammembership_list.go index 1c0f11fc3..508f5db13 100644 --- a/api/http/handler/teammemberships/teammembership_list.go +++ b/api/http/handler/teammemberships/teammembership_list.go @@ -3,8 +3,8 @@ package teammemberships 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" ) // @id TeamMembershipList diff --git a/api/http/handler/teammemberships/teammembership_update.go b/api/http/handler/teammemberships/teammembership_update.go index b5da6f2cc..47a0115f3 100644 --- a/api/http/handler/teammemberships/teammembership_update.go +++ b/api/http/handler/teammemberships/teammembership_update.go @@ -4,12 +4,12 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type teamMembershipUpdatePayload struct { diff --git a/api/http/handler/teams/handler.go b/api/http/handler/teams/handler.go index 45cf156b9..271887838 100644 --- a/api/http/handler/teams/handler.go +++ b/api/http/handler/teams/handler.go @@ -3,10 +3,11 @@ package teams import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler is the HTTP handler used to handle team operations. diff --git a/api/http/handler/teams/team_create.go b/api/http/handler/teams/team_create.go index 8c30864e6..f4fc76702 100644 --- a/api/http/handler/teams/team_create.go +++ b/api/http/handler/teams/team_create.go @@ -4,11 +4,12 @@ import ( "errors" "net/http" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/asaskevich/govalidator" ) type teamCreatePayload struct { diff --git a/api/http/handler/teams/team_delete.go b/api/http/handler/teams/team_delete.go index 52e66b030..93cd43f17 100644 --- a/api/http/handler/teams/team_delete.go +++ b/api/http/handler/teams/team_delete.go @@ -3,11 +3,12 @@ package teams import ( "net/http" - "github.com/pkg/errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/pkg/errors" ) // @id TeamDelete diff --git a/api/http/handler/teams/team_inspect.go b/api/http/handler/teams/team_inspect.go index a037b2a37..ee92b7bc2 100644 --- a/api/http/handler/teams/team_inspect.go +++ b/api/http/handler/teams/team_inspect.go @@ -3,12 +3,12 @@ package teams import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id TeamInspect diff --git a/api/http/handler/teams/team_list.go b/api/http/handler/teams/team_list.go index 5bbaa6df6..35821de04 100644 --- a/api/http/handler/teams/team_list.go +++ b/api/http/handler/teams/team_list.go @@ -3,11 +3,11 @@ package teams import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id TeamList diff --git a/api/http/handler/teams/team_memberships.go b/api/http/handler/teams/team_memberships.go index aeeded983..5f577e914 100644 --- a/api/http/handler/teams/team_memberships.go +++ b/api/http/handler/teams/team_memberships.go @@ -3,12 +3,12 @@ package teams import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id TeamMemberships diff --git a/api/http/handler/teams/team_update.go b/api/http/handler/teams/team_update.go index ce8d663a2..ee04c2706 100644 --- a/api/http/handler/teams/team_update.go +++ b/api/http/handler/teams/team_update.go @@ -3,10 +3,10 @@ package teams import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type teamUpdatePayload struct { diff --git a/api/http/handler/templates/handler.go b/api/http/handler/templates/handler.go index 7f5dcd5b1..a6ee14e1e 100644 --- a/api/http/handler/templates/handler.go +++ b/api/http/handler/templates/handler.go @@ -3,11 +3,12 @@ package templates import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // Handler represents an HTTP API handler for managing templates. diff --git a/api/http/handler/templates/template_file.go b/api/http/handler/templates/template_file.go index 95254dbb6..043d0d0a1 100644 --- a/api/http/handler/templates/template_file.go +++ b/api/http/handler/templates/template_file.go @@ -5,12 +5,12 @@ import ( "errors" "net/http" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + "github.com/asaskevich/govalidator" "github.com/rs/zerolog/log" ) diff --git a/api/http/handler/templates/template_list.go b/api/http/handler/templates/template_list.go index 14cfad20b..8ea591296 100644 --- a/api/http/handler/templates/template_list.go +++ b/api/http/handler/templates/template_list.go @@ -4,8 +4,8 @@ import ( "io" "net/http" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) // introduced for swagger diff --git a/api/http/handler/upload/handler.go b/api/http/handler/upload/handler.go index 935a09345..d23e58ad1 100644 --- a/api/http/handler/upload/handler.go +++ b/api/http/handler/upload/handler.go @@ -1,11 +1,11 @@ package upload import ( - httperror "github.com/portainer/libhttp/error" + "net/http" + portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" - - "net/http" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/gorilla/mux" ) diff --git a/api/http/handler/upload/upload_tls.go b/api/http/handler/upload/upload_tls.go index f1e46297b..b25f2d5dd 100644 --- a/api/http/handler/upload/upload_tls.go +++ b/api/http/handler/upload/upload_tls.go @@ -3,11 +3,11 @@ package upload import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/filesystem" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id UploadTLS diff --git a/api/http/handler/users/admin_check.go b/api/http/handler/users/admin_check.go index 5fbec62a5..01d7b91d3 100644 --- a/api/http/handler/users/admin_check.go +++ b/api/http/handler/users/admin_check.go @@ -3,11 +3,10 @@ package users import ( "net/http" - "github.com/portainer/portainer/api/dataservices/errors" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + "github.com/portainer/portainer/api/dataservices/errors" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id UserAdminCheck diff --git a/api/http/handler/users/admin_init.go b/api/http/handler/users/admin_init.go index 9e56c7f46..1eb0f5734 100644 --- a/api/http/handler/users/admin_init.go +++ b/api/http/handler/users/admin_init.go @@ -4,11 +4,12 @@ import ( "errors" "net/http" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/asaskevich/govalidator" ) type adminInitPayload struct { diff --git a/api/http/handler/users/handler.go b/api/http/handler/users/handler.go index 4491fee72..b7113010c 100644 --- a/api/http/handler/users/handler.go +++ b/api/http/handler/users/handler.go @@ -2,16 +2,14 @@ package users import ( "errors" + "net/http" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" - "github.com/portainer/portainer/api/apikey" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/demo" "github.com/portainer/portainer/api/http/security" - - "net/http" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/gorilla/mux" ) diff --git a/api/http/handler/users/user_create.go b/api/http/handler/users/user_create.go index 8d913a6cd..8ba4e16fa 100644 --- a/api/http/handler/users/user_create.go +++ b/api/http/handler/users/user_create.go @@ -4,11 +4,12 @@ import ( "errors" "net/http" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/asaskevich/govalidator" ) type userCreatePayload struct { diff --git a/api/http/handler/users/user_create_access_token.go b/api/http/handler/users/user_create_access_token.go index 875635b61..cee657042 100644 --- a/api/http/handler/users/user_create_access_token.go +++ b/api/http/handler/users/user_create_access_token.go @@ -4,13 +4,14 @@ import ( "errors" "net/http" - "github.com/asaskevich/govalidator" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" + + "github.com/asaskevich/govalidator" ) type userAccessTokenCreatePayload struct { diff --git a/api/http/handler/users/user_delete.go b/api/http/handler/users/user_delete.go index 234a98131..25c588d04 100644 --- a/api/http/handler/users/user_delete.go +++ b/api/http/handler/users/user_delete.go @@ -4,11 +4,11 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id UserDelete diff --git a/api/http/handler/users/user_get_access_tokens.go b/api/http/handler/users/user_get_access_tokens.go index ba40939cf..a98b5094b 100644 --- a/api/http/handler/users/user_get_access_tokens.go +++ b/api/http/handler/users/user_get_access_tokens.go @@ -3,12 +3,12 @@ package users import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id UserGetAPIKeys diff --git a/api/http/handler/users/user_inspect.go b/api/http/handler/users/user_inspect.go index 80ed8fd56..f3308b6cf 100644 --- a/api/http/handler/users/user_inspect.go +++ b/api/http/handler/users/user_inspect.go @@ -3,12 +3,12 @@ package users import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id UserInspect diff --git a/api/http/handler/users/user_list.go b/api/http/handler/users/user_list.go index 4535dc73a..917c22a47 100644 --- a/api/http/handler/users/user_list.go +++ b/api/http/handler/users/user_list.go @@ -3,11 +3,11 @@ package users import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id UserList diff --git a/api/http/handler/users/user_memberships.go b/api/http/handler/users/user_memberships.go index 9f52d87aa..5f77afd6d 100644 --- a/api/http/handler/users/user_memberships.go +++ b/api/http/handler/users/user_memberships.go @@ -3,12 +3,12 @@ package users import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id UserMembershipsInspect diff --git a/api/http/handler/users/user_remove_access_token.go b/api/http/handler/users/user_remove_access_token.go index 52b114bf1..8ab6ca519 100644 --- a/api/http/handler/users/user_remove_access_token.go +++ b/api/http/handler/users/user_remove_access_token.go @@ -4,13 +4,13 @@ import ( "errors" "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/apikey" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @id UserRemoveAPIKey diff --git a/api/http/handler/users/user_update.go b/api/http/handler/users/user_update.go index 8c58003f6..df9ef0513 100644 --- a/api/http/handler/users/user_update.go +++ b/api/http/handler/users/user_update.go @@ -5,12 +5,12 @@ import ( "net/http" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/asaskevich/govalidator" ) diff --git a/api/http/handler/users/user_update_password.go b/api/http/handler/users/user_update_password.go index 5239f0534..981043860 100644 --- a/api/http/handler/users/user_update_password.go +++ b/api/http/handler/users/user_update_password.go @@ -5,12 +5,12 @@ import ( "net/http" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" httperrors "github.com/portainer/portainer/api/http/errors" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/asaskevich/govalidator" ) diff --git a/api/http/handler/webhooks/handler.go b/api/http/handler/webhooks/handler.go index 0566658c7..b981da82d 100644 --- a/api/http/handler/webhooks/handler.go +++ b/api/http/handler/webhooks/handler.go @@ -3,10 +3,10 @@ package webhooks import ( "net/http" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/dataservices" dockerclient "github.com/portainer/portainer/api/docker/client" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/gorilla/mux" ) diff --git a/api/http/handler/webhooks/webhook_create.go b/api/http/handler/webhooks/webhook_create.go index 9e27e4a34..1f840e7b1 100644 --- a/api/http/handler/webhooks/webhook_create.go +++ b/api/http/handler/webhooks/webhook_create.go @@ -4,13 +4,12 @@ import ( "errors" "net/http" + portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/registryutils/access" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" - portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" "github.com/asaskevich/govalidator" "github.com/gofrs/uuid" diff --git a/api/http/handler/webhooks/webhook_delete.go b/api/http/handler/webhooks/webhook_delete.go index 5344bc928..a16a886bd 100644 --- a/api/http/handler/webhooks/webhook_delete.go +++ b/api/http/handler/webhooks/webhook_delete.go @@ -4,12 +4,11 @@ import ( "errors" "net/http" - "github.com/portainer/portainer/api/http/security" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) // @summary Delete a webhook diff --git a/api/http/handler/webhooks/webhook_execute.go b/api/http/handler/webhooks/webhook_execute.go index 5aea5c080..baf22fc7e 100644 --- a/api/http/handler/webhooks/webhook_execute.go +++ b/api/http/handler/webhooks/webhook_execute.go @@ -7,13 +7,13 @@ import ( "net/http" "strings" + portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/internal/registryutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" dockertypes "github.com/docker/docker/api/types" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" - portainer "github.com/portainer/portainer/api" ) // @summary Execute a webhook diff --git a/api/http/handler/webhooks/webhook_list.go b/api/http/handler/webhooks/webhook_list.go index 64dc5698f..697788622 100644 --- a/api/http/handler/webhooks/webhook_list.go +++ b/api/http/handler/webhooks/webhook_list.go @@ -3,12 +3,11 @@ package webhooks import ( "net/http" - "github.com/portainer/portainer/api/http/security" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" portainer "github.com/portainer/portainer/api" + "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type webhookListOperationFilters struct { diff --git a/api/http/handler/webhooks/webhook_update.go b/api/http/handler/webhooks/webhook_update.go index eda3e529f..7a026fcd7 100644 --- a/api/http/handler/webhooks/webhook_update.go +++ b/api/http/handler/webhooks/webhook_update.go @@ -4,13 +4,12 @@ import ( "errors" "net/http" + portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/registryutils/access" - - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" - "github.com/portainer/libhttp/response" - portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + "github.com/portainer/portainer/pkg/libhttp/response" ) type webhookUpdatePayload struct { diff --git a/api/http/handler/websocket/attach.go b/api/http/handler/websocket/attach.go index 786296508..a4b3e19c0 100644 --- a/api/http/handler/websocket/attach.go +++ b/api/http/handler/websocket/attach.go @@ -6,9 +6,9 @@ import ( "net/http/httputil" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" "github.com/gorilla/websocket" diff --git a/api/http/handler/websocket/exec.go b/api/http/handler/websocket/exec.go index 1c85c0a19..46de75777 100644 --- a/api/http/handler/websocket/exec.go +++ b/api/http/handler/websocket/exec.go @@ -8,9 +8,9 @@ import ( "net/http/httputil" "time" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/asaskevich/govalidator" "github.com/gorilla/websocket" diff --git a/api/http/handler/websocket/handler.go b/api/http/handler/websocket/handler.go index cf0262c21..2d15891a0 100644 --- a/api/http/handler/websocket/handler.go +++ b/api/http/handler/websocket/handler.go @@ -1,14 +1,15 @@ package websocket import ( - "github.com/gorilla/mux" - "github.com/gorilla/websocket" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/proxy/factory/kubernetes" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/kubernetes/cli" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" + "github.com/gorilla/websocket" ) // Handler is the HTTP handler used to handle websocket operations. diff --git a/api/http/handler/websocket/pod.go b/api/http/handler/websocket/pod.go index 8520a5a3f..d37371d33 100644 --- a/api/http/handler/websocket/pod.go +++ b/api/http/handler/websocket/pod.go @@ -6,11 +6,11 @@ import ( "net/http" "strings" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/proxy/factory/kubernetes" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" "github.com/gorilla/websocket" "github.com/rs/zerolog/log" diff --git a/api/http/handler/websocket/shell_pod.go b/api/http/handler/websocket/shell_pod.go index e6e498e1a..cb3d1fd2b 100644 --- a/api/http/handler/websocket/shell_pod.go +++ b/api/http/handler/websocket/shell_pod.go @@ -3,10 +3,10 @@ package websocket import ( "net/http" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/http/security" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" ) // @summary Execute a websocket on kubectl shell pod diff --git a/api/http/middlewares/demo.go b/api/http/middlewares/demo.go index ea8b1aadb..cf95cac98 100644 --- a/api/http/middlewares/demo.go +++ b/api/http/middlewares/demo.go @@ -3,9 +3,10 @@ package middlewares import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/http/errors" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) // restrict functionality on demo environments diff --git a/api/http/middlewares/endpoint.go b/api/http/middlewares/endpoint.go index 2a4593fa2..b2a8a6552 100644 --- a/api/http/middlewares/endpoint.go +++ b/api/http/middlewares/endpoint.go @@ -5,12 +5,12 @@ import ( "errors" "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" - requesthelpers "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" - "github.com/portainer/portainer/api/dataservices" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + requesthelpers "github.com/portainer/portainer/pkg/libhttp/request" + + "github.com/gorilla/mux" ) const ( diff --git a/api/http/middlewares/featureflag.go b/api/http/middlewares/featureflag.go index c60e2cb8e..7498b115c 100644 --- a/api/http/middlewares/featureflag.go +++ b/api/http/middlewares/featureflag.go @@ -3,10 +3,11 @@ package middlewares import ( "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/pkg/featureflags" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/gorilla/mux" ) func FeatureFlag(settingsService dataservices.SettingsService, feature featureflags.Feature) mux.MiddlewareFunc { diff --git a/api/http/middlewares/withitem.go b/api/http/middlewares/withitem.go index 3229d555c..34e6a9ba2 100644 --- a/api/http/middlewares/withitem.go +++ b/api/http/middlewares/withitem.go @@ -5,10 +5,11 @@ import ( "errors" "net/http" - "github.com/gorilla/mux" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" "github.com/portainer/portainer/api/dataservices" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" + + "github.com/gorilla/mux" ) type ItemContextKey string diff --git a/api/http/offlinegate/offlinegate.go b/api/http/offlinegate/offlinegate.go index 992d3f199..aabe813af 100644 --- a/api/http/offlinegate/offlinegate.go +++ b/api/http/offlinegate/offlinegate.go @@ -5,7 +5,7 @@ import ( "strings" "time" - httperror "github.com/portainer/libhttp/error" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/rs/zerolog/log" lock "github.com/viney-shih/go-lock" diff --git a/api/http/proxy/factory/docker.go b/api/http/proxy/factory/docker.go index 0b43f59da..2e4d28e21 100644 --- a/api/http/proxy/factory/docker.go +++ b/api/http/proxy/factory/docker.go @@ -6,11 +6,11 @@ import ( "net/http" "strings" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/crypto" "github.com/portainer/portainer/api/http/proxy/factory/docker" "github.com/portainer/portainer/api/internal/url" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/rs/zerolog/log" ) diff --git a/api/http/security/bouncer.go b/api/http/security/bouncer.go index 052a639e7..85ef5f68f 100644 --- a/api/http/security/bouncer.go +++ b/api/http/security/bouncer.go @@ -5,11 +5,11 @@ import ( "strings" "time" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/apikey" "github.com/portainer/portainer/api/dataservices" httperrors "github.com/portainer/portainer/api/http/errors" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/pkg/errors" ) diff --git a/api/http/security/rate_limiter.go b/api/http/security/rate_limiter.go index 58ad63315..5b0e60fe6 100644 --- a/api/http/security/rate_limiter.go +++ b/api/http/security/rate_limiter.go @@ -5,9 +5,10 @@ import ( "strings" "time" - "github.com/g07cha/defender" - httperror "github.com/portainer/libhttp/error" "github.com/portainer/portainer/api/http/errors" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + + "github.com/g07cha/defender" ) // RateLimiter represents an entity that manages request rate limiting diff --git a/api/stacks/deployments/autoupdate.go b/api/stacks/deployments/autoupdate.go index 6fedea18e..3fdcbd0c0 100644 --- a/api/stacks/deployments/autoupdate.go +++ b/api/stacks/deployments/autoupdate.go @@ -3,10 +3,10 @@ package deployments import ( "time" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/scheduler" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/rs/zerolog/log" ) diff --git a/api/stacks/stackbuilders/compose_file_content_builder.go b/api/stacks/stackbuilders/compose_file_content_builder.go index df72207eb..813136162 100644 --- a/api/stacks/stackbuilders/compose_file_content_builder.go +++ b/api/stacks/stackbuilders/compose_file_content_builder.go @@ -3,12 +3,12 @@ package stackbuilders import ( "strconv" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type ComposeStackFileContentBuilder struct { diff --git a/api/stacks/stackbuilders/compose_file_upload_builder.go b/api/stacks/stackbuilders/compose_file_upload_builder.go index 1ea5a2556..e7968bc8c 100644 --- a/api/stacks/stackbuilders/compose_file_upload_builder.go +++ b/api/stacks/stackbuilders/compose_file_upload_builder.go @@ -1,12 +1,12 @@ package stackbuilders import ( - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type ComposeStackFileUploadBuilder struct { diff --git a/api/stacks/stackbuilders/compose_git_builder.go b/api/stacks/stackbuilders/compose_git_builder.go index e0198f631..43d10d376 100644 --- a/api/stacks/stackbuilders/compose_git_builder.go +++ b/api/stacks/stackbuilders/compose_git_builder.go @@ -1,12 +1,12 @@ package stackbuilders import ( - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/scheduler" "github.com/portainer/portainer/api/stacks/deployments" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type ComposeStackGitBuilder struct { diff --git a/api/stacks/stackbuilders/director.go b/api/stacks/stackbuilders/director.go index 2134c9aba..0af7b6c79 100644 --- a/api/stacks/stackbuilders/director.go +++ b/api/stacks/stackbuilders/director.go @@ -3,9 +3,9 @@ package stackbuilders import ( "errors" - httperror "github.com/portainer/libhttp/error" - "github.com/portainer/libhttp/request" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" + "github.com/portainer/portainer/pkg/libhttp/request" ) type StackBuilderDirector struct { diff --git a/api/stacks/stackbuilders/k8s_file_content_builder.go b/api/stacks/stackbuilders/k8s_file_content_builder.go index 783c2110b..0df4a5246 100644 --- a/api/stacks/stackbuilders/k8s_file_content_builder.go +++ b/api/stacks/stackbuilders/k8s_file_content_builder.go @@ -5,13 +5,13 @@ import ( "strconv" "sync" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" k "github.com/portainer/portainer/api/kubernetes" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type K8sStackFileContentBuilder struct { diff --git a/api/stacks/stackbuilders/k8s_git_builder.go b/api/stacks/stackbuilders/k8s_git_builder.go index 1907f8cf7..6b4092f6a 100644 --- a/api/stacks/stackbuilders/k8s_git_builder.go +++ b/api/stacks/stackbuilders/k8s_git_builder.go @@ -3,13 +3,13 @@ package stackbuilders import ( "sync" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" k "github.com/portainer/portainer/api/kubernetes" "github.com/portainer/portainer/api/scheduler" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type KubernetesStackGitBuilder struct { diff --git a/api/stacks/stackbuilders/k8s_url_builder.go b/api/stacks/stackbuilders/k8s_url_builder.go index ddd1d24ce..f22cd1702 100644 --- a/api/stacks/stackbuilders/k8s_url_builder.go +++ b/api/stacks/stackbuilders/k8s_url_builder.go @@ -4,7 +4,6 @@ import ( "strconv" "sync" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" @@ -12,6 +11,7 @@ import ( k "github.com/portainer/portainer/api/kubernetes" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type KubernetesStackUrlBuilder struct { diff --git a/api/stacks/stackbuilders/stack_builder.go b/api/stacks/stackbuilders/stack_builder.go index 920e936db..9ec4fc540 100644 --- a/api/stacks/stackbuilders/stack_builder.go +++ b/api/stacks/stackbuilders/stack_builder.go @@ -1,10 +1,10 @@ package stackbuilders import ( - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/stacks/deployments" + httperror "github.com/portainer/portainer/pkg/libhttp/error" "github.com/rs/zerolog/log" ) diff --git a/api/stacks/stackbuilders/stack_file_content_builder.go b/api/stacks/stackbuilders/stack_file_content_builder.go index e80efdef4..f70933991 100644 --- a/api/stacks/stackbuilders/stack_file_content_builder.go +++ b/api/stacks/stackbuilders/stack_file_content_builder.go @@ -3,8 +3,8 @@ package stackbuilders import ( "time" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type FileContentMethodStackBuildProcess interface { diff --git a/api/stacks/stackbuilders/stack_file_upload_builder.go b/api/stacks/stackbuilders/stack_file_upload_builder.go index 94a3952b3..b431a1400 100644 --- a/api/stacks/stackbuilders/stack_file_upload_builder.go +++ b/api/stacks/stackbuilders/stack_file_upload_builder.go @@ -4,8 +4,8 @@ import ( "strconv" "time" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type FileUploadMethodStackBuildProcess interface { diff --git a/api/stacks/stackbuilders/stack_git_builder.go b/api/stacks/stackbuilders/stack_git_builder.go index ac3ba0cb8..ed500e317 100644 --- a/api/stacks/stackbuilders/stack_git_builder.go +++ b/api/stacks/stackbuilders/stack_git_builder.go @@ -5,13 +5,13 @@ import ( "strconv" "time" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/filesystem" gittypes "github.com/portainer/portainer/api/git/types" "github.com/portainer/portainer/api/scheduler" "github.com/portainer/portainer/api/stacks/deployments" "github.com/portainer/portainer/api/stacks/stackutils" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type GitMethodStackBuildProcess interface { diff --git a/api/stacks/stackbuilders/stack_url_builder.go b/api/stacks/stackbuilders/stack_url_builder.go index 97753efa2..3393f4cea 100644 --- a/api/stacks/stackbuilders/stack_url_builder.go +++ b/api/stacks/stackbuilders/stack_url_builder.go @@ -3,8 +3,8 @@ package stackbuilders import ( "time" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type UrlMethodStackBuildProcess interface { diff --git a/api/stacks/stackbuilders/swarm_file_content_builder.go b/api/stacks/stackbuilders/swarm_file_content_builder.go index 06e501806..2ae3c4753 100644 --- a/api/stacks/stackbuilders/swarm_file_content_builder.go +++ b/api/stacks/stackbuilders/swarm_file_content_builder.go @@ -3,12 +3,12 @@ package stackbuilders import ( "strconv" - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type SwarmStackFileContentBuilder struct { diff --git a/api/stacks/stackbuilders/swarm_file_upload_builder.go b/api/stacks/stackbuilders/swarm_file_upload_builder.go index 73fd8e044..e60fd8f94 100644 --- a/api/stacks/stackbuilders/swarm_file_upload_builder.go +++ b/api/stacks/stackbuilders/swarm_file_upload_builder.go @@ -1,12 +1,12 @@ package stackbuilders import ( - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/stacks/deployments" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type SwarmStackFileUploadBuilder struct { diff --git a/api/stacks/stackbuilders/swarm_git_builder.go b/api/stacks/stackbuilders/swarm_git_builder.go index 2a437176b..c3d6fab6a 100644 --- a/api/stacks/stackbuilders/swarm_git_builder.go +++ b/api/stacks/stackbuilders/swarm_git_builder.go @@ -1,12 +1,12 @@ package stackbuilders import ( - httperror "github.com/portainer/libhttp/error" portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/dataservices" "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/scheduler" "github.com/portainer/portainer/api/stacks/deployments" + httperror "github.com/portainer/portainer/pkg/libhttp/error" ) type SwarmStackGitBuilder struct { diff --git a/go.mod b/go.mod index f8d4831c0..0819badbe 100644 --- a/go.mod +++ b/go.mod @@ -37,7 +37,6 @@ require ( github.com/orcaman/concurrent-map v1.0.0 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 - github.com/portainer/libhttp v0.0.0-20230615144939-a999f666d9a9 github.com/robfig/cron/v3 v3.0.1 github.com/rs/zerolog v1.29.0 github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 2356076f0..264233621 100644 --- a/go.sum +++ b/go.sum @@ -311,8 +311,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/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs= github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro= diff --git a/pkg/libhttp/LICENSE b/pkg/libhttp/LICENSE new file mode 100644 index 000000000..8696d60fa --- /dev/null +++ b/pkg/libhttp/LICENSE @@ -0,0 +1,17 @@ +Copyright (c) 2018-2020 Portainer.io + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. diff --git a/pkg/libhttp/README.md b/pkg/libhttp/README.md new file mode 100644 index 000000000..1b02c9bfc --- /dev/null +++ b/pkg/libhttp/README.md @@ -0,0 +1,5 @@ +[![GoDoc](https://godoc.org/github.com/portainer/libhttp?status.svg)](https://godoc.org/github.com/portainer/libhttp) + +# libhttp + +A HTTP library providing useful methods when working with `net/http` and `gorilla/mux`. diff --git a/pkg/libhttp/error/error.go b/pkg/libhttp/error/error.go new file mode 100644 index 000000000..929e4570e --- /dev/null +++ b/pkg/libhttp/error/error.go @@ -0,0 +1,46 @@ +// Package error provides error/logging functions that can be used in conjuction with http.Handler. +package error + +import ( + "encoding/json" + "errors" + "net/http" + + "github.com/rs/zerolog/log" +) + +type ( + // LoggerHandler defines a HTTP handler that includes a HandlerError return pointer + LoggerHandler func(http.ResponseWriter, *http.Request) *HandlerError + + errorResponse struct { + Message string `json:"message,omitempty"` + Details string `json:"details,omitempty"` + } +) + +func (handler LoggerHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + err := handler(rw, r) + if err != nil { + writeErrorResponse(rw, err) + } +} + +func writeErrorResponse(rw http.ResponseWriter, err *HandlerError) { + if err.Err == nil { + err.Err = errors.New(err.Message) + } + + log.Debug().CallerSkipFrame(2).Err(err.Err).Int("status_code", err.StatusCode).Str("msg", err.Message).Msg("HTTP error") + + rw.Header().Set("Content-Type", "application/json") + rw.WriteHeader(err.StatusCode) + + json.NewEncoder(rw).Encode(&errorResponse{Message: err.Message, Details: err.Err.Error()}) +} + +// WriteError is a convenience function that creates a new HandlerError before calling writeErrorResponse. +// For use outside of the standard http handlers. +func WriteError(rw http.ResponseWriter, code int, message string, err error) { + writeErrorResponse(rw, &HandlerError{code, message, err}) +} diff --git a/pkg/libhttp/error/status.go b/pkg/libhttp/error/status.go new file mode 100644 index 000000000..f9f3342f6 --- /dev/null +++ b/pkg/libhttp/error/status.go @@ -0,0 +1,42 @@ +package error + +import "net/http" + +// HandlerError represents an error raised inside a HTTP handler +type HandlerError struct { + StatusCode int + Message string + Err error +} + +func (h *HandlerError) Error() string { + return h.Message +} + +func NewError(statusCode int, message string, err error) *HandlerError { + return &HandlerError{ + StatusCode: statusCode, + Message: message, + Err: err, + } +} + +func BadRequest(message string, err error) *HandlerError { + return NewError(http.StatusBadRequest, message, err) +} + +func NotFound(message string, err error) *HandlerError { + return NewError(http.StatusNotFound, message, err) +} + +func InternalServerError(message string, err error) *HandlerError { + return NewError(http.StatusInternalServerError, message, err) +} + +func Unauthorized(message string, err error) *HandlerError { + return NewError(http.StatusUnauthorized, message, err) +} + +func Forbidden(message string, err error) *HandlerError { + return NewError(http.StatusForbidden, message, err) +} diff --git a/pkg/libhttp/request/payload.go b/pkg/libhttp/request/payload.go new file mode 100644 index 000000000..9e563ddd2 --- /dev/null +++ b/pkg/libhttp/request/payload.go @@ -0,0 +1,37 @@ +package request + +import ( + "encoding/json" + "net/http" + + "github.com/pkg/errors" +) + +// PayloadValidation is an interface used to validate the payload of a request. +type PayloadValidation interface { + Validate(request *http.Request) error +} + +// DecodeAndValidateJSONPayload decodes the body of the request into an object +// implementing the PayloadValidation interface. +// It also triggers a validation of object content. +func DecodeAndValidateJSONPayload(request *http.Request, v PayloadValidation) error { + if err := json.NewDecoder(request.Body).Decode(v); err != nil { + return err + } + return v.Validate(request) +} + +// GetPayload decodes the body of the request into an object implementing the PayloadValidation interface. +func GetPayload[T any, PT interface { + *T + Validate(request *http.Request) error +}](r *http.Request) (PT, error) { + p := PT(new(T)) + + err := DecodeAndValidateJSONPayload(r, p) + if err != nil { + return nil, errors.WithMessage(err, "Invalid request payload") + } + return p, nil +} diff --git a/pkg/libhttp/request/payload_test.go b/pkg/libhttp/request/payload_test.go new file mode 100644 index 000000000..4f107c2f9 --- /dev/null +++ b/pkg/libhttp/request/payload_test.go @@ -0,0 +1,43 @@ +package request_test + +import ( + "bytes" + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + "github.com/portainer/portainer/pkg/libhttp/request" + + "github.com/stretchr/testify/assert" +) + +type requestPayload struct { + FirstName string `json:"first_name"` + LastName string `json:"last_name"` +} + +func (p *requestPayload) Validate(r *http.Request) error { + return nil +} + +func Test_GetPayload(t *testing.T) { + + payload := requestPayload{ + FirstName: "John", + LastName: "Doe", + } + + payloadJSON, err := json.Marshal(payload) + if err != nil { + t.Fatal(err) + } + + r := httptest.NewRequest(http.MethodPost, "/", bytes.NewReader(payloadJSON)) + newPayload, err := request.GetPayload[requestPayload](r) + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, payload, *newPayload) +} diff --git a/pkg/libhttp/request/request.go b/pkg/libhttp/request/request.go new file mode 100644 index 000000000..e5c2ed5fc --- /dev/null +++ b/pkg/libhttp/request/request.go @@ -0,0 +1,152 @@ +// Package request provides function to retrieve content from a *http.Request object of the net/http standard library, +// be it JSON body payload, multi-part form values or query parameters. +// It also provides functions to retrieve route variables when using gorilla/mux. +package request + +import ( + "encoding/json" + "errors" + "io/ioutil" + "net/http" + "strconv" + + "github.com/gorilla/mux" +) + +const ( + // ErrInvalidQueryParameter defines the message of an error raised when a mandatory query parameter has an invalid value. + ErrInvalidQueryParameter = "Invalid query parameter" + // ErrInvalidRequestURL defines the message of an error raised when the data sent in the query or the URL is invalid + ErrInvalidRequestURL = "Invalid request URL" + // ErrMissingQueryParameter defines the message of an error raised when a mandatory query parameter is missing. + ErrMissingQueryParameter = "Missing query parameter" + // ErrMissingFormDataValue defines the message of an error raised when a mandatory form data value is missing. + ErrMissingFormDataValue = "Missing form data value" +) + +// RetrieveMultiPartFormFile returns the content of an uploaded file (form data) as bytes as well +// as the name of the uploaded file. +func RetrieveMultiPartFormFile(request *http.Request, requestParameter string) ([]byte, string, error) { + file, headers, err := request.FormFile(requestParameter) + if err != nil { + return nil, "", err + } + defer file.Close() + + fileContent, err := ioutil.ReadAll(file) + if err != nil { + return nil, "", err + } + return fileContent, headers.Filename, nil +} + +// RetrieveMultiPartFormJSONValue decodes the value of some form data as a JSON object into the target parameter. +// If optional is set to true, will not return an error when the form data value is not found. +func RetrieveMultiPartFormJSONValue(request *http.Request, name string, target interface{}, optional bool) error { + value, err := RetrieveMultiPartFormValue(request, name, optional) + if err != nil { + return err + } + if value == "" { + return nil + } + return json.Unmarshal([]byte(value), target) +} + +// RetrieveMultiPartFormValue returns the value of some form data as a string. +// If optional is set to true, will not return an error when the form data value is not found. +func RetrieveMultiPartFormValue(request *http.Request, name string, optional bool) (string, error) { + value := request.FormValue(name) + if value == "" && !optional { + return "", errors.New(ErrMissingFormDataValue) + } + return value, nil +} + +// RetrieveNumericMultiPartFormValue returns the value of some form data as an integer. +// If optional is set to true, will not return an error when the form data value is not found. +func RetrieveNumericMultiPartFormValue(request *http.Request, name string, optional bool) (int, error) { + value, err := RetrieveMultiPartFormValue(request, name, optional) + if err != nil { + return 0, err + } + return strconv.Atoi(value) +} + +// RetrieveBooleanMultiPartFormValue returns the value of some form data as a boolean. +// If optional is set to true, will not return an error when the form data value is not found. +func RetrieveBooleanMultiPartFormValue(request *http.Request, name string, optional bool) (bool, error) { + value, err := RetrieveMultiPartFormValue(request, name, optional) + if err != nil { + return false, err + } + return value == "true", nil +} + +// RetrieveRouteVariableValue returns the value of a route variable as a string. +func RetrieveRouteVariableValue(request *http.Request, name string) (string, error) { + routeVariables := mux.Vars(request) + if routeVariables == nil { + return "", errors.New(ErrInvalidRequestURL) + } + routeVar := routeVariables[name] + if routeVar == "" { + return "", errors.New(ErrInvalidRequestURL) + } + return routeVar, nil +} + +// RetrieveNumericRouteVariableValue returns the value of a route variable as an integer. +func RetrieveNumericRouteVariableValue(request *http.Request, name string) (int, error) { + routeVar, err := RetrieveRouteVariableValue(request, name) + if err != nil { + return 0, err + } + return strconv.Atoi(routeVar) +} + +// RetrieveQueryParameter returns the value of a query parameter as a string. +// If optional is set to true, will not return an error when the query parameter is not found. +func RetrieveQueryParameter(request *http.Request, name string, optional bool) (string, error) { + queryParameter := request.FormValue(name) + if queryParameter == "" && !optional { + return "", errors.New(ErrMissingQueryParameter) + } + return queryParameter, nil +} + +// RetrieveNumericQueryParameter returns the value of a query parameter as an integer. +// If optional is set to true, will not return an error when the query parameter is not found. +func RetrieveNumericQueryParameter(request *http.Request, name string, optional bool) (int, error) { + queryParameter, err := RetrieveQueryParameter(request, name, optional) + if err != nil { + return 0, err + } + if queryParameter == "" && optional { + return 0, nil + } + return strconv.Atoi(queryParameter) +} + +// RetrieveBooleanQueryParameter returns the value of a query parameter as a boolean. +// If optional is set to true, will not return an error when the query parameter is not found. +func RetrieveBooleanQueryParameter(request *http.Request, name string, optional bool) (bool, error) { + queryParameter, err := RetrieveQueryParameter(request, name, optional) + if err != nil { + return false, err + } + return queryParameter == "true", nil +} + +// RetrieveJSONQueryParameter decodes the value of a query parameter as a JSON object into the target parameter. +// If optional is set to true, will not return an error when the query parameter is not found. +func RetrieveJSONQueryParameter(request *http.Request, name string, target interface{}, optional bool) error { + queryParameter, err := RetrieveQueryParameter(request, name, optional) + if err != nil { + return err + } + if queryParameter == "" { + return nil + } + return json.Unmarshal([]byte(queryParameter), target) +} diff --git a/pkg/libhttp/response/response.go b/pkg/libhttp/response/response.go new file mode 100644 index 000000000..3a5bddfb7 --- /dev/null +++ b/pkg/libhttp/response/response.go @@ -0,0 +1,45 @@ +// Package response provides convenience functions to write into a http.ResponseWriter. +package response + +import ( + "encoding/json" + "errors" + "fmt" + "net/http" + + httperror "github.com/portainer/portainer/pkg/libhttp/error" +) + +// JSON encodes data to rw in JSON format. Returns a pointer to a +// HandlerError if encoding fails. +func JSON(rw http.ResponseWriter, data interface{}) *httperror.HandlerError { + rw.Header().Set("Content-Type", "application/json") + + err := json.NewEncoder(rw).Encode(data) + if err != nil { + return httperror.InternalServerError("Unable to write JSON response", err) + } + + return nil +} + +// JSON encodes data to rw in YAML format. Returns a pointer to a +// HandlerError if encoding fails. +func YAML(rw http.ResponseWriter, data interface{}) *httperror.HandlerError { + rw.Header().Set("Content-Type", "text/yaml") + + strData, ok := data.(string) + if !ok { + return httperror.InternalServerError("Unable to write YAML response", errors.New("failed to convert input to string")) + } + + fmt.Fprint(rw, strData) + + return nil +} + +// Empty merely sets the response code to NoContent (204). +func Empty(rw http.ResponseWriter) *httperror.HandlerError { + rw.WriteHeader(http.StatusNoContent) + return nil +}