Merge pull request #9695 from jmguzik/array-inspect-network-fix

Fix array instead of one elem network http api
This commit is contained in:
OpenShift Merge Robot
2021-03-16 11:31:33 +01:00
committed by GitHub
4 changed files with 8 additions and 3 deletions

View File

@ -128,7 +128,7 @@ func InspectNetwork(w http.ResponseWriter, r *http.Request) {
utils.InternalServerError(w, err) utils.InternalServerError(w, err)
return return
} }
utils.WriteResponse(w, http.StatusOK, reports) utils.WriteResponse(w, http.StatusOK, reports[0])
} }
// Connect adds a container to a network // Connect adds a container to a network

View File

@ -102,7 +102,7 @@ type swagNetworkRmReport struct {
// swagger:response NetworkInspectReport // swagger:response NetworkInspectReport
type swagNetworkInspectReport struct { type swagNetworkInspectReport struct {
// in:body // in:body
Body []entities.NetworkInspectReport Body entities.NetworkInspectReport
} }
// Network list // Network list

View File

@ -40,6 +40,7 @@ func Create(ctx context.Context, options *CreateOptions) (*entities.NetworkCreat
// Inspect returns low level information about a CNI network configuration // Inspect returns low level information about a CNI network configuration
func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) ([]entities.NetworkInspectReport, error) { func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) ([]entities.NetworkInspectReport, error) {
var reports []entities.NetworkInspectReport var reports []entities.NetworkInspectReport
reports = append(reports, entities.NetworkInspectReport{})
if options == nil { if options == nil {
options = new(InspectOptions) options = new(InspectOptions)
} }
@ -52,7 +53,7 @@ func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) ([]e
if err != nil { if err != nil {
return nil, err return nil, err
} }
return reports, response.Process(&reports) return reports, response.Process(&reports[0])
} }
// Remove deletes a defined CNI network configuration by name. The optional force boolean // Remove deletes a defined CNI network configuration by name. The optional force boolean

View File

@ -30,6 +30,10 @@ t GET libpod/networks/json?filters='{"name":["network1"]}' 200 \
.[0].Name=network1 .[0].Name=network1
t GET networks 200 t GET networks 200
#inspect network
t GET libpod/networks/network1/json 200 \
.name="network1"
#network list docker endpoint #network list docker endpoint
t GET networks?filters='{"name":["network1","network2"]}' 200 \ t GET networks?filters='{"name":["network1","network2"]}' 200 \
length=2 length=2