Move the proxy in the server package

This commit is contained in:
Djordje Lukic 2020-04-29 23:44:01 +02:00
Родитель 8571cf5a04
Коммит 0af5afe440
5 изменённых файлов: 12 добавлений и 9 удалений

Просмотреть файл

@ -30,15 +30,15 @@ func getter() interface{} {
func New(ctx context.Context) (containers.ContainerService, error) { func New(ctx context.Context) (containers.ContainerService, error) {
cc := apicontext.CurrentContext(ctx) cc := apicontext.CurrentContext(ctx)
s, err := store.New() contextStore, err := store.New()
if err != nil { if err != nil {
return nil, err return nil, err
} }
m, err := s.Get(cc, getter) metadata, err := contextStore.Get(cc, getter)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "wrong context type") return nil, errors.Wrap(err, "wrong context type")
} }
tc, _ := m.Metadata.Data.(store.AciContext) tc, _ := metadata.Metadata.Data.(store.AciContext)
auth, _ := auth.NewAuthorizerFromCLI() auth, _ := auth.NewAuthorizerFromCLI()
containerGroupsClient := containerinstance.NewContainerGroupsClient(tc.SubscriptionID) containerGroupsClient := containerinstance.NewContainerGroupsClient(tc.SubscriptionID)

Просмотреть файл

@ -5,10 +5,10 @@ import (
"net" "net"
cliv1 "github.com/docker/api/cli/v1" cliv1 "github.com/docker/api/cli/v1"
"github.com/docker/api/containers/proxy"
containersv1 "github.com/docker/api/containers/v1" containersv1 "github.com/docker/api/containers/v1"
"github.com/docker/api/context/store" "github.com/docker/api/context/store"
"github.com/docker/api/server" "github.com/docker/api/server"
"github.com/docker/api/server/proxy"
"github.com/golang/protobuf/ptypes/empty" "github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -38,11 +38,11 @@ func ServeCommand() *cobra.Command {
func runServe(ctx context.Context, opts serveOpts) error { func runServe(ctx context.Context, opts serveOpts) error {
s := server.New() s := server.New()
l, err := net.Listen("unix", opts.address) listener, err := net.Listen("unix", opts.address)
if err != nil { if err != nil {
return errors.Wrap(err, "listen unix socket") return errors.Wrap(err, "listen unix socket")
} }
defer l.Close() defer listener.Close()
p := proxy.NewContainerApi() p := proxy.NewContainerApi()
@ -60,7 +60,7 @@ func runServe(ctx context.Context, opts serveOpts) error {
logrus.WithField("address", opts.address).Info("serving daemon API") logrus.WithField("address", opts.address).Info("serving daemon API")
// start the GRPC server to serve on the listener // start the GRPC server to serve on the listener
return s.Serve(l) return s.Serve(listener)
} }
type cliServer struct { type cliServer struct {

Просмотреть файл

@ -114,8 +114,11 @@ func (s *store) Get(name string, getter func() interface{}) (*Metadata, error) {
meta := filepath.Join(s.root, contextsDir, metadataDir, contextdirOf(name), metaFile) meta := filepath.Join(s.root, contextsDir, metadataDir, contextdirOf(name), metaFile)
m, err := read(meta, getter) m, err := read(meta, getter)
if os.IsNotExist(err) { if os.IsNotExist(err) {
return nil, fmt.Errorf("unknown conetxt %q", name) return nil, fmt.Errorf("unknown context %q", name)
} else if err != nil {
return nil, err
} }
return m, nil return m, nil
} }

Просмотреть файл

Просмотреть файл

@ -32,9 +32,9 @@ import (
"errors" "errors"
"github.com/docker/api/client" "github.com/docker/api/client"
"github.com/docker/api/containers/proxy"
apicontext "github.com/docker/api/context" apicontext "github.com/docker/api/context"
"github.com/docker/api/context/store" "github.com/docker/api/context/store"
"github.com/docker/api/server/proxy"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus" grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/health" "google.golang.org/grpc/health"