本文整理汇总了Golang中github.com/cloudfoundry/bosh-utils/system.NewOsFileSystem函数的典型用法代码示例。如果您正苦于以下问题:Golang NewOsFileSystem函数的具体用法?Golang NewOsFileSystem怎么用?Golang NewOsFileSystem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewOsFileSystem函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: runAgent
func runAgent(logger logger.Logger) chan error {
errCh := make(chan error, 1)
go func() {
defer logger.HandlePanic("Main")
logger.Debug(mainLogTag, "Starting agent")
fs := boshsys.NewOsFileSystem(logger)
app := boshapp.New(logger, fs)
err := app.Setup(os.Args)
if err != nil {
logger.Error(mainLogTag, "App setup %s", err.Error())
errCh <- err
return
}
err = app.Run()
if err != nil {
logger.Error(mainLogTag, "App run %s", err.Error())
errCh <- err
return
}
}()
return errCh
}
开发者ID:mattcui,项目名称:bosh-agent,代码行数:26,代码来源:agent.go
示例2: basicDeps
func basicDeps() (boshlog.Logger, boshsys.FileSystem, boshsys.CmdRunner) {
logger := boshlog.NewWriterLogger(boshlog.LevelDebug, os.Stderr, os.Stderr)
fs := boshsys.NewOsFileSystem(logger)
cmdRunner := boshsys.NewExecCmdRunner(logger)
return logger, fs, cmdRunner
}
开发者ID:CloudCredo,项目名称:bosh-lattice-cpi,代码行数:9,代码来源:main.go
示例3: basicDeps
func basicDeps() (boshlog.Logger, boshsys.FileSystem, boshsys.CmdRunner, boshuuid.Generator) {
logger := boshlog.NewWriterLogger(boshlog.LevelDebug, os.Stderr, os.Stderr)
fs := boshsys.NewOsFileSystem(logger)
runner := boshsys.NewExecCmdRunner(logger)
uuidGen := boshuuid.NewGenerator()
return logger, fs, runner, uuidGen
}
开发者ID:pcfdev-forks,项目名称:bosh-provisioner,代码行数:11,代码来源:main.go
示例4: newSignalableFileLogger
func newSignalableFileLogger(logPath string, level boshlog.LogLevel) boshlog.Logger {
// Log file logger errors to the STDERR logger
logger := boshlog.NewLogger(boshlog.LevelError)
fileSystem := boshsys.NewOsFileSystem(logger)
// log file will be closed by process exit
// log file readable by all
logfileLogger, _, err := boshlogfile.New(level, logPath, boshlogfile.DefaultLogFileMode, fileSystem)
if err != nil {
logger := boshlog.NewLogger(boshlog.LevelError)
ui := biui.NewConsoleUI(logger)
fail(err, ui, logger, nil)
}
return newSignalableLogger(logfileLogger)
}
开发者ID:mattcui,项目名称:bosh-init,代码行数:15,代码来源:main.go
示例5: main
func main() {
logger := newSignalableLogger(boshlog.NewLogger(boshlog.LevelDebug))
defer logger.HandlePanic("Main")
logger.Debug(mainLogTag, "Starting agent")
fs := boshsys.NewOsFileSystem(logger)
app := boshapp.New(logger, fs)
err := app.Setup(os.Args)
if err != nil {
logger.Error(mainLogTag, "App setup %s", err.Error())
os.Exit(1)
}
err = app.Run()
if err != nil {
logger.Error(mainLogTag, "App run %s", err.Error())
os.Exit(1)
}
}
开发者ID:EMC-CMD,项目名称:bosh-agent,代码行数:22,代码来源:agent.go
示例6:
. "github.com/onsi/gomega"
)
var _ = Describe("Blob Manager", func() {
var (
fs boshsys.FileSystem
logger boshlog.Logger
basePath string
blobPath string
blobId string
toWrite io.Reader
)
BeforeEach(func() {
logger = boshlog.NewLogger(boshlog.LevelNone)
fs = boshsys.NewOsFileSystem(logger)
blobId = "105d33ae-655c-493d-bf9f-1df5cf3ca847"
basePath = os.TempDir()
blobPath = filepath.Join(basePath, blobId)
toWrite = bytes.NewReader([]byte("new data"))
})
readFile := func(fileIO boshsys.File) []byte {
fileStat, _ := fileIO.Stat()
fileBytes := make([]byte, fileStat.Size())
fileIO.Read(fileBytes)
return fileBytes
}
It("fetches", func() {
blobManager := NewBlobManager(fs, basePath)
开发者ID:jianqiu,项目名称:bosh-agent,代码行数:31,代码来源:blob_manager_test.go
示例7: init
func init() {
Describe("App", func() {
var (
baseDir string
agentConfPath string
agentConfJSON string
app App
)
BeforeEach(func() {
var err error
baseDir, err = ioutil.TempDir("", "go-agent-test")
Expect(err).ToNot(HaveOccurred())
err = os.Mkdir(filepath.Join(baseDir, "bosh"), os.ModePerm)
Expect(err).ToNot(HaveOccurred())
})
BeforeEach(func() {
agentConfPath = filepath.Join(baseDir, "bosh", "agent.json")
agentConfJSON = `{
"Infrastructure": { "Settings": { "Sources": [{ "Type": "CDROM", "FileName": "/fake-file-name" }] } }
}`
settingsPath := filepath.Join(baseDir, "bosh", "settings.json")
settingsJSON := `{
"agent_id": "my-agent-id",
"blobstore": {
"options": {
"bucket_name": "george",
"encryption_key": "optional encryption key",
"access_key_id": "optional access key id",
"secret_access_key": "optional secret access key"
},
"provider": "dummy"
},
"disks": {
"ephemeral": "/dev/sdb",
"persistent": {
"vol-xxxxxx": "/dev/sdf"
},
"system": "/dev/sda1"
},
"env": {
"bosh": {
"password": "some encrypted password"
}
},
"networks": {
"netA": {
"default": ["dns", "gateway"],
"ip": "ww.ww.ww.ww",
"dns": [
"xx.xx.xx.xx",
"yy.yy.yy.yy"
]
},
"netB": {
"dns": [
"zz.zz.zz.zz"
]
}
},
"Mbus": "https://vcap:[email protected]:6868",
"ntp": [
"0.north-america.pool.ntp.org",
"1.north-america.pool.ntp.org"
],
"vm": {
"name": "vm-abc-def"
}
}`
err := ioutil.WriteFile(settingsPath, []byte(settingsJSON), 0640)
Expect(err).ToNot(HaveOccurred())
})
JustBeforeEach(func() {
err := ioutil.WriteFile(agentConfPath, []byte(agentConfJSON), 0640)
Expect(err).ToNot(HaveOccurred())
logger := boshlog.NewLogger(boshlog.LevelNone)
fakefs := boshsys.NewOsFileSystem(logger)
app = New(logger, fakefs)
})
AfterEach(func() {
os.RemoveAll(baseDir)
})
It("Sets up device path resolver on platform specific to infrastructure", func() {
err := app.Setup([]string{"bosh-agent", "-P", "dummy", "-C", agentConfPath, "-b", baseDir})
Expect(err).ToNot(HaveOccurred())
Expect(app.GetPlatform().GetDevicePathResolver()).To(Equal(devicepathresolver.NewIdentityDevicePathResolver()))
})
//.........这里部分代码省略.........
开发者ID:mattcui,项目名称:bosh-agent,代码行数:101,代码来源:app_test.go
示例8: NewDnsUpdater
func NewDnsUpdater(cfg config.Config, log logger.Logger) *DnsUpdater {
fs := system.NewOsFileSystem(log)
cmdRunner := system.NewExecCmdRunner(log)
return &DnsUpdater{cfg: cfg, logger: log, fs: fs, cmdRunner: cmdRunner}
}
开发者ID:nimbus-cloud,项目名称:postgresql-boshrelease,代码行数:5,代码来源:dns.go
示例9: loadConfig
func (app *app) loadConfig(path string) (Config, error) {
// Use one off copy of file system to read configuration file
fs := boshsys.NewOsFileSystem(app.logger)
return LoadConfigFromPath(fs, path)
}
开发者ID:uzzz,项目名称:bosh-agent,代码行数:5,代码来源:app.go
示例10:
"github.com/cloudfoundry/bosh-init/installation"
"github.com/cloudfoundry/bosh-utils/logger"
"github.com/cloudfoundry/bosh-utils/system"
"github.com/cloudfoundry/bosh-utils/system/fakes"
"github.com/onsi/gomega/gbytes"
)
var _ = Describe("Uninstaller", func() {
Describe("Uninstall", func() {
It("deletes the installation target directory", func() {
logBuffer := gbytes.NewBuffer()
goLogger := log.New(logBuffer, "", log.LstdFlags)
boshlogger := logger.New(logger.LevelInfo, goLogger, goLogger)
fs := system.NewOsFileSystem(boshlogger)
installationPath, err := fs.TempDir("some-installation-dir")
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFileString(filepath.Join(installationPath, "some-installation-artifact"), "something-blah")
Expect(err).ToNot(HaveOccurred())
installationTarget := installation.NewTarget(installationPath)
uninstaller := installation.NewUninstaller(fs, boshlogger)
Expect(fs.FileExists(installationPath)).To(BeTrue())
err = uninstaller.Uninstall(installationTarget)
Expect(err).ToNot(HaveOccurred())
开发者ID:mattcui,项目名称:bosh-init,代码行数:29,代码来源:uninstaller_test.go
示例11: main
func main() {
if len(os.Args) < 2 || len(os.Args) > 3 {
println("Usage: blt path/to/config.json [path/to/state.json]")
os.Exit(1)
}
logger := boshlog.NewLogger(boshlog.LevelDebug)
fs := boshsys.NewOsFileSystem(logger)
cmdRunner := boshsys.NewExecCmdRunner(logger)
config := bltconfig.NewConfig(fs)
err := config.Load(os.Args[1])
if err != nil {
panic(err)
}
assetsProvider := bltassets.NewProvider(config.AssetsPath)
logger.Debug("main", "Setting up environment")
environmentProvider := bltenv.NewProvider(config, fs, cmdRunner, assetsProvider)
environment := environmentProvider.Get()
err = environment.Setup()
if err != nil {
panic(err)
}
defer environment.Shutdown()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, syscall.SIGTERM)
go func() {
<-c
environment.Shutdown()
os.Exit(1)
}()
logger.Debug("main", "Starting deploy")
cliRunnerFactory := bltclirunner.NewFactory(config.CliCmd, cmdRunner, fs)
directorInfo, err := bltaction.NewDirectorInfo(environment.DirectorURL(), cliRunnerFactory)
if err != nil {
panic(err)
}
actionFactory := bltaction.NewFactory(directorInfo, fs, assetsProvider)
prepareActionFlow := bltflow.NewFlow(1, []bltflow.ActionInfo{{Name: "prepare"}}, actionFactory, cliRunnerFactory)
err = prepareActionFlow.Run(false)
if err != nil {
panic(err)
}
if !config.UsingLegacyManifest {
uploadCloudConfigActionFlow := bltflow.NewFlow(2, []bltflow.ActionInfo{{Name: "upload_cloud_config"}}, actionFactory, cliRunnerFactory)
err := uploadCloudConfigActionFlow.Run(false)
if err != nil {
panic(err)
}
}
randomizer := bltflow.NewRandomizer(actionFactory, cliRunnerFactory, fs, logger)
if len(os.Args) == 3 {
err := randomizer.Configure(os.Args[2])
if err != nil {
panic(err)
}
} else {
err := randomizer.Prepare(config.Flows, config.NumberOfDeployments)
if err != nil {
panic(err)
}
}
doneCh := make(chan error)
for i := 0; i < config.NumberOfDeployments; i++ {
go func(i int) {
doneCh <- randomizer.RunFlow(i, config.UsingLegacyManifest)
}(i)
}
for i := 0; i < config.NumberOfDeployments; i++ {
err := <-doneCh
if err != nil {
panic(err)
}
}
println("Done!")
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-load-tests,代码行数:89,代码来源:main.go
示例12: main
func main() {
if len(os.Args) < 2 || len(os.Args) > 3 {
println("Usage: bft path/to/config.json seed")
os.Exit(1)
}
logger := boshlog.NewLogger(boshlog.LevelDebug)
fs := boshsys.NewOsFileSystem(logger)
cmdRunner := boshsys.NewExecCmdRunner(logger)
testConfig := bftconfig.NewConfig(fs)
err := testConfig.Load(os.Args[1])
if err != nil {
panic(err)
}
envConfig := bltconfig.NewConfig(fs)
err = envConfig.Load(os.Args[1])
if err != nil {
panic(err)
}
assetsProvider := bltassets.NewProvider(envConfig.AssetsPath)
logger.Debug("main", "Setting up environment")
environmentProvider := bltenv.NewProvider(envConfig, fs, cmdRunner, assetsProvider)
environment := environmentProvider.Get()
if !testConfig.GenerateManifestOnly {
err = environment.Setup()
if err != nil {
panic(err)
}
defer environment.Shutdown()
}
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, syscall.SIGTERM)
go func() {
<-c
environment.Shutdown()
os.Exit(1)
}()
cliRunnerFactory := bltclirunner.NewFactory(envConfig.CliCmd, cmdRunner, fs)
var directorInfo bltaction.DirectorInfo
if testConfig.GenerateManifestOnly {
directorInfo = bltaction.DirectorInfo{
UUID: "blah",
URL: "xxx",
}
} else {
directorInfo, err = bltaction.NewDirectorInfo(environment.DirectorURL(), cliRunnerFactory)
}
if err != nil {
panic(err)
}
cliRunner := cliRunnerFactory.Create()
cliRunner.Configure()
defer cliRunner.Clean()
if !testConfig.GenerateManifestOnly {
logger.Debug("main", "Preparing to deploy")
preparer := bftdeployment.NewPreparer(directorInfo, cliRunner, fs, assetsProvider)
err = preparer.Prepare()
if err != nil {
panic(err)
}
}
logger.Debug("main", "Starting deploy")
renderer := bftdeployment.NewRenderer(fs)
var seed int64
if len(os.Args) == 3 {
seed, _ = strconv.ParseInt(os.Args[2], 10, 64)
} else {
seed = time.Now().Unix()
}
logger.Info("main", "Seeding with %d", seed)
rand.Seed(seed)
nameGenerator := bftnamegen.NewNameGenerator()
decider := bftdecider.NewRandomDecider()
ipPoolProvider := bftnetwork.NewIpPoolProvider()
networksAssigner := bftnetwork.NewAssigner(testConfig.Parameters.Networks, nameGenerator, ipPoolProvider, decider, logger)
parameterProvider := bftparam.NewParameterProvider(testConfig.Parameters, nameGenerator, decider, networksAssigner, logger)
inputGenerator := bftdeployment.NewInputGenerator(testConfig.Parameters, parameterProvider, testConfig.NumberOfConsequentDeploys, nameGenerator, decider, logger)
analyzer := bftanalyzer.NewAnalyzer(logger)
deployer := bftdeployment.NewDeployer(
cliRunner,
directorInfo,
renderer,
//.........这里部分代码省略.........
开发者ID:cloudfoundry-incubator,项目名称:bosh-fuzz-tests,代码行数:101,代码来源:main.go
注:本文中的github.com/cloudfoundry/bosh-utils/system.NewOsFileSystem函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论