Files
linuxkit/vendor/github.com/docker/infrakit/pkg/discovery/local/local.go
Rolf Neugebauer 2ab909fcbd vendor: Update to a new version of InfraKit
This pulls in another slew of other packages.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
2017-04-04 16:07:53 +01:00

34 lines
690 B
Go

package local
import (
"fmt"
"github.com/docker/infrakit/pkg/discovery"
logutil "github.com/docker/infrakit/pkg/log"
"github.com/spf13/afero"
)
// Setup sets up the necessary environment for running this module -- ie make sure
// the CLI module directories are present, etc.
func Setup() error {
dir := Dir()
if dir == "" {
return fmt.Errorf("Env not set:%s", discovery.PluginDirEnvVar)
}
fs := afero.NewOsFs()
exists, err := afero.Exists(fs, dir)
if err != nil {
return err
}
if !exists {
log.Warn("Creating directory", "dir", dir)
err = fs.MkdirAll(dir, 0600)
if err != nil {
return err
}
}
return nil
}
var log = logutil.New("module", "discovery/local")