diff options
Diffstat (limited to 'pkg/api/handlers/compat')
-rw-r--r-- | pkg/api/handlers/compat/containers_create.go | 8 | ||||
-rw-r--r-- | pkg/api/handlers/compat/images_history.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/info.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/compat/networks.go | 6 |
4 files changed, 8 insertions, 10 deletions
diff --git a/pkg/api/handlers/compat/containers_create.go b/pkg/api/handlers/compat/containers_create.go index 3d4bd4fb5..3ae9d9ab3 100644 --- a/pkg/api/handlers/compat/containers_create.go +++ b/pkg/api/handlers/compat/containers_create.go @@ -62,10 +62,8 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) { func makeCreateConfig(containerConfig *config.Config, input handlers.CreateContainerConfig, newImage *image2.Image) (createconfig.CreateConfig, error) { var ( - err error - init bool - tmpfs []string - volumes []string + err error + init bool ) env := make(map[string]string) stopSignal := unix.SIGTERM @@ -137,6 +135,7 @@ func makeCreateConfig(containerConfig *config.Config, input handlers.CreateConta User: input.User, } pidConfig := createconfig.PidConfig{PidMode: namespaces.PidMode(input.HostConfig.PidMode)} + volumes := make([]string, 0, len(input.Volumes)) for k := range input.Volumes { volumes = append(volumes, k) } @@ -158,6 +157,7 @@ func makeCreateConfig(containerConfig *config.Config, input handlers.CreateConta } // format the tmpfs mounts into a []string from map + tmpfs := make([]string, 0, len(input.HostConfig.Tmpfs)) for k, v := range input.HostConfig.Tmpfs { tmpfs = append(tmpfs, fmt.Sprintf("%s:%s", k, v)) } diff --git a/pkg/api/handlers/compat/images_history.go b/pkg/api/handlers/compat/images_history.go index afadf4c48..7c0bbf828 100644 --- a/pkg/api/handlers/compat/images_history.go +++ b/pkg/api/handlers/compat/images_history.go @@ -12,7 +12,6 @@ import ( func HistoryImage(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) name := utils.GetName(r) - var allHistory []handlers.HistoryResponse newImage, err := runtime.ImageRuntime().NewFromLocal(name) if err != nil { @@ -25,6 +24,7 @@ func HistoryImage(w http.ResponseWriter, r *http.Request) { utils.InternalServerError(w, err) return } + allHistory := make([]handlers.HistoryResponse, 0, len(history)) for _, h := range history { l := handlers.HistoryResponse{ ID: h.ID, diff --git a/pkg/api/handlers/compat/info.go b/pkg/api/handlers/compat/info.go index d4a933c54..5c3f610a4 100644 --- a/pkg/api/handlers/compat/info.go +++ b/pkg/api/handlers/compat/info.go @@ -129,7 +129,7 @@ func GetInfo(w http.ResponseWriter, r *http.Request) { } func getGraphStatus(storeInfo map[string]string) [][2]string { - var graphStatus [][2]string + graphStatus := make([][2]string, 0, len(storeInfo)) for k, v := range storeInfo { graphStatus = append(graphStatus, [2]string{k, v}) } diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go index 8734ba405..0f1eca5e5 100644 --- a/pkg/api/handlers/compat/networks.go +++ b/pkg/api/handlers/compat/networks.go @@ -162,9 +162,6 @@ func findPluginByName(plugins []*libcni.NetworkConfig, pluginType string) ([]byt } func ListNetworks(w http.ResponseWriter, r *http.Request) { - var ( - reports []*types.NetworkResource - ) runtime := r.Context().Value("runtime").(*libpod.Runtime) decoder := r.Context().Value("decoder").(*schema.Decoder) query := struct { @@ -191,6 +188,7 @@ func ListNetworks(w http.ResponseWriter, r *http.Request) { utils.InternalServerError(w, err) return } + reports := make([]*types.NetworkResource, 0, len(netNames)) for _, name := range netNames { report, err := getNetworkResourceByName(name, runtime) if err != nil { @@ -215,7 +213,7 @@ func CreateNetwork(w http.ResponseWriter, r *http.Request) { if len(networkCreate.Name) > 0 { name = networkCreate.Name } - // At present I think we should just suport the bridge driver + // At present I think we should just support the bridge driver // and allow demand to make us consider more if networkCreate.Driver != network.DefaultNetworkDriver { utils.InternalServerError(w, errors.New("network create only supports the bridge driver")) |