summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2021-01-12 13:44:56 -0600
committerbaude <bbaude@redhat.com>2021-01-13 09:35:24 -0600
commit827f6c9cb01929a7c36a465d633c82d384ed7ddb (patch)
tree581ce5889f07b19770bbd9c4ff0dd56ddfc9ea50 /pkg
parent99c5746150799d6cfe3ea612d3c88c6b904f9312 (diff)
downloadpodman-827f6c9cb01929a7c36a465d633c82d384ed7ddb.tar.gz
podman-827f6c9cb01929a7c36a465d633c82d384ed7ddb.tar.bz2
podman-827f6c9cb01929a7c36a465d633c82d384ed7ddb.zip
Reduce general binding binary size
when using the bindings to *only* make a connection, the binary was rough 28MB. This PR reduces it down to 11. There is more work to do but it will come in a secondary PR. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/unsupported.go5
-rw-r--r--pkg/api/handlers/utils/errors.go4
-rw-r--r--pkg/api/server/swagger.go29
-rw-r--r--pkg/bindings/errors.go6
-rw-r--r--pkg/domain/entities/types.go24
-rw-r--r--pkg/domain/infra/tunnel/containers.go2
-rw-r--r--pkg/domain/infra/tunnel/images.go9
-rw-r--r--pkg/domain/infra/tunnel/network.go3
-rw-r--r--pkg/domain/infra/tunnel/volumes.go3
-rw-r--r--pkg/errorhandling/errorhandling.go24
-rw-r--r--pkg/specgen/generate/kube/kube.go2
-rw-r--r--pkg/specgen/generate/kube/volume.go2
-rw-r--r--pkg/specgen/volumes.go2
13 files changed, 58 insertions, 57 deletions
diff --git a/pkg/api/handlers/compat/unsupported.go b/pkg/api/handlers/compat/unsupported.go
index e5ff266f9..1c518690f 100644
--- a/pkg/api/handlers/compat/unsupported.go
+++ b/pkg/api/handlers/compat/unsupported.go
@@ -4,9 +4,8 @@ import (
"fmt"
"net/http"
- "github.com/containers/podman/v2/pkg/domain/entities"
-
"github.com/containers/podman/v2/pkg/api/handlers/utils"
+ "github.com/containers/podman/v2/pkg/errorhandling"
log "github.com/sirupsen/logrus"
)
@@ -14,5 +13,5 @@ func UnsupportedHandler(w http.ResponseWriter, r *http.Request) {
msg := fmt.Sprintf("Path %s is not supported", r.URL.Path)
log.Infof("Request Failed: %s", msg)
- utils.WriteJSON(w, http.StatusNotFound, entities.ErrorModel{Message: msg})
+ utils.WriteJSON(w, http.StatusNotFound, errorhandling.ErrorModel{Message: msg})
}
diff --git a/pkg/api/handlers/utils/errors.go b/pkg/api/handlers/utils/errors.go
index fc77b8ec0..e2c287c45 100644
--- a/pkg/api/handlers/utils/errors.go
+++ b/pkg/api/handlers/utils/errors.go
@@ -5,7 +5,7 @@ import (
"net/http"
"github.com/containers/podman/v2/libpod/define"
- "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/errorhandling"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
@@ -24,7 +24,7 @@ var (
func Error(w http.ResponseWriter, apiMessage string, code int, err error) {
// Log detailed message of what happened to machine running podman service
log.Infof("Request Failed(%s): %s", http.StatusText(code), err.Error())
- em := entities.ErrorModel{
+ em := errorhandling.ErrorModel{
Because: (errors.Cause(err)).Error(),
Message: err.Error(),
ResponseCode: code,
diff --git a/pkg/api/server/swagger.go b/pkg/api/server/swagger.go
index 45253e01a..d4fc33442 100644
--- a/pkg/api/server/swagger.go
+++ b/pkg/api/server/swagger.go
@@ -5,6 +5,7 @@ import (
"github.com/containers/podman/v2/libpod/define"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/domain/entities/reports"
+ "github.com/containers/podman/v2/pkg/errorhandling"
)
// No such image
@@ -12,7 +13,7 @@ import (
type swagErrNoSuchImage struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -21,7 +22,7 @@ type swagErrNoSuchImage struct {
type swagErrNoSuchContainer struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -30,7 +31,7 @@ type swagErrNoSuchContainer struct {
type swagErrNoSuchNetwork struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -39,7 +40,7 @@ type swagErrNoSuchNetwork struct {
type swagErrNoSuchExecInstance struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -48,7 +49,7 @@ type swagErrNoSuchExecInstance struct {
type swagErrNoSuchVolume struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -57,7 +58,7 @@ type swagErrNoSuchVolume struct {
type swagErrNoSuchPod struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -66,7 +67,7 @@ type swagErrNoSuchPod struct {
type swagErrNoSuchManifest struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -75,7 +76,7 @@ type swagErrNoSuchManifest struct {
type swagInternalError struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -84,7 +85,7 @@ type swagInternalError struct {
type swagConflictError struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -93,7 +94,7 @@ type swagConflictError struct {
type swagBadParamError struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -102,7 +103,7 @@ type swagBadParamError struct {
type swagContainerAlreadyStartedError struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -111,7 +112,7 @@ type swagContainerAlreadyStartedError struct {
type swagContainerAlreadyStopped struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -120,7 +121,7 @@ type swagContainerAlreadyStopped struct {
type swagPodAlreadyStartedError struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
@@ -129,7 +130,7 @@ type swagPodAlreadyStartedError struct {
type swagPodAlreadyStopped struct {
// in:body
Body struct {
- entities.ErrorModel
+ errorhandling.ErrorModel
}
}
diff --git a/pkg/bindings/errors.go b/pkg/bindings/errors.go
index 603299389..e75ce898d 100644
--- a/pkg/bindings/errors.go
+++ b/pkg/bindings/errors.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"io/ioutil"
- "github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/errorhandling"
"github.com/pkg/errors"
)
@@ -13,7 +13,7 @@ var (
)
func handleError(data []byte) error {
- e := entities.ErrorModel{}
+ e := errorhandling.ErrorModel{}
if err := json.Unmarshal(data, &e); err != nil {
return err
}
@@ -36,7 +36,7 @@ func (a APIResponse) Process(unmarshalInto interface{}) error {
}
func CheckResponseCode(inError error) (int, error) {
- e, ok := inError.(entities.ErrorModel)
+ e, ok := inError.(errorhandling.ErrorModel)
if !ok {
return -1, errors.New("error is not type ErrorModel")
}
diff --git a/pkg/domain/entities/types.go b/pkg/domain/entities/types.go
index 12135c2b1..e5473dc62 100644
--- a/pkg/domain/entities/types.go
+++ b/pkg/domain/entities/types.go
@@ -1,7 +1,6 @@
package entities
import (
- "errors"
"net"
"github.com/containers/buildah/imagebuildah"
@@ -90,29 +89,6 @@ type ContainerCreateResponse struct {
Warnings []string `json:"Warnings"`
}
-type ErrorModel struct {
- // API root cause formatted for automated parsing
- // example: API root cause
- Because string `json:"cause"`
- // human error message, formatted for a human to read
- // example: human error message
- Message string `json:"message"`
- // http response code
- ResponseCode int `json:"response"`
-}
-
-func (e ErrorModel) Error() string {
- return e.Message
-}
-
-func (e ErrorModel) Cause() error {
- return errors.New(e.Because)
-}
-
-func (e ErrorModel) Code() int {
- return e.ResponseCode
-}
-
// BuildOptions describe the options for building container images.
type BuildOptions struct {
imagebuildah.BuildOptions
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 3366cb425..49bcdec98 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -211,7 +211,7 @@ func (ic *ContainerEngine) ContainerInspect(ctx context.Context, namesOrIds []st
for _, name := range namesOrIds {
inspect, err := containers.Inspect(ic.ClientCtx, name, options)
if err != nil {
- errModel, ok := err.(entities.ErrorModel)
+ errModel, ok := err.(errorhandling.ErrorModel)
if !ok {
return nil, nil, err
}
diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go
index 8ab832599..7a4aa1fbc 100644
--- a/pkg/domain/infra/tunnel/images.go
+++ b/pkg/domain/infra/tunnel/images.go
@@ -8,16 +8,15 @@ import (
"strings"
"time"
- "github.com/containers/podman/v2/libpod/image"
-
- "github.com/containers/image/v5/types"
-
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/docker/reference"
+ "github.com/containers/image/v5/types"
+ "github.com/containers/podman/v2/libpod/image"
images "github.com/containers/podman/v2/pkg/bindings/images"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/domain/entities/reports"
"github.com/containers/podman/v2/pkg/domain/utils"
+ "github.com/containers/podman/v2/pkg/errorhandling"
utils2 "github.com/containers/podman/v2/utils"
"github.com/pkg/errors"
)
@@ -187,7 +186,7 @@ func (ir *ImageEngine) Inspect(ctx context.Context, namesOrIDs []string, opts en
for _, i := range namesOrIDs {
r, err := images.GetImage(ir.ClientCtx, i, options)
if err != nil {
- errModel, ok := err.(entities.ErrorModel)
+ errModel, ok := err.(errorhandling.ErrorModel)
if !ok {
return nil, nil, err
}
diff --git a/pkg/domain/infra/tunnel/network.go b/pkg/domain/infra/tunnel/network.go
index 9afb8db02..d4e827580 100644
--- a/pkg/domain/infra/tunnel/network.go
+++ b/pkg/domain/infra/tunnel/network.go
@@ -5,6 +5,7 @@ import (
"github.com/containers/podman/v2/pkg/bindings/network"
"github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/errorhandling"
"github.com/pkg/errors"
)
@@ -22,7 +23,7 @@ func (ic *ContainerEngine) NetworkInspect(ctx context.Context, namesOrIds []stri
for _, name := range namesOrIds {
report, err := network.Inspect(ic.ClientCtx, name, options)
if err != nil {
- errModel, ok := err.(entities.ErrorModel)
+ errModel, ok := err.(errorhandling.ErrorModel)
if !ok {
return nil, nil, err
}
diff --git a/pkg/domain/infra/tunnel/volumes.go b/pkg/domain/infra/tunnel/volumes.go
index 10e8d7da8..f21336828 100644
--- a/pkg/domain/infra/tunnel/volumes.go
+++ b/pkg/domain/infra/tunnel/volumes.go
@@ -6,6 +6,7 @@ import (
"github.com/containers/podman/v2/pkg/bindings/volumes"
"github.com/containers/podman/v2/pkg/domain/entities"
"github.com/containers/podman/v2/pkg/domain/entities/reports"
+ "github.com/containers/podman/v2/pkg/errorhandling"
"github.com/pkg/errors"
)
@@ -55,7 +56,7 @@ func (ic *ContainerEngine) VolumeInspect(ctx context.Context, namesOrIds []strin
for _, id := range namesOrIds {
data, err := volumes.Inspect(ic.ClientCtx, id, nil)
if err != nil {
- errModel, ok := err.(entities.ErrorModel)
+ errModel, ok := err.(errorhandling.ErrorModel)
if !ok {
return nil, nil, err
}
diff --git a/pkg/errorhandling/errorhandling.go b/pkg/errorhandling/errorhandling.go
index 21df261fb..b1923be98 100644
--- a/pkg/errorhandling/errorhandling.go
+++ b/pkg/errorhandling/errorhandling.go
@@ -70,3 +70,27 @@ func CloseQuiet(f *os.File) {
func Contains(err error, sub error) bool {
return strings.Contains(err.Error(), sub.Error())
}
+
+// ErrorModel is used in remote connections with podman
+type ErrorModel struct {
+ // API root cause formatted for automated parsing
+ // example: API root cause
+ Because string `json:"cause"`
+ // human error message, formatted for a human to read
+ // example: human error message
+ Message string `json:"message"`
+ // http response code
+ ResponseCode int `json:"response"`
+}
+
+func (e ErrorModel) Error() string {
+ return e.Message
+}
+
+func (e ErrorModel) Cause() error {
+ return errors.New(e.Because)
+}
+
+func (e ErrorModel) Code() int {
+ return e.ResponseCode
+}
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go
index e5b09dcd8..f5ccf4d85 100644
--- a/pkg/specgen/generate/kube/kube.go
+++ b/pkg/specgen/generate/kube/kube.go
@@ -5,7 +5,7 @@ import (
"fmt"
"strings"
- "github.com/containers/buildah/pkg/parse"
+ "github.com/containers/common/pkg/parse"
"github.com/containers/podman/v2/libpod/image"
ann "github.com/containers/podman/v2/pkg/annotations"
"github.com/containers/podman/v2/pkg/specgen"
diff --git a/pkg/specgen/generate/kube/volume.go b/pkg/specgen/generate/kube/volume.go
index bb8edabb7..f5687f60d 100644
--- a/pkg/specgen/generate/kube/volume.go
+++ b/pkg/specgen/generate/kube/volume.go
@@ -3,7 +3,7 @@ package kube
import (
"os"
- "github.com/containers/buildah/pkg/parse"
+ "github.com/containers/common/pkg/parse"
"github.com/containers/podman/v2/libpod"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
diff --git a/pkg/specgen/volumes.go b/pkg/specgen/volumes.go
index a4f42d715..83634b4ef 100644
--- a/pkg/specgen/volumes.go
+++ b/pkg/specgen/volumes.go
@@ -4,7 +4,7 @@ import (
"path/filepath"
"strings"
- "github.com/containers/buildah/pkg/parse"
+ "github.com/containers/common/pkg/parse"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"