Merge pull request #805 from baude/config
Make kpod parse configuration file
This commit is contained in:
commit
553521f03f
3 changed files with 16 additions and 5 deletions
|
@ -23,8 +23,6 @@ import (
|
|||
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
||||
)
|
||||
|
||||
const crioConfigPath = "/etc/crio/crio.conf"
|
||||
|
||||
func validateConfig(config *server.Config) error {
|
||||
switch config.ImageVolumes {
|
||||
case libkpod.ImageVolumesMkdir:
|
||||
|
@ -48,7 +46,7 @@ func mergeConfig(config *server.Config, ctx *cli.Context) error {
|
|||
// We don't error out if --config wasn't explicitly set and the
|
||||
// default doesn't exist. But we will log a warning about it, so
|
||||
// the user doesn't miss it.
|
||||
logrus.Warnf("default configuration file does not exist: %s", crioConfigPath)
|
||||
logrus.Warnf("default configuration file does not exist: %s", server.CrioConfigPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +162,7 @@ func main() {
|
|||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "config",
|
||||
Value: crioConfigPath,
|
||||
Value: server.CrioConfigPath,
|
||||
Usage: "path to configuration file",
|
||||
},
|
||||
cli.StringFlag{
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
is "github.com/containers/image/storage"
|
||||
"github.com/containers/storage"
|
||||
"github.com/fatih/camelcase"
|
||||
"github.com/kubernetes-incubator/cri-o/libkpod"
|
||||
"github.com/kubernetes-incubator/cri-o/server"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -40,8 +42,16 @@ func shutdownStores() {
|
|||
|
||||
func getConfig(c *cli.Context) (*libkpod.Config, error) {
|
||||
config := libkpod.DefaultConfig()
|
||||
var configFile string
|
||||
if c.GlobalIsSet("config") {
|
||||
err := config.UpdateFromFile(c.String("config"))
|
||||
configFile = c.GlobalString("config")
|
||||
} else if _, err := os.Stat(server.CrioConfigPath); err == nil {
|
||||
configFile = server.CrioConfigPath
|
||||
}
|
||||
// load and merge the configfile from the commandline or use
|
||||
// the default crio config file
|
||||
if configFile != "" {
|
||||
err := config.UpdateFromFile(configFile)
|
||||
if err != nil {
|
||||
return config, err
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ import (
|
|||
"github.com/kubernetes-incubator/cri-o/libkpod"
|
||||
)
|
||||
|
||||
//CrioConfigPath is the default location for the conf file
|
||||
const CrioConfigPath = "/etc/crio/crio.conf"
|
||||
|
||||
// Config represents the entire set of configuration values that can be set for
|
||||
// the server. This is intended to be loaded from a toml-encoded config file.
|
||||
type Config struct {
|
||||
|
|
Loading…
Reference in a new issue