Skip to content

Commit 72c3bcf

Browse files
committed
Make plugin emit strongly typed, consumable events
Enables other subsystems to watch actions for a plugin(s). This will be used specifically for implementing plugins on swarm where a swarm controller needs to watch the state of a plugin. Signed-off-by: Brian Goff <[email protected]>
1 parent 9d95740 commit 72c3bcf

37 files changed

Lines changed: 2197 additions & 206 deletions

api/server/router/plugin/backend.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/docker/distribution/reference"
88
enginetypes "github.com/docker/docker/api/types"
99
"github.com/docker/docker/api/types/filters"
10+
"github.com/docker/docker/plugin"
1011
"golang.org/x/net/context"
1112
)
1213

@@ -19,7 +20,7 @@ type Backend interface {
1920
Remove(name string, config *enginetypes.PluginRmConfig) error
2021
Set(name string, args []string) error
2122
Privileges(ctx context.Context, ref reference.Named, metaHeaders http.Header, authConfig *enginetypes.AuthConfig) (enginetypes.PluginPrivileges, error)
22-
Pull(ctx context.Context, ref reference.Named, name string, metaHeaders http.Header, authConfig *enginetypes.AuthConfig, privileges enginetypes.PluginPrivileges, outStream io.Writer) error
23+
Pull(ctx context.Context, ref reference.Named, name string, metaHeaders http.Header, authConfig *enginetypes.AuthConfig, privileges enginetypes.PluginPrivileges, outStream io.Writer, opts ...plugin.CreateOpt) error
2324
Push(ctx context.Context, name string, metaHeaders http.Header, authConfig *enginetypes.AuthConfig, outStream io.Writer) error
2425
Upgrade(ctx context.Context, ref reference.Named, name string, metaHeaders http.Header, authConfig *enginetypes.AuthConfig, privileges enginetypes.PluginPrivileges, outStream io.Writer) error
2526
CreateFromContext(ctx context.Context, tarCtx io.ReadCloser, options *enginetypes.PluginCreateOptions) error

api/server/router/swarm/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func (sr *swarmRouter) swarmLogs(ctx context.Context, w http.ResponseWriter, r *
4444
// maybe should return some context with this error?
4545
return err
4646
}
47-
tty = s.Spec.TaskTemplate.ContainerSpec.TTY || tty
47+
tty = (s.Spec.TaskTemplate.ContainerSpec != nil && s.Spec.TaskTemplate.ContainerSpec.TTY) || tty
4848
}
4949
for _, task := range selector.Tasks {
5050
t, err := sr.backend.GetTask(task)

api/swagger.yaml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,11 +1975,39 @@ definitions:
19751975
description: "User modifiable task configuration."
19761976
type: "object"
19771977
properties:
1978+
PluginSpec:
1979+
type: "object"
1980+
description: "Invalid when specified with `ContainerSpec`."
1981+
properties:
1982+
Name:
1983+
description: "The name or 'alias' to use for the plugin."
1984+
type: "string"
1985+
Remote:
1986+
description: "The plugin image reference to use."
1987+
type: "string"
1988+
Disabled:
1989+
description: "Disable the plugin once scheduled."
1990+
type: "boolean"
1991+
PluginPrivilege:
1992+
type: "array"
1993+
items:
1994+
description: "Describes a permission accepted by the user upon installing the plugin."
1995+
type: "object"
1996+
properties:
1997+
Name:
1998+
type: "string"
1999+
Description:
2000+
type: "string"
2001+
Value:
2002+
type: "array"
2003+
items:
2004+
type: "string"
19782005
ContainerSpec:
19792006
type: "object"
2007+
description: "Invalid when specified with `PluginSpec`."
19802008
properties:
19812009
Image:
1982-
description: "The image name to use for the container."
2010+
description: "The image name to use for the container"
19832011
type: "string"
19842012
Labels:
19852013
description: "User-defined key/value data."

api/types/swarm/runtime/gen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//go:generate protoc -I . --gogofast_out=import_path=github.com/docker/docker/api/types/swarm/runtime:. plugin.proto
2+
3+
package runtime

0 commit comments

Comments
 (0)