Skip to content

Commit

Permalink
Updated docker personality to support API 1.25
Browse files Browse the repository at this point in the history
1. Updated all the backend interfaces within
   vic/lib/apiservers/backends
2. Added hollowed out swarm.go and backends/exec/SwarmBackend.go
3. Updated main.go
4. Added robot scripts for docker secret, checkpoint, deploy, node,
   plugin, service, stack, swarm.
  • Loading branch information
sflxn committed Feb 10, 2017
1 parent f54b6ef commit b74444d
Show file tree
Hide file tree
Showing 54 changed files with 1,358 additions and 209 deletions.
61 changes: 46 additions & 15 deletions cmd/docker/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2017 VMware, Inc. All Rights Reserved.
// Copyright 2016 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.
Expand All @@ -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 2016 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())
}
9 changes: 4 additions & 5 deletions lib/apiservers/engine/backends/cache/image_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,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 @@ -165,7 +164,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))
} else {
config = ic.getImageByNamed(named)
}
Expand All @@ -183,10 +182,10 @@ func (ic *ICache) Get(idOrRef string) (*metadata.ImageConfig, error) {
return copyImageConfig(config), nil
}

func (ic *ICache) getImageByDigest(digest digest.Digest) *metadata.ImageConfig {
func (ic *ICache) getImageByDigest(digest string) *metadata.ImageConfig {
defer trace.End(trace.Begin(""))
var config *metadata.ImageConfig
config, ok := ic.cacheByID[string(digest)]
config, ok := ic.cacheByID[digest]
if !ok {
return nil
}
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 2016 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

0 comments on commit b74444d

Please sign in to comment.