Skip to content

Commit c5843b7

Browse files
committed
Initial windows runtime work
Signed-off-by: Kenfe-Mickael Laventure <[email protected]>
1 parent e5c8c56 commit c5843b7

120 files changed

Lines changed: 11155 additions & 593 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ addons:
1515
packages:
1616
- btrfs-tools
1717

18+
env:
19+
- GOOS=windows
20+
- GOOS=linux
21+
1822
install:
1923
- wget https://github.com/google/protobuf/releases/download/v3.1.0/protoc-3.1.0-linux-x86_64.zip -O /tmp/protoc-3.1.0-linux-x86_64.zip
2024
- unzip -o -d /tmp/protobuf /tmp/protoc-3.1.0-linux-x86_64.zip

Makefile

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,29 @@ VERSION=$(shell git describe --match 'v[0-9]*' --dirty='.m' --always)
99

1010
PKG=github.com/containerd/containerd
1111

12+
GOOS ?= $(shell go env GOOS)
13+
WHALE = "🐳"
14+
ONI = "👹"
15+
ifeq ("$(OS)", "Windows_NT")
16+
WHALE="+"
17+
ONI="-"
18+
endif
19+
1220
# Project packages.
1321
PACKAGES=$(shell go list ./... | grep -v /vendor/)
1422
INTEGRATION_PACKAGE=${PKG}/integration
1523
SNAPSHOT_PACKAGES=$(shell go list ./snapshot/...)
1624

1725
# Project binaries.
18-
COMMANDS=ctr containerd containerd-shim protoc-gen-gogoctrd dist ctrd-protobuild
26+
COMMANDS=ctr containerd protoc-gen-gogoctrd dist ctrd-protobuild
27+
ifneq ("$(GOOS)", "windows")
28+
COMMANDS += containerd-shim
29+
endif
1930
BINARIES=$(addprefix bin/,$(COMMANDS))
31+
ifeq ("$(GOOS)", "windows")
32+
BINARY_SUFFIX=".exe"
33+
endif
34+
2035

2136
GO_LDFLAGS=-ldflags "-X $(PKG).Version=$(VERSION) -X $(PKG).Package=$(PKG)"
2237

@@ -36,45 +51,45 @@ AUTHORS: .mailmap .git/HEAD
3651
git log --format='%aN <%aE>' | sort -fu > $@
3752

3853
setup: ## install dependencies
39-
@echo "🐳 $@"
54+
@echo "$(WHALE) $@"
4055
# TODO(stevvooe): Install these from the vendor directory
4156
@go get -u github.com/golang/lint/golint
4257
#@go get -u github.com/kisielk/errcheck
4358
@go get -u github.com/gordonklaus/ineffassign
4459

4560
generate: protos
46-
@echo "🐳 $@"
61+
@echo "$(WHALE) $@"
4762
@PATH=${ROOTDIR}/bin:${PATH} go generate -x ${PACKAGES}
4863

4964
protos: bin/protoc-gen-gogoctrd bin/ctrd-protobuild ## generate protobuf
50-
@echo "🐳 $@"
65+
@echo "$(WHALE) $@"
5166
@PATH=${ROOTDIR}/bin:${PATH} ctrd-protobuild ${PACKAGES}
5267

5368
checkprotos: protos ## check if protobufs needs to be generated again
54-
@echo "🐳 $@"
69+
@echo "$(WHALE) $@"
5570
@test -z "$$(git status --short | grep ".pb.go" | tee /dev/stderr)" || \
5671
((git diff | cat) && \
57-
(echo "👹 please run 'make generate' when making changes to proto files" && false))
72+
(echo "$(ONI) please run 'make generate' when making changes to proto files" && false))
5873

5974
# Depends on binaries because vet will silently fail if it can't load compiled
6075
# imports
6176
vet: binaries ## run go vet
62-
@echo "🐳 $@"
77+
@echo "$(WHALE) $@"
6378
@test -z "$$(go vet ${PACKAGES} 2>&1 | grep -v 'constant [0-9]* not a string in call to Errorf' | egrep -v '(timestamp_test.go|duration_test.go|exit status 1)' | tee /dev/stderr)"
6479

