1
0

backend.go 565 B

123456789101112131415161718192021222324252627282930313233
  1. package example
  2. import (
  3. "context"
  4. "github.com/docker/api/backend"
  5. "github.com/docker/api/containers"
  6. )
  7. type containerService struct{}
  8. func init() {
  9. backend.Register("example", "example", func(ctx context.Context) (interface{}, error) {
  10. return New(), nil
  11. })
  12. }
  13. func New() containers.ContainerService {
  14. return &containerService{}
  15. }
  16. func (cs *containerService) List(ctx context.Context) ([]containers.Container, error) {
  17. return []containers.Container{
  18. {
  19. ID: "id",
  20. Image: "nginx",
  21. },
  22. {
  23. ID: "1234",
  24. Image: "alpine",
  25. },
  26. }, nil
  27. }