Add swagger.yaml
Generate Volume type from the swagger.yaml Add makefile target for generating the models Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
13fd75c3dd
commit
0243936d92
5 changed files with 6758 additions and 19 deletions
6
Makefile
6
Makefile
|
@ -137,3 +137,9 @@ validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isol
|
||||||
|
|
||||||
win: build ## cross build the binary for windows
|
win: build ## cross build the binary for windows
|
||||||
$(DOCKER_RUN_DOCKER) hack/make.sh win
|
$(DOCKER_RUN_DOCKER) hack/make.sh win
|
||||||
|
|
||||||
|
.PHONY: swagger-gen
|
||||||
|
swagger-gen:
|
||||||
|
docker run --rm -v $(PWD):/work -w /work quay.io/goswagger/swagger \
|
||||||
|
generate model -m "types" -f api/swagger.yaml -t api/ --skip-validator \
|
||||||
|
-n Volume
|
||||||
|
|
6694
api/swagger.yaml
Normal file
6694
api/swagger.yaml
Normal file
File diff suppressed because it is too large
Load diff
|
@ -433,24 +433,6 @@ type MountPoint struct {
|
||||||
Propagation mount.Propagation
|
Propagation mount.Propagation
|
||||||
}
|
}
|
||||||
|
|
||||||
// VolumeUsageData holds information regarding the volume usage
|
|
||||||
type VolumeUsageData struct {
|
|
||||||
Size int64 // Size holds how much disk space is used by the (local driver only). Sets to -1 if not provided.
|
|
||||||
RefCount int // RefCount holds the number of containers having this volume attached to them. Sets to -1 if not provided.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Volume represents the configuration of a volume for the remote API
|
|
||||||
type Volume struct {
|
|
||||||
Name string // Name is the name of the volume
|
|
||||||
Driver string // Driver is the Driver name used to create the volume
|
|
||||||
Mountpoint string // Mountpoint is the location on disk of the volume
|
|
||||||
Status map[string]interface{} `json:",omitempty"` // Status provides low-level status information about the volume
|
|
||||||
Labels map[string]string // Labels is metadata specific to the volume
|
|
||||||
Scope string // Scope describes the level at which the volume exists (e.g. `global` for cluster-wide or `local` for machine level)
|
|
||||||
Options map[string]string // Options holds the driver specific options to use for when creating the volume.
|
|
||||||
UsageData *VolumeUsageData `json:",omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// VolumesListResponse contains the response for the remote API:
|
// VolumesListResponse contains the response for the remote API:
|
||||||
// GET "/volumes"
|
// GET "/volumes"
|
||||||
type VolumesListResponse struct {
|
type VolumesListResponse struct {
|
||||||
|
|
57
api/types/volume.go
Normal file
57
api/types/volume.go
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
// Volume volume
|
||||||
|
// swagger:model Volume
|
||||||
|
type Volume struct {
|
||||||
|
|
||||||
|
// Name of the volume driver used by the volume.
|
||||||
|
// Required: true
|
||||||
|
Driver string `json:"Driver"`
|
||||||
|
|
||||||
|
// A mapping of abitrary key/value data set on this volume.
|
||||||
|
// Required: true
|
||||||
|
Labels map[string]string `json:"Labels"`
|
||||||
|
|
||||||
|
// Mount path of the volume on the host.
|
||||||
|
// Required: true
|
||||||
|
Mountpoint string `json:"Mountpoint"`
|
||||||
|
|
||||||
|
// Name of the volume.
|
||||||
|
// Required: true
|
||||||
|
Name string `json:"Name"`
|
||||||
|
|
||||||
|
// ref count
|
||||||
|
RefCount int64 `json:"RefCount,omitempty"`
|
||||||
|
|
||||||
|
// The level at which the volume exists. Either `global` for cluster-wide, or `local` for machine level.
|
||||||
|
// Required: true
|
||||||
|
Scope string `json:"Scope"`
|
||||||
|
|
||||||
|
// Low-level details about the volume, provided by the volume driver.
|
||||||
|
// Details are returned as a map with key/value pairs:
|
||||||
|
// `{"key":"value","key2":"value2"}`.
|
||||||
|
//
|
||||||
|
// The `Status` field is optional, and is omitted if the volume driver
|
||||||
|
// does not support this feature.
|
||||||
|
//
|
||||||
|
Status map[string]interface{} `json:"Status,omitempty"`
|
||||||
|
|
||||||
|
// usage data
|
||||||
|
UsageData *VolumeUsageData `json:"UsageData,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// VolumeUsageDatavolume usage data
|
||||||
|
// swagger:model VolumeUsageData
|
||||||
|
type VolumeUsageData struct {
|
||||||
|
|
||||||
|
// The number of containers referencing this volume.
|
||||||
|
// Required: true
|
||||||
|
RefCount int64 `json:"RefCount"`
|
||||||
|
|
||||||
|
// The disk space used by the volume (local driver only)
|
||||||
|
// Required: true
|
||||||
|
Size int64 `json:"Size"`
|
||||||
|
}
|
|
@ -61,7 +61,7 @@ func (daemon *Daemon) SystemDiskUsage() (*types.DiskUsage, error) {
|
||||||
logrus.Warnf("failed to determine size of volume %v", name)
|
logrus.Warnf("failed to determine size of volume %v", name)
|
||||||
sz = -1
|
sz = -1
|
||||||
}
|
}
|
||||||
tv.UsageData = &types.VolumeUsageData{Size: sz, RefCount: len(refs)}
|
tv.UsageData = &types.VolumeUsageData{Size: sz, RefCount: int64(len(refs))}
|
||||||
allVolumes = append(allVolumes, tv)
|
allVolumes = append(allVolumes, tv)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue