Replace the hard-coded archive size from error message with actual value (#735)
This commit is contained in:
@@ -18,9 +18,11 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
@@ -64,12 +66,14 @@ func (a *API) PackageApiCreate(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// Ensure size limits
|
// Ensure size limits
|
||||||
if len(f.Spec.Source.Literal) > int(fission.ArchiveLiteralSizeLimit) {
|
if len(f.Spec.Source.Literal) > int(fission.ArchiveLiteralSizeLimit) {
|
||||||
err := fission.MakeError(fission.ErrorInvalidArgument, "Package literal larger than 256K")
|
err := fission.MakeError(fission.ErrorInvalidArgument,
|
||||||
|
fmt.Sprintf("Package literal larger than %s", humanize.Bytes(uint64(fission.ArchiveLiteralSizeLimit))))
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(f.Spec.Deployment.Literal) > int(fission.ArchiveLiteralSizeLimit) {
|
if len(f.Spec.Deployment.Literal) > int(fission.ArchiveLiteralSizeLimit) {
|
||||||
err := fission.MakeError(fission.ErrorInvalidArgument, "Package literal larger than 256K")
|
err := fission.MakeError(fission.ErrorInvalidArgument,
|
||||||
|
fmt.Sprintf("Package literal larger than %s", humanize.Bytes(uint64(fission.ArchiveLiteralSizeLimit))))
|
||||||
a.respondWithError(w, err)
|
a.respondWithError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+2
@@ -430,3 +430,5 @@ testImports:
|
|||||||
- difflib
|
- difflib
|
||||||
- name: github.com/stretchr/objx
|
- name: github.com/stretchr/objx
|
||||||
version: 8a3f7159479fbc75b30357fbc48f380b7320f08e
|
version: 8a3f7159479fbc75b30357fbc48f380b7320f08e
|
||||||
|
- name: github.com/dustin/go-humanize
|
||||||
|
version: 02af3965c54e8cacf948b97fef38925c4120652c
|
||||||
|
|||||||
+1
-1
@@ -63,4 +63,4 @@ import:
|
|||||||
- package: github.com/hashicorp/errwrap
|
- package: github.com/hashicorp/errwrap
|
||||||
- package: github.com/prometheus/client_golang
|
- package: github.com/prometheus/client_golang
|
||||||
version: v0.8.0
|
version: v0.8.0
|
||||||
|
- package: github.com/dustin/go-humanize
|
||||||
|
|||||||
Reference in New Issue
Block a user