Use defaults pkg for all platforms

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2017-11-28 18:04:21 -08:00
parent 90a6b79bfc
commit 6bf779c589
No known key found for this signature in database
GPG Key ID: 40CF16616B361216
8 changed files with 45 additions and 50 deletions

View File

@ -2,18 +2,21 @@
package main package main
import "github.com/containerd/containerd/server" import (
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/server"
)
func defaultConfig() *server.Config { func defaultConfig() *server.Config {
return &server.Config{ return &server.Config{
Root: server.DefaultRootDir, Root: defaults.DefaultRootDir,
State: server.DefaultStateDir, State: defaults.DefaultStateDir,
GRPC: server.GRPCConfig{ GRPC: server.GRPCConfig{
Address: server.DefaultAddress, Address: defaults.DefaultAddress,
}, },
Debug: server.Debug{ Debug: server.Debug{
Level: "info", Level: "info",
Address: server.DefaultDebugAddress, Address: defaults.DefaultDebugAddress,
}, },
} }
} }

View File

@ -1,17 +1,20 @@
package main package main
import "github.com/containerd/containerd/server" import (
"github.com/containerd/containerd/defaults"
"github.com/containerd/containerd/server"
)
func defaultConfig() *server.Config { func defaultConfig() *server.Config {
return &server.Config{ return &server.Config{
Root: server.DefaultRootDir, Root: defaults.DefaultRootDir,
State: server.DefaultStateDir, State: defaults.DefaultStateDir,
GRPC: server.GRPCConfig{ GRPC: server.GRPCConfig{
Address: server.DefaultAddress, Address: defaults.DefaultAddress,
}, },
Debug: server.Debug{ Debug: server.Debug{
Level: "info", Level: "info",
Address: server.DefaultDebugAddress, Address: defaults.DefaultDebugAddress,
}, },
} }
} }

View File

@ -1,5 +1,5 @@
// Package defaults provides several common defaults for interacting wtih // +build !windows
// containerd. These can be used on the client-side or server-side.
package defaults package defaults
const ( const (

View File

@ -0,0 +1,24 @@
// +build windows
package defaults
import (
"os"
"path/filepath"
)
var (
// DefaultRootDir is the default location used by containerd to store
// persistent data
DefaultRootDir = filepath.Join(os.Getenv("programfiles"), "containerd", "root")
// DefaultStateDir is the default location used by containerd to store
// transient data
DefaultStateDir = filepath.Join(os.Getenv("programfiles"), "containerd", "state")
)
const (
// DefaultAddress is the default winpipe address
DefaultAddress = `\\.\pipe\containerd-containerd`
// DefaultDebugAddress is the default winpipe address for pprof data
DefaultDebugAddress = `\\.\pipe\containerd-debug`
)

3
defaults/doc.go Normal file
View File

@ -0,0 +1,3 @@
// Package defaults provides several common defaults for interacting wtih
// containerd. These can be used on the client-side or server-side.
package defaults

View File

@ -2,13 +2,6 @@ package server
import "context" import "context"
const (
// DefaultAddress is the default unix socket address
DefaultAddress = "/var/run/containerd/containerd.sock"
// DefaultDebugAddress is the default unix socket address for pprof data
DefaultDebugAddress = "/var/run/containerd/debug.sock"
)
func apply(_ context.Context, _ *Config) error { func apply(_ context.Context, _ *Config) error {
return nil return nil
} }

View File

@ -4,19 +4,6 @@ package server
import "context" import "context"
const (
// DefaultRootDir is the default location used by containerd to store
// persistent data
DefaultRootDir = "/var/lib/containerd"
// DefaultStateDir is the default location used by containerd to store
// transient data
DefaultStateDir = "/run/containerd"
// DefaultAddress is the default unix socket address
DefaultAddress = "/run/containerd/containerd.sock"
// DefaultDebugAddress is the default unix socket address for pprof data
DefaultDebugAddress = "/run/containerd/debug.sock"
)
func apply(_ context.Context, _ *Config) error { func apply(_ context.Context, _ *Config) error {
return nil return nil
} }

View File

@ -4,24 +4,6 @@ package server
import ( import (
"context" "context"
"os"
"path/filepath"
)
var (
// DefaultRootDir is the default location used by containerd to store
// persistent data
DefaultRootDir = filepath.Join(os.Getenv("programfiles"), "containerd", "root")
// DefaultStateDir is the default location used by containerd to store
// transient data
DefaultStateDir = filepath.Join(os.Getenv("programfiles"), "containerd", "state")
)
const (
// DefaultAddress is the default winpipe address
DefaultAddress = `\\.\pipe\containerd-containerd`
// DefaultDebugAddress is the default winpipe address for pprof data
DefaultDebugAddress = `\\.\pipe\containerd-debug`
) )
func apply(_ context.Context, _ *Config) error { func apply(_ context.Context, _ *Config) error {