ocid: add config subcommand
This subcommand is so that users can get a nice commented version of the ocid configuration file. This comes from the "current" version of the configuration (allowing somone to get their custom configuration as a file). It also has a --default option. In addition, update the tests to use `ocid config` so that we test this setup (the loading and saving of the options). Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
parent
cd9e7de108
commit
9fb23bf0dc
3 changed files with 118 additions and 31 deletions
|
@ -4,7 +4,6 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/kubernetes-incubator/cri-o/server"
|
||||
|
@ -14,35 +13,7 @@ import (
|
|||
"k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||
)
|
||||
|
||||
const (
|
||||
ocidRoot = "/var/lib/ocid"
|
||||
conmonPath = "/usr/libexec/ocid/conmon"
|
||||
pausePath = "/usr/libexec/ocid/pause"
|
||||
ociConfigPath = "/etc/ocid.conf"
|
||||
)
|
||||
|
||||
// DefaultConfig returns the default configuration for ocid.
|
||||
func DefaultConfig() *server.Config {
|
||||
return &server.Config{
|
||||
RootConfig: server.RootConfig{
|
||||
Root: ocidRoot,
|
||||
SandboxDir: filepath.Join(ocidRoot, "sandboxes"),
|
||||
ContainerDir: filepath.Join(ocidRoot, "containers"),
|
||||
},
|
||||
APIConfig: server.APIConfig{
|
||||
Listen: "/var/run/ocid.sock",
|
||||
},
|
||||
RuntimeConfig: server.RuntimeConfig{
|
||||
Runtime: "/usr/bin/runc",
|
||||
Conmon: conmonPath,
|
||||
SELinux: selinux.SelinuxEnabled(),
|
||||
},
|
||||
ImageConfig: server.ImageConfig{
|
||||
Pause: pausePath,
|
||||
ImageStore: filepath.Join(ocidRoot, "store"),
|
||||
},
|
||||
}
|
||||
}
|
||||
const ociConfigPath = "/etc/ocid.conf"
|
||||
|
||||
func mergeConfig(config *server.Config, ctx *cli.Context) error {
|
||||
// Don't parse the config if the user explicitly set it to "".
|
||||
|
@ -150,6 +121,10 @@ func main() {
|
|||
},
|
||||
}
|
||||
|
||||
app.Commands = []cli.Command{
|
||||
configCommand,
|
||||
}
|
||||
|
||||
app.Before = func(c *cli.Context) error {
|
||||
// Load the configuration file.
|
||||
config := c.App.Metadata["config"].(*server.Config)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue