Generate plugin types from the swagger spec.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
02e1ffd76c
commit
6f7b69b63f
9 changed files with 415 additions and 167 deletions
|
@ -1118,11 +1118,15 @@ definitions:
|
||||||
|
|
||||||
PluginMount:
|
PluginMount:
|
||||||
type: "object"
|
type: "object"
|
||||||
|
x-nullable: false
|
||||||
|
required: [Name, Description, Settable, Source, Destination, Type, Options]
|
||||||
properties:
|
properties:
|
||||||
Name:
|
Name:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Description:
|
Description:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Settable:
|
Settable:
|
||||||
type: "array"
|
type: "array"
|
||||||
items:
|
items:
|
||||||
|
@ -1131,8 +1135,10 @@ definitions:
|
||||||
type: "string"
|
type: "string"
|
||||||
Destination:
|
Destination:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Type:
|
Type:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Options:
|
Options:
|
||||||
type: "array"
|
type: "array"
|
||||||
items:
|
items:
|
||||||
|
@ -1140,11 +1146,15 @@ definitions:
|
||||||
|
|
||||||
PluginDevice:
|
PluginDevice:
|
||||||
type: "object"
|
type: "object"
|
||||||
|
required: [Name, Description, Settable, Path]
|
||||||
|
x-nullable: false
|
||||||
properties:
|
properties:
|
||||||
Name:
|
Name:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Description:
|
Description:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Settable:
|
Settable:
|
||||||
type: "array"
|
type: "array"
|
||||||
items:
|
items:
|
||||||
|
@ -1152,22 +1162,61 @@ definitions:
|
||||||
Path:
|
Path:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
|
||||||
|
PluginEnv:
|
||||||
|
type: "object"
|
||||||
|
x-nullable: false
|
||||||
|
required: [Name, Description, Settable, Value]
|
||||||
|
properties:
|
||||||
|
Name:
|
||||||
|
x-nullable: false
|
||||||
|
type: "string"
|
||||||
|
Description:
|
||||||
|
x-nullable: false
|
||||||
|
type: "string"
|
||||||
|
Settable:
|
||||||
|
type: "array"
|
||||||
|
items:
|
||||||
|
type: "string"
|
||||||
|
Value:
|
||||||
|
type: "string"
|
||||||
|
|
||||||
|
PluginInterfaceType:
|
||||||
|
type: "object"
|
||||||
|
x-nullable: false
|
||||||
|
required: [Prefix, Capability, Version]
|
||||||
|
properties:
|
||||||
|
Prefix:
|
||||||
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
|
Capability:
|
||||||
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
|
Version:
|
||||||
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
|
|
||||||
Plugin:
|
Plugin:
|
||||||
description: "A plugin for the Remote API"
|
description: "A plugin for the Remote API"
|
||||||
type: "object"
|
type: "object"
|
||||||
|
required: [Config, Enabled, Manifest, Name, Tag]
|
||||||
properties:
|
properties:
|
||||||
Id:
|
Id:
|
||||||
type: "string"
|
type: "string"
|
||||||
Name:
|
Name:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Tag:
|
Tag:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Enabled:
|
Enabled:
|
||||||
description: "True when the plugin is running. False when the plugin is not running, only installed."
|
description: "True when the plugin is running. False when the plugin is not running, only installed."
|
||||||
type: "boolean"
|
type: "boolean"
|
||||||
|
x-nullable: false
|
||||||
Config:
|
Config:
|
||||||
description: "Settings that can be modified by users."
|
description: "Settings that can be modified by users."
|
||||||
type: "object"
|
type: "object"
|
||||||
|
x-nullable: false
|
||||||
|
required: [Args, Devices, Env, Mounts]
|
||||||
properties:
|
properties:
|
||||||
Mounts:
|
Mounts:
|
||||||
type: "array"
|
type: "array"
|
||||||
|
@ -1188,40 +1237,67 @@ definitions:
|
||||||
Manifest:
|
Manifest:
|
||||||
description: "The manifest of a plugin."
|
description: "The manifest of a plugin."
|
||||||
type: "object"
|
type: "object"
|
||||||
|
x-nullable: false
|
||||||
|
required:
|
||||||
|
- ManifestVersion
|
||||||
|
- Description
|
||||||
|
- Documentation
|
||||||
|
- Interface
|
||||||
|
- Entrypoint
|
||||||
|
- Workdir
|
||||||
|
- Network
|
||||||
|
- Capabilities
|
||||||
|
- Mounts
|
||||||
|
- Devices
|
||||||
|
- Env
|
||||||
|
- Args
|
||||||
properties:
|
properties:
|
||||||
ManifestVersion:
|
ManifestVersion:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Description:
|
Description:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Documentation:
|
Documentation:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Interface:
|
Interface:
|
||||||
description: "The interface between Docker and the plugin"
|
description: "The interface between Docker and the plugin"
|
||||||
|
x-nullable: false
|
||||||
type: "object"
|
type: "object"
|
||||||
|
required: [Types, Socket]
|
||||||
properties:
|
properties:
|
||||||
Types:
|
Types:
|
||||||
type: "array"
|
type: "array"
|
||||||
items:
|
items:
|
||||||
type: "string"
|
$ref: "#/definitions/PluginInterfaceType"
|
||||||
Socket:
|
Socket:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
Entrypoint:
|
Entrypoint:
|
||||||
type: "array"
|
type: "array"
|
||||||
items:
|
items:
|
||||||
type: "string"
|
type: "string"
|
||||||
Workdir:
|
Workdir:
|
||||||
type: "string"
|
type: "string"
|
||||||
|
x-nullable: false
|
||||||
User:
|
User:
|
||||||
type: "object"
|
type: "object"
|
||||||
|
x-nullable: false
|
||||||
properties:
|
properties:
|
||||||
UID:
|
UID:
|
||||||
type: "integer"
|
type: "integer"
|
||||||
|
format: "uint32"
|
||||||
GID:
|
GID:
|
||||||
type: "integer"
|
type: "integer"
|
||||||
|
format: "uint32"
|
||||||
Network:
|
Network:
|
||||||
type: "object"
|
type: "object"
|
||||||
|
x-nullable: false
|
||||||
|
required: [Type]
|
||||||
properties:
|
properties:
|
||||||
Type:
|
Type:
|
||||||
|
x-nullable: false
|
||||||
type: "string"
|
type: "string"
|
||||||
Capabilities:
|
Capabilities:
|
||||||
type: "array"
|
type: "array"
|
||||||
|
@ -1236,24 +1312,19 @@ definitions:
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/PluginDevice"
|
$ref: "#/definitions/PluginDevice"
|
||||||
Env:
|
Env:
|
||||||
type: "object"
|
type: "array"
|
||||||
properties:
|
items:
|
||||||
Name:
|
$ref: "#/definitions/PluginEnv"
|
||||||
type: "string"
|
|
||||||
Description:
|
|
||||||
type: "string"
|
|
||||||
Settable:
|
|
||||||
type: "array"
|
|
||||||
items:
|
|
||||||
type: "string"
|
|
||||||
Value:
|
|
||||||
type: "string"
|
|
||||||
Args:
|
Args:
|
||||||
type: "object"
|
type: "object"
|
||||||
|
x-nullable: false
|
||||||
|
required: [Name, Description, Settable, Value]
|
||||||
properties:
|
properties:
|
||||||
Name:
|
Name:
|
||||||
|
x-nullable: false
|
||||||
type: "string"
|
type: "string"
|
||||||
Description:
|
Description:
|
||||||
|
x-nullable: false
|
||||||
type: "string"
|
type: "string"
|
||||||
Settable:
|
Settable:
|
||||||
type: "array"
|
type: "array"
|
||||||
|
|
|
@ -314,3 +314,12 @@ type TaskListOptions struct {
|
||||||
type PluginRemoveOptions struct {
|
type PluginRemoveOptions struct {
|
||||||
Force bool
|
Force bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PluginInstallOptions holds parameters to install a plugin.
|
||||||
|
type PluginInstallOptions struct {
|
||||||
|
Disabled bool
|
||||||
|
AcceptAllPermissions bool
|
||||||
|
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
|
||||||
|
PrivilegeFunc RequestPrivilegeFunc
|
||||||
|
AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
|
||||||
|
}
|
||||||
|
|
|
@ -1,168 +1,163 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
// This file was generated by the swagger tool.
|
||||||
"encoding/json"
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PluginInstallOptions holds parameters to install a plugin.
|
// Plugin A plugin for the Remote API
|
||||||
type PluginInstallOptions struct {
|
// swagger:model Plugin
|
||||||
Disabled bool
|
|
||||||
AcceptAllPermissions bool
|
|
||||||
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
|
|
||||||
PrivilegeFunc RequestPrivilegeFunc
|
|
||||||
AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginConfig represents the values of settings potentially modifiable by a user
|
|
||||||
type PluginConfig struct {
|
|
||||||
Mounts []PluginMount
|
|
||||||
Env []string
|
|
||||||
Args []string
|
|
||||||
Devices []PluginDevice
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plugin represents a Docker plugin for the remote API
|
|
||||||
type Plugin struct {
|
type Plugin struct {
|
||||||
ID string `json:"Id,omitempty"`
|
|
||||||
Name string
|
// config
|
||||||
Tag string
|
// Required: true
|
||||||
// Enabled is true when the plugin is running, is false when the plugin is not running, only installed.
|
Config PluginConfig `json:"Config"`
|
||||||
Enabled bool
|
|
||||||
Config PluginConfig
|
// True when the plugin is running. False when the plugin is not running, only installed.
|
||||||
Manifest PluginManifest
|
// Required: true
|
||||||
|
Enabled bool `json:"Enabled"`
|
||||||
|
|
||||||
|
// Id
|
||||||
|
ID string `json:"Id,omitempty"`
|
||||||
|
|
||||||
|
// manifest
|
||||||
|
// Required: true
|
||||||
|
Manifest PluginManifest `json:"Manifest"`
|
||||||
|
|
||||||
|
// name
|
||||||
|
// Required: true
|
||||||
|
Name string `json:"Name"`
|
||||||
|
|
||||||
|
// tag
|
||||||
|
// Required: true
|
||||||
|
Tag string `json:"Tag"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PluginsListResponse contains the response for the remote API
|
// PluginConfigSettings that can be modified by users.
|
||||||
type PluginsListResponse []*Plugin
|
// swagger:model PluginConfig
|
||||||
|
type PluginConfig struct {
|
||||||
|
|
||||||
const (
|
// args
|
||||||
authzDriver = "AuthzDriver"
|
// Required: true
|
||||||
graphDriver = "GraphDriver"
|
Args []string `json:"Args"`
|
||||||
ipamDriver = "IpamDriver"
|
|
||||||
networkDriver = "NetworkDriver"
|
|
||||||
volumeDriver = "VolumeDriver"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PluginInterfaceType represents a type that a plugin implements.
|
// devices
|
||||||
type PluginInterfaceType struct {
|
// Required: true
|
||||||
Prefix string // This is always "docker"
|
Devices []PluginDevice `json:"Devices"`
|
||||||
Capability string // Capability should be validated against the above list.
|
|
||||||
Version string // Plugin API version. Depends on the capability
|
// env
|
||||||
|
// Required: true
|
||||||
|
Env []string `json:"Env"`
|
||||||
|
|
||||||
|
// mounts
|
||||||
|
// Required: true
|
||||||
|
Mounts []PluginMount `json:"Mounts"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements json.Unmarshaler for PluginInterfaceType
|
// PluginManifestThe manifest of a plugin.
|
||||||
func (t *PluginInterfaceType) UnmarshalJSON(p []byte) error {
|
// swagger:model PluginManifest
|
||||||
versionIndex := len(p)
|
|
||||||
prefixIndex := 0
|
|
||||||
if len(p) < 2 || p[0] != '"' || p[len(p)-1] != '"' {
|
|
||||||
return fmt.Errorf("%q is not a plugin interface type", p)
|
|
||||||
}
|
|
||||||
p = p[1 : len(p)-1]
|
|
||||||
loop:
|
|
||||||
for i, b := range p {
|
|
||||||
switch b {
|
|
||||||
case '.':
|
|
||||||
prefixIndex = i
|
|
||||||
case '/':
|
|
||||||
versionIndex = i
|
|
||||||
break loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
t.Prefix = string(p[:prefixIndex])
|
|
||||||
t.Capability = string(p[prefixIndex+1 : versionIndex])
|
|
||||||
if versionIndex < len(p) {
|
|
||||||
t.Version = string(p[versionIndex+1:])
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalJSON implements json.Marshaler for PluginInterfaceType
|
|
||||||
func (t *PluginInterfaceType) MarshalJSON() ([]byte, error) {
|
|
||||||
return json.Marshal(t.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
// String implements fmt.Stringer for PluginInterfaceType
|
|
||||||
func (t PluginInterfaceType) String() string {
|
|
||||||
return fmt.Sprintf("%s.%s/%s", t.Prefix, t.Capability, t.Version)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginInterface describes the interface between Docker and plugin
|
|
||||||
type PluginInterface struct {
|
|
||||||
Types []PluginInterfaceType
|
|
||||||
Socket string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginSetting is to be embedded in other structs, if they are supposed to be
|
|
||||||
// modifiable by the user.
|
|
||||||
type PluginSetting struct {
|
|
||||||
Name string
|
|
||||||
Description string
|
|
||||||
Settable []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginNetwork represents the network configuration for a plugin
|
|
||||||
type PluginNetwork struct {
|
|
||||||
Type string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginMount represents the mount configuration for a plugin
|
|
||||||
type PluginMount struct {
|
|
||||||
PluginSetting
|
|
||||||
Source *string
|
|
||||||
Destination string
|
|
||||||
Type string
|
|
||||||
Options []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginEnv represents an environment variable for a plugin
|
|
||||||
type PluginEnv struct {
|
|
||||||
PluginSetting
|
|
||||||
Value *string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginArgs represents the command line arguments for a plugin
|
|
||||||
type PluginArgs struct {
|
|
||||||
PluginSetting
|
|
||||||
Value []string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginDevice represents a device for a plugin
|
|
||||||
type PluginDevice struct {
|
|
||||||
PluginSetting
|
|
||||||
Path *string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginUser represents the user for the plugin's process
|
|
||||||
type PluginUser struct {
|
|
||||||
UID uint32 `json:"Uid,omitempty"`
|
|
||||||
GID uint32 `json:"Gid,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginManifest represents the manifest of a plugin
|
|
||||||
type PluginManifest struct {
|
type PluginManifest struct {
|
||||||
ManifestVersion string
|
|
||||||
Description string
|
// args
|
||||||
Documentation string
|
// Required: true
|
||||||
Interface PluginInterface
|
Args PluginManifestArgs `json:"Args"`
|
||||||
Entrypoint []string
|
|
||||||
Workdir string
|
// capabilities
|
||||||
User PluginUser `json:",omitempty"`
|
// Required: true
|
||||||
Network PluginNetwork
|
Capabilities []string `json:"Capabilities"`
|
||||||
Capabilities []string
|
|
||||||
Mounts []PluginMount
|
// description
|
||||||
Devices []PluginDevice
|
// Required: true
|
||||||
Env []PluginEnv
|
Description string `json:"Description"`
|
||||||
Args PluginArgs
|
|
||||||
|
// devices
|
||||||
|
// Required: true
|
||||||
|
Devices []PluginDevice `json:"Devices"`
|
||||||
|
|
||||||
|
// documentation
|
||||||
|
// Required: true
|
||||||
|
Documentation string `json:"Documentation"`
|
||||||
|
|
||||||
|
// entrypoint
|
||||||
|
// Required: true
|
||||||
|
Entrypoint []string `json:"Entrypoint"`
|
||||||
|
|
||||||
|
// env
|
||||||
|
// Required: true
|
||||||
|
Env []PluginEnv `json:"Env"`
|
||||||
|
|
||||||
|
// interface
|
||||||
|
// Required: true
|
||||||
|
Interface PluginManifestInterface `json:"Interface"`
|
||||||
|
|
||||||
|
// manifest version
|
||||||
|
// Required: true
|
||||||
|
ManifestVersion string `json:"ManifestVersion"`
|
||||||
|
|
||||||
|
// mounts
|
||||||
|
// Required: true
|
||||||
|
Mounts []PluginMount `json:"Mounts"`
|
||||||
|
|
||||||
|
// network
|
||||||
|
// Required: true
|
||||||
|
Network PluginManifestNetwork `json:"Network"`
|
||||||
|
|
||||||
|
// user
|
||||||
|
User PluginManifestUser `json:"User,omitempty"`
|
||||||
|
|
||||||
|
// workdir
|
||||||
|
// Required: true
|
||||||
|
Workdir string `json:"Workdir"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PluginPrivilege describes a permission the user has to accept
|
// PluginManifestArgsplugin manifest args
|
||||||
// upon installing a plugin.
|
// swagger:model PluginManifestArgs
|
||||||
type PluginPrivilege struct {
|
type PluginManifestArgs struct {
|
||||||
Name string
|
|
||||||
Description string
|
// description
|
||||||
Value []string
|
// Required: true
|
||||||
|
Description string `json:"Description"`
|
||||||
|
|
||||||
|
// name
|
||||||
|
// Required: true
|
||||||
|
Name string `json:"Name"`
|
||||||
|
|
||||||
|
// settable
|
||||||
|
// Required: true
|
||||||
|
Settable []string `json:"Settable"`
|
||||||
|
|
||||||
|
// value
|
||||||
|
// Required: true
|
||||||
|
Value []string `json:"Value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PluginPrivileges is a list of PluginPrivilege
|
// PluginManifestInterfaceThe interface between Docker and the plugin
|
||||||
type PluginPrivileges []PluginPrivilege
|
// swagger:model PluginManifestInterface
|
||||||
|
type PluginManifestInterface struct {
|
||||||
|
|
||||||
|
// socket
|
||||||
|
// Required: true
|
||||||
|
Socket string `json:"Socket"`
|
||||||
|
|
||||||
|
// types
|
||||||
|
// Required: true
|
||||||
|
Types []PluginInterfaceType `json:"Types"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PluginManifestNetworkplugin manifest network
|
||||||
|
// swagger:model PluginManifestNetwork
|
||||||
|
type PluginManifestNetwork struct {
|
||||||
|
|
||||||
|
// type
|
||||||
|
// Required: true
|
||||||
|
Type string `json:"Type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PluginManifestUserplugin manifest user
|
||||||
|
// swagger:model PluginManifestUser
|
||||||
|
type PluginManifestUser struct {
|
||||||
|
|
||||||
|
// g ID
|
||||||
|
GID uint32 `json:"GID,omitempty"`
|
||||||
|
|
||||||
|
// UID
|
||||||
|
UID uint32 `json:"UID,omitempty"`
|
||||||
|
}
|
||||||
|
|
25
api/types/plugin_device.go
Normal file
25
api/types/plugin_device.go
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
// PluginDevice plugin device
|
||||||
|
// swagger:model PluginDevice
|
||||||
|
type PluginDevice struct {
|
||||||
|
|
||||||
|
// description
|
||||||
|
// Required: true
|
||||||
|
Description string `json:"Description"`
|
||||||
|
|
||||||
|
// name
|
||||||
|
// Required: true
|
||||||
|
Name string `json:"Name"`
|
||||||
|
|
||||||
|
// path
|
||||||
|
// Required: true
|
||||||
|
Path *string `json:"Path"`
|
||||||
|
|
||||||
|
// settable
|
||||||
|
// Required: true
|
||||||
|
Settable []string `json:"Settable"`
|
||||||
|
}
|
25
api/types/plugin_env.go
Normal file
25
api/types/plugin_env.go
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
// PluginEnv plugin env
|
||||||
|
// swagger:model PluginEnv
|
||||||
|
type PluginEnv struct {
|
||||||
|
|
||||||
|
// description
|
||||||
|
// Required: true
|
||||||
|
Description string `json:"Description"`
|
||||||
|
|
||||||
|
// name
|
||||||
|
// Required: true
|
||||||
|
Name string `json:"Name"`
|
||||||
|
|
||||||
|
// settable
|
||||||
|
// Required: true
|
||||||
|
Settable []string `json:"Settable"`
|
||||||
|
|
||||||
|
// value
|
||||||
|
// Required: true
|
||||||
|
Value *string `json:"Value"`
|
||||||
|
}
|
21
api/types/plugin_interface_type.go
Normal file
21
api/types/plugin_interface_type.go
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
// PluginInterfaceType plugin interface type
|
||||||
|
// swagger:model PluginInterfaceType
|
||||||
|
type PluginInterfaceType struct {
|
||||||
|
|
||||||
|
// capability
|
||||||
|
// Required: true
|
||||||
|
Capability string `json:"Capability"`
|
||||||
|
|
||||||
|
// prefix
|
||||||
|
// Required: true
|
||||||
|
Prefix string `json:"Prefix"`
|
||||||
|
|
||||||
|
// version
|
||||||
|
// Required: true
|
||||||
|
Version string `json:"Version"`
|
||||||
|
}
|
37
api/types/plugin_mount.go
Normal file
37
api/types/plugin_mount.go
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
// This file was generated by the swagger tool.
|
||||||
|
// Editing this file might prove futile when you re-run the swagger generate command
|
||||||
|
|
||||||
|
// PluginMount plugin mount
|
||||||
|
// swagger:model PluginMount
|
||||||
|
type PluginMount struct {
|
||||||
|
|
||||||
|
// description
|
||||||
|
// Required: true
|
||||||
|
Description string `json:"Description"`
|
||||||
|
|
||||||
|
// destination
|
||||||
|
// Required: true
|
||||||
|
Destination string `json:"Destination"`
|
||||||
|
|
||||||
|
// name
|
||||||
|
// Required: true
|
||||||
|
Name string `json:"Name"`
|
||||||
|
|
||||||
|
// options
|
||||||
|
// Required: true
|
||||||
|
Options []string `json:"Options"`
|
||||||
|
|
||||||
|
// settable
|
||||||
|
// Required: true
|
||||||
|
Settable []string `json:"Settable"`
|
||||||
|
|
||||||
|
// source
|
||||||
|
// Required: true
|
||||||
|
Source *string `json:"Source"`
|
||||||
|
|
||||||
|
// type
|
||||||
|
// Required: true
|
||||||
|
Type string `json:"Type"`
|
||||||
|
}
|
64
api/types/plugin_responses.go
Normal file
64
api/types/plugin_responses.go
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PluginsListResponse contains the response for the remote API
|
||||||
|
type PluginsListResponse []*Plugin
|
||||||
|
|
||||||
|
const (
|
||||||
|
authzDriver = "AuthzDriver"
|
||||||
|
graphDriver = "GraphDriver"
|
||||||
|
ipamDriver = "IpamDriver"
|
||||||
|
networkDriver = "NetworkDriver"
|
||||||
|
volumeDriver = "VolumeDriver"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UnmarshalJSON implements json.Unmarshaler for PluginInterfaceType
|
||||||
|
func (t *PluginInterfaceType) UnmarshalJSON(p []byte) error {
|
||||||
|
versionIndex := len(p)
|
||||||
|
prefixIndex := 0
|
||||||
|
if len(p) < 2 || p[0] != '"' || p[len(p)-1] != '"' {
|
||||||
|
return fmt.Errorf("%q is not a plugin interface type", p)
|
||||||
|
}
|
||||||
|
p = p[1 : len(p)-1]
|
||||||
|
loop:
|
||||||
|
for i, b := range p {
|
||||||
|
switch b {
|
||||||
|
case '.':
|
||||||
|
prefixIndex = i
|
||||||
|
case '/':
|
||||||
|
versionIndex = i
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
t.Prefix = string(p[:prefixIndex])
|
||||||
|
t.Capability = string(p[prefixIndex+1 : versionIndex])
|
||||||
|
if versionIndex < len(p) {
|
||||||
|
t.Version = string(p[versionIndex+1:])
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON implements json.Marshaler for PluginInterfaceType
|
||||||
|
func (t *PluginInterfaceType) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(t.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
// String implements fmt.Stringer for PluginInterfaceType
|
||||||
|
func (t PluginInterfaceType) String() string {
|
||||||
|
return fmt.Sprintf("%s.%s/%s", t.Prefix, t.Capability, t.Version)
|
||||||
|
}
|
||||||
|
|
||||||
|
// PluginPrivilege describes a permission the user has to accept
|
||||||
|
// upon installing a plugin.
|
||||||
|
type PluginPrivilege struct {
|
||||||
|
Name string
|
||||||
|
Description string
|
||||||
|
Value []string
|
||||||
|
}
|
||||||
|
|
||||||
|
// PluginPrivileges is a list of PluginPrivilege
|
||||||
|
type PluginPrivileges []PluginPrivilege
|
|
@ -5,4 +5,5 @@ swagger generate model -f api/swagger.yaml \
|
||||||
-t api -m types --skip-validator \
|
-t api -m types --skip-validator \
|
||||||
-n Volume \
|
-n Volume \
|
||||||
-n Port \
|
-n Port \
|
||||||
-n ImageSummary
|
-n ImageSummary \
|
||||||
|
-n Plugin -n PluginDevice -n PluginMount -n PluginEnv -n PluginInterfaceType
|
||||||
|
|
Loading…
Reference in a new issue