6580
fmt: ## run go fmt
66-
@echo "🐳 $@"
81+
@echo "$(WHALE) $@"
6782
@test -z "$$(gofmt -s -l . | grep -v vendor/ | grep -v ".pb.go$$" | tee /dev/stderr)" || \
68-
(echo "👹 please format Go code with 'gofmt -s -w'" && false)
83+
(echo "$(ONI) please format Go code with 'gofmt -s -w'" && false)
6984
@test -z "$$(find . -path ./vendor -prune -o ! -name timestamp.proto ! -name duration.proto -name '*.proto' -type f -exec grep -Hn -e "^ " {} \; | tee /dev/stderr)" || \
70-
(echo "👹 please indent proto files with tabs only" && false)
85+
(echo "$(ONI) please indent proto files with tabs only" && false)
7186
@test -z "$$(find . -path ./vendor -prune -o -name '*.proto' -type f -exec grep -EHn "[_ ]id = " {} \; | grep -v gogoproto.customname | tee /dev/stderr)" || \
72-
(echo "👹 id fields in proto files must have a gogoproto.customname set" && false)
87+
(echo "$(ONI) id fields in proto files must have a gogoproto.customname set" && false)
7388
@test -z "$$(find . -path ./vendor -prune -o -name '*.proto' -type f -exec grep -Hn "Meta meta = " {} \; | grep -v '(gogoproto.nullable) = false' | tee /dev/stderr)" || \
74-
(echo "👹 meta fields in proto files must have option (gogoproto.nullable) = false" && false)
89+
(echo "$(ONI) meta fields in proto files must have option (gogoproto.nullable) = false" && false)
7590

7691
lint: ## run go lint
77-
@echo "🐳 $@"
92+
@echo "$(WHALE) $@"
7893
@test -z "$$(golint ./... | grep -v vendor/ | grep -v ".pb.go:" | tee /dev/stderr)"
7994

8095
dco: ## dco check
@@ -86,57 +101,57 @@ else
86101
endif
87102

88103
ineffassign: ## run ineffassign
89-
@echo "🐳 $@"
104+
@echo "$(WHALE) $@"
90105
@test -z "$$(ineffassign . | grep -v vendor/ | grep -v ".pb.go:" | tee /dev/stderr)"
91106

92107
#errcheck: ## run go errcheck
93-
# @echo "🐳 $@"
108+
# @echo "$(WHALE) $@"
94109
# @test -z "$$(errcheck ./... | grep -v vendor/ | grep -v ".pb.go:" | tee /dev/stderr)"
95110

96111
build: ## build the go packages
97-
@echo "🐳 $@"
112+
@echo "$(WHALE) $@"
98113
@go build -i -v ${GO_LDFLAGS} ${GO_GCFLAGS} ${PACKAGES}
99114

100115
test: ## run tests, except integration tests and tests that require root
101-
@echo "🐳 $@"
116+
@echo "$(WHALE) $@"
102117
@go test ${TESTFLAGS} $(filter-out ${INTEGRATION_PACKAGE},${PACKAGES})
103118

104119
root-test: ## run tests, except integration tests
105-
@echo "🐳 $@"
120+
@echo "$(WHALE) $@"
106121
@go test ${TESTFLAGS} ${SNAPSHOT_PACKAGES} -test.root
107122

108123
integration: ## run integration tests
109-
@echo "🐳 $@"
124+
@echo "$(WHALE) $@"
110125
@go test ${TESTFLAGS} ${INTEGRATION_PACKAGE}
111126

112127
FORCE:
113128

114129
# Build a binary from a cmd.
115130
bin/%: cmd/% FORCE
116131
@test $$(go list) = "${PKG}" || \
117-
(echo "👹 Please correctly set up your Go build environment. This project must be located at <GOPATH>/src/${PKG}" && false)
118-
@echo "🐳 $@"
119-
@go build -i -o $@ ${GO_LDFLAGS} ${GO_GCFLAGS} ./$<
132+
(echo "$(ONI) Please correctly set up your Go build environment. This project must be located at <GOPATH>/src/${PKG}" && false)
133+
@echo "$(WHALE) $@${BINARY_SUFFIX}"
134+
@go build -i -o $@${BINARY_SUFFIX} ${GO_LDFLAGS} ${GO_GCFLAGS} ./$<
120135

121136
binaries: $(BINARIES) ## build binaries
122-
@echo "🐳 $@"
137+
@echo "$(WHALE) $@"
123138

124139
clean: ## clean up binaries
125-
@echo "🐳 $@"
140+
@echo "$(WHALE) $@"
126141
@rm -f $(BINARIES)
127142

128143
install: ## install binaries
129-
@echo "🐳 $@ $(BINARIES)"
144+
@echo "$(WHALE) $@ $(BINARIES)"
130145
@mkdir -p $(DESTDIR)/bin
131146
@install $(BINARIES) $(DESTDIR)/bin
132147

133148
uninstall:
134-
@echo "🐳 $@"
149+
@echo "$(WHALE) $@"
135150
@rm -f $(addprefix $(DESTDIR)/bin/,$(notdir $(BINARIES)))
136151

137152

138153
coverage: ## generate coverprofiles from the unit tests, except tests that require root
139-
@echo "🐳 $@"
154+
@echo "$(WHALE) $@"
140155
@rm -f coverage.txt
141156
( for pkg in $(filter-out ${INTEGRATION_PACKAGE},${PACKAGES}); do \
142157
go test -i ${TESTFLAGS} -test.short -coverprofile=coverage.out -covermode=atomic $$pkg || exit; \
@@ -152,18 +167,18 @@ coverage: ## generate coverprofiles from the unit tests, except tests that requi
152167
done )
153168

154169
root-coverage: ## generae coverage profiles for the unit tests
155-
@echo "🐳 $@"
170+
@echo "$(WHALE) $@"
156171
@( for pkg in ${SNAPSHOT_PACKAGES}; do \
157172
go test -i ${TESTFLAGS} -test.short -coverprofile="../../../$$pkg/coverage.txt" -covermode=atomic $$pkg -test.root || exit; \
158173
go test ${TESTFLAGS} -test.short -coverprofile="../../../$$pkg/coverage.txt" -covermode=atomic $$pkg -test.root || exit; \
159174
done )
160175

161176
coverage-integration: ## generate coverprofiles from the integration tests
162-
@echo "🐳 $@"
177+
@echo "$(WHALE) $@"
163178
go test ${TESTFLAGS} -test.short -coverprofile="../../../${INTEGRATION_PACKAGE}/coverage.txt" -covermode=atomic ${INTEGRATION_PACKAGE}
164179

165180
vendor:
166-
@echo "🐳 $@"
181+
@echo "$(WHALE) $@"
167182
@vndr
168183

169184
help: ## this help
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build !windows
2+
13
package main
24

35
import (

cmd/containerd/builtins.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@ package main
22

33
// register containerd builtins here
44
import (
5-
_ "github.com/containerd/containerd/linux"
6-
_ "github.com/containerd/containerd/metrics/cgroups"
75
_ "github.com/containerd/containerd/services/content"
86
_ "github.com/containerd/containerd/services/execution"
97
_ "github.com/containerd/containerd/services/healthcheck"
108
_ "github.com/containerd/containerd/services/images"
119
_ "github.com/containerd/containerd/services/metrics"
1210
_ "github.com/containerd/containerd/services/rootfs"
13-
_ "github.com/containerd/containerd/snapshot/btrfs"
14-
_ "github.com/containerd/containerd/snapshot/overlay"
1511
)

cmd/containerd/builtins_linux.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package main
2+
3+
import (
4+
_ "github.com/containerd/containerd/linux"
5+
_ "github.com/containerd/containerd/metrics/cgroups"
6+
_ "github.com/containerd/containerd/snapshot/btrfs"
7+
_ "github.com/containerd/containerd/snapshot/overlay"
8+
)

cmd/containerd/builtins_windows.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package main
2+
3+
import (
4+
_ "github.com/containerd/containerd/snapshot/windows"
5+
_ "github.com/containerd/containerd/windows"
6+
)

cmd/containerd/config.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,6 @@ import (
77
"github.com/BurntSushi/toml"
88
)
99

10-
func defaultConfig() *config {
11-
return &config{
12-
Root: "/var/lib/containerd",
13-
State: "/run/containerd",
14-
GRPC: grpcConfig{
15-
Socket: "/run/containerd/containerd.sock",
16-
},
17-
Debug: debug{
18-
Level: "info",
19-
Socket: "/run/containerd/debug.sock",
20-
},
21-
Snapshotter: "overlay",
22-
}
23-
}
24-
2510
// loadConfig loads the config from the provided path
2611
func loadConfig(path string) error {
2712
md, err := toml.DecodeFile(path, conf)
@@ -73,14 +58,14 @@ func (c *config) WriteTo(w io.Writer) (int64, error) {
7358
}
7459

7560
type grpcConfig struct {
76-
Socket string `toml:"socket"`
77-
Uid int `toml:"uid"`
78-
Gid int `toml:"gid"`
61+
Address string `toml:"address"`
62+
Uid int `toml:"uid"`
63+
Gid int `toml:"gid"`
7964
}
8065

8166
type debug struct {
82-
Socket string `toml:"socket"`
83-
Level string `toml:"level"`
67+
Address string `toml:"address"`
68+
Level string `toml:"level"`
8469
}
8570

8671
type metricsConfig struct {

cmd/containerd/config_unix.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// +build !windows
2+
3+
package main
4+
5+
func defaultConfig() *config {
6+
return &config{
7+
Root: "/var/lib/containerd",
8+
State: "/run/containerd",
9+
GRPC: grpcConfig{
10+
Address: "/run/containerd/containerd.sock",
11+
},
12+
Debug: debug{
13+
Level: "info",
14+
Address: "/run/containerd/debug.sock",
15+
},
16+
Snapshotter: "overlay",
17+
}
18+
}

cmd/containerd/config_windows.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package main
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
)
7+
8+
func defaultConfig() *config {
9+
return &config{
10+
Root: filepath.Join(os.Getenv("programfiles"), "containerd", "root"),
11+
State: filepath.Join(os.Getenv("programfiles"), "containerd", "state"),
12+
GRPC: grpcConfig{
13+
Address: `\\.\pipe\containerd-containerd`,
14+
},
15+
Debug: debug{
16+
Level: "info",
17+
Address: `\\.\pipe\containerd-debug`,
18+
},
19+
Snapshotter: "windows",
20+
}
21+
}

0 commit comments

Comments
 (0)