mirror of
https://github.com/containers/podman.git
synced 2025-06-27 13:38:49 +08:00
Merge pull request #7804 from baude/issue7740
fix for compatibility volume creation
This commit is contained in:
@ -93,6 +93,29 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See if the volume exists already
|
||||||
|
existingVolume, err := runtime.GetVolume(input.Name)
|
||||||
|
if err != nil && errors.Cause(err) != define.ErrNoSuchVolume {
|
||||||
|
utils.InternalServerError(w, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// if using the compat layer and the volume already exists, we
|
||||||
|
// must return a 201 with the same information as create
|
||||||
|
if existingVolume != nil && !utils.IsLibpodRequest(r) {
|
||||||
|
response := docker_api_types.Volume{
|
||||||
|
CreatedAt: existingVolume.CreatedTime().Format(time.RFC3339),
|
||||||
|
Driver: existingVolume.Driver(),
|
||||||
|
Labels: existingVolume.Labels(),
|
||||||
|
Mountpoint: existingVolume.MountPoint(),
|
||||||
|
Name: existingVolume.Name(),
|
||||||
|
Options: existingVolume.Options(),
|
||||||
|
Scope: existingVolume.Scope(),
|
||||||
|
}
|
||||||
|
utils.WriteResponse(w, http.StatusCreated, response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if len(input.Name) > 0 {
|
if len(input.Name) > 0 {
|
||||||
volumeOptions = append(volumeOptions, libpod.WithVolumeName(input.Name))
|
volumeOptions = append(volumeOptions, libpod.WithVolumeName(input.Name))
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,9 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error {
|
|||||||
// parameters:
|
// parameters:
|
||||||
// - in: body
|
// - in: body
|
||||||
// name: create
|
// name: create
|
||||||
// description: attributes for creating a container
|
// description: |
|
||||||
|
// attributes for creating a container.
|
||||||
|
// Note: If a volume by the same name exists, a 201 response with that volume's information will be generated.
|
||||||
// schema:
|
// schema:
|
||||||
// $ref: "#/definitions/DockerVolumeCreate"
|
// $ref: "#/definitions/DockerVolumeCreate"
|
||||||
// produces:
|
// produces:
|
||||||
|
Reference in New Issue
Block a user