Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Docker Personality to support Docker API 1.25 [full ci] #3756

Merged
merged 2 commits into from
Feb 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
59 changes: 45 additions & 14 deletions cmd/docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,23 @@ import (

log "github.com/Sirupsen/logrus"
apiserver "github.com/docker/docker/api/server"
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/api/server/router/container"
"github.com/docker/docker/api/server/router/image"
"github.com/docker/docker/api/server/router/network"
"github.com/docker/docker/api/server/router/swarm"
"github.com/docker/docker/api/server/router/system"
"github.com/docker/docker/api/server/router/volume"
"github.com/docker/docker/docker/listeners"
"github.com/docker/docker/api/server/router/checkpoint"
"github.com/docker/docker/api/server/router/plugin"
"github.com/docker/docker/daemon/cluster"
"github.com/docker/docker/pkg/listeners"
"github.com/docker/docker/pkg/signal"
"github.com/docker/docker/runconfig"
"github.com/docker/go-connections/tlsconfig"

vicbackends "github.com/vmware/vic/lib/apiservers/engine/backends"
"github.com/vmware/vic/lib/apiservers/engine/backends/executor"
"github.com/vmware/vic/lib/config"
"github.com/vmware/vic/lib/pprof"
viclog "github.com/vmware/vic/pkg/log"
Expand Down Expand Up @@ -169,7 +176,7 @@ func startServerWithOptions(cli *CliOptions) *apiserver.Server {
MaxVersion: c.MaxVersion,
CurvePreferences: c.CurvePreferences,
}
}(&tlsconfig.ServerDefault)
}(tlsconfig.ServerDefault())

if !vchConfig.HostCertificate.IsNil() {
log.Info("TLS enabled")
Expand Down Expand Up @@ -230,16 +237,40 @@ func startServerWithOptions(cli *CliOptions) *apiserver.Server {
}

func setAPIRoutes(api *apiserver.Server) {
imageHandler := &vicbackends.Image{}
containerHandler := vicbackends.NewContainerBackend()
volumeHandler := &vicbackends.Volume{}
networkHandler := &vicbackends.Network{}
systemHandler := vicbackends.NewSystemBackend()

api.InitRouter(false,
image.NewRouter(imageHandler),
container.NewRouter(containerHandler),
volume.NewRouter(volumeHandler),
network.NewRouter(networkHandler),
system.NewRouter(systemHandler))
decoder := runconfig.ContainerDecoder{}

swarmBackend := executor.SwarmBackend{}

c, err := cluster.New(cluster.Config{
Root: "",
Name: "",
Backend: swarmBackend,
NetworkSubnetsProvider: nil,
DefaultAdvertiseAddr: "",
RuntimeRoot: "",
})
if err != nil {
log.Fatalf("Error creating cluster component: %v", err)
}

routers := []router.Router{
image.NewRouter(vicbackends.NewImageBackend(), decoder),
container.NewRouter(vicbackends.NewContainerBackend(), decoder),
volume.NewRouter(vicbackends.NewVolumeBackend()),
network.NewRouter(vicbackends.NewNetworkBackend(), c),
system.NewRouter(vicbackends.NewSystemBackend(), c),
swarm.NewRouter(vicbackends.NewSwarmBackend()),
checkpoint.NewRouter(vicbackends.NewCheckpointBackend(), decoder),
plugin.NewRouter(vicbackends.NewPluginBackend()),
}

for _, r := range routers {
for _, route := range r.Routes() {
if experimental, ok := route.(router.ExperimentalRoute); ok {
experimental.Enable()
}
}
}

api.InitRouter(false, routers...)
}
4 changes: 2 additions & 2 deletions cmd/vicadmin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"context"

log "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/tlsconfig"
"github.com/docker/go-connections/tlsconfig"
"github.com/google/uuid"
gorillacontext "github.com/gorilla/context"

Expand Down Expand Up @@ -133,7 +133,7 @@ func (s *server) listen() error {
MaxVersion: c.MaxVersion,
CurvePreferences: c.CurvePreferences,
}
}(&tlsconfig.ServerDefault)
}(tlsconfig.ServerDefault())

tlsconfig.Certificates = []tls.Certificate{*certificate}

Expand Down
69 changes: 69 additions & 0 deletions demos/compose/voting-app/votingapp.dab
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"Services": {
"db": {
"Env": [
"PGDATA=/var/lib/postgresql/data/data"
],
"Image": "postgres@sha256:9db811348585075eddb7b6938fa65c0236fe8e4f7feaf3c2890a3c4b7f4c9bfc",
"Networks": [
"default"
]
},
"redis": {
"Image": "redis@sha256:f1ed3708f538b537eb9c2a7dd50dc90a706f7debd7e1196c9264edeea521a86d",
"Networks": [
"default"
],
"Ports": [
{
"Port": 6379,
"Protocol": "tcp"
}
]
},
"result": {
"Args": [
"nodemon",
"--debug",
"server.js"
],
"Image": "victest/vote-result@sha256:413fcc5d11e4426d9e5ec512056aeeb7fa83acc61eec2ed6346e8d30d56b7ae7",
"Networks": [
"default"
],
"Ports": [
{
"Port": 80,
"Protocol": "tcp"
},
{
"Port": 5858,
"Protocol": "tcp"
}
]
},
"vote": {
"Args": [
"python",
"app.py"
],
"Image": "victest/vote@sha256:13037f3373a3b10dfeac4f323b38a215d9665d88d72b1bb5fe7baef83c3b34ad",
"Networks": [
"default"
],
"Ports": [
{
"Port": 80,
"Protocol": "tcp"
}
]
},
"worker": {
"Image": "victest/vote-worker@sha256:70cc69d1e91b8c23bbfd7515572c804c8b954c227da0e55e1131c367929f79dd",
"Networks": [
"default"
]
}
},
"Version": "0.1"
}
32 changes: 32 additions & 0 deletions lib/apiservers/engine/backends/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package backends

import (
"fmt"
"io"

"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"golang.org/x/net/context"
)

type Builder struct {

}

func (b *Builder) BuildFromContext(ctx context.Context, src io.ReadCloser, remote string, buildOptions *types.ImageBuildOptions, pg backend.ProgressWriter) (string, error) {
return "", fmt.Errorf("%s does not yet implement BuildFromContext", ProductName())
}
3 changes: 2 additions & 1 deletion lib/apiservers/engine/backends/cache/image_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
log "github.com/Sirupsen/logrus"

"github.com/docker/distribution/digest"
derr "github.com/docker/docker/errors"
derr "github.com/docker/docker/api/errors"
"github.com/docker/docker/pkg/truncindex"
"github.com/docker/docker/reference"

Expand Down Expand Up @@ -166,6 +166,7 @@ func (ic *ICache) Get(idOrRef string) (*metadata.ImageConfig, error) {
var config *metadata.ImageConfig
if imgDigest != "" {
config = ic.getImageByDigest(imgDigest)
// config = ic.getImageByDigest(string(imgDigest))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented code

} else {
config = ic.getImageByNamed(named)
}
Expand Down
40 changes: 40 additions & 0 deletions lib/apiservers/engine/backends/checkpoint.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright 2017 VMware, Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package backends

import (
"fmt"

"github.com/docker/docker/api/types"
)

type Checkpoint struct {
}

func NewCheckpointBackend() *Checkpoint {
return &Checkpoint{}
}

func (c *Checkpoint) CheckpointCreate(container string, config types.CheckpointCreateOptions) error {
return fmt.Errorf("%s does not yet implement checkpointing", ProductName())
}

func (c *Checkpoint) CheckpointDelete(container string, config types.CheckpointDeleteOptions) error {
return fmt.Errorf("%s does not yet implement checkpointing", ProductName())
}

func (c *Checkpoint) CheckpointList(container string, config types.CheckpointListOptions) ([]types.Checkpoint, error) {
return nil, fmt.Errorf("%s does not yet implement checkpointing", ProductName())
}
Loading