1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-05 05:45:22 +02:00

feat(performance): performance optimizations EE-6042 (#10520)

This commit is contained in:
andres-portainer 2023-10-24 13:55:11 -03:00 committed by GitHub
parent e4e66dac9c
commit ae1726cece
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 311 additions and 382 deletions

View file

@ -1,11 +1,11 @@
package binary
import (
"encoding/json"
"github.com/pkg/errors"
"github.com/portainer/portainer/pkg/libhelm/options"
"github.com/portainer/portainer/pkg/libhelm/release"
"github.com/pkg/errors"
"github.com/segmentio/encoding/json"
)
// Install runs `helm install` with specified install options.

View file

@ -1,11 +1,11 @@
package binary
import (
"encoding/json"
"github.com/pkg/errors"
"github.com/portainer/portainer/pkg/libhelm/options"
"github.com/portainer/portainer/pkg/libhelm/release"
"github.com/pkg/errors"
"github.com/segmentio/encoding/json"
)
// List runs `helm list --output json --filter <filter> --selector <selector> --namespace <namespace>` with specified list options.

View file

@ -4,15 +4,16 @@ package binary
// The functionality does not rely on the implementation of `HelmPackageManager`
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"path"
"time"
"github.com/pkg/errors"
"github.com/portainer/portainer/pkg/libhelm/options"
"github.com/pkg/errors"
"github.com/segmentio/encoding/json"
"gopkg.in/yaml.v3"
)

View file

@ -1,13 +1,14 @@
package test
import (
"encoding/json"
"strings"
"github.com/pkg/errors"
"github.com/portainer/portainer/pkg/libhelm"
"github.com/portainer/portainer/pkg/libhelm/options"
"github.com/portainer/portainer/pkg/libhelm/release"
"github.com/pkg/errors"
"github.com/segmentio/encoding/json"
"gopkg.in/yaml.v3"
)

View file

@ -17,9 +17,10 @@ limitations under the License.
package time
import (
"encoding/json"
"testing"
"time"
"github.com/segmentio/encoding/json"
)
var (

View file

@ -2,11 +2,11 @@
package error
import (
"encoding/json"
"errors"
"net/http"
"github.com/rs/zerolog/log"
"github.com/segmentio/encoding/json"
)
type (
@ -36,7 +36,11 @@ func writeErrorResponse(rw http.ResponseWriter, err *HandlerError) {
rw.Header().Set("Content-Type", "application/json")
rw.WriteHeader(err.StatusCode)
json.NewEncoder(rw).Encode(&errorResponse{Message: err.Message, Details: err.Err.Error()})
enc := json.NewEncoder(rw)
enc.SetSortMapKeys(false)
enc.SetAppendNewline(false)
enc.Encode(&errorResponse{Message: err.Message, Details: err.Err.Error()})
}
// WriteError is a convenience function that creates a new HandlerError before calling writeErrorResponse.

View file

@ -1,10 +1,10 @@
package request
import (
"encoding/json"
"net/http"
"github.com/pkg/errors"
"github.com/segmentio/encoding/json"
)
// PayloadValidation is an interface used to validate the payload of a request.

View file

@ -2,13 +2,13 @@ package request_test
import (
"bytes"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"github.com/portainer/portainer/pkg/libhttp/request"
"github.com/segmentio/encoding/json"
"github.com/stretchr/testify/assert"
)

View file

@ -4,13 +4,13 @@
package request
import (
"encoding/json"
"errors"
"io/ioutil"
"net/http"
"strconv"
"github.com/gorilla/mux"
"github.com/segmentio/encoding/json"
)
const (

View file

@ -2,12 +2,13 @@
package response
import (
"encoding/json"
"errors"
"fmt"
"net/http"
httperror "github.com/portainer/portainer/pkg/libhttp/error"
"github.com/segmentio/encoding/json"
)
// JSON encodes data to rw in JSON format. Returns a pointer to a
@ -15,7 +16,11 @@ import (
func JSON(rw http.ResponseWriter, data interface{}) *httperror.HandlerError {
rw.Header().Set("Content-Type", "application/json")
err := json.NewEncoder(rw).Encode(data)
enc := json.NewEncoder(rw)
enc.SetSortMapKeys(false)
enc.SetAppendNewline(false)
err := enc.Encode(data)
if err != nil {
return httperror.InternalServerError("Unable to write JSON response", err)
}

View file

@ -2,12 +2,13 @@ package composeplugin
import (
"context"
"encoding/json"
"fmt"
"time"
"github.com/portainer/portainer/pkg/libstack"
"github.com/rs/zerolog/log"
"github.com/segmentio/encoding/json"
)
type publisher struct {