func init() { Describe("GenericScriptProvider", func() { It("produces script paths relative to the base directory", func() { runner := fakesys.NewFakeCmdRunner() fs := fakesys.NewFakeFileSystem() dirProvider := boshdir.NewProvider("/the/base/dir") scriptProvider := scriptrunner.NewGenericScriptProvider(runner, fs, dirProvider) script := scriptProvider.Get("jobs/myjob/the-best-hook-ever") Expect(script.Path()).To(Equal("/the/base/dir/jobs/myjob/the-best-hook-ever")) }) }) }
func (app *app) Setup(args []string) error { opts, err := ParseOptions(args) if err != nil { return bosherr.WrapError(err, "Parsing options") } config, err := app.loadConfig(opts.ConfigPath) if err != nil { return bosherr.WrapError(err, "Loading config") } app.dirProvider = boshdirs.NewProvider(opts.BaseDirectory) app.logStemcellInfo() // Pulled outside of the platform provider so bosh-init will not pull in // sigar when cross compiling linux -> darwin sigarCollector := boshsigar.NewSigarStatsCollector(&sigar.ConcreteSigar{}) platformProvider := boshplatform.NewProvider(app.logger, app.dirProvider, sigarCollector, app.fs, config.Platform) app.platform, err = platformProvider.Get(opts.PlatformName) if err != nil { return bosherr.WrapError(err, "Getting platform") } settingsSourceFactory := boshinf.NewSettingsSourceFactory(config.Infrastructure.Settings, app.platform, app.logger) settingsSource, err := settingsSourceFactory.New() if err != nil { return bosherr.WrapError(err, "Getting Settings Source") } settingsService := boshsettings.NewService( app.platform.GetFs(), filepath.Join(app.dirProvider.BoshDir(), "settings.json"), settingsSource, app.platform, app.logger, ) boot := boshagent.NewBootstrap( app.platform, app.dirProvider, settingsService, app.logger, ) if err = boot.Run(); err != nil { return bosherr.WrapError(err, "Running bootstrap") } mbusHandlerProvider := boshmbus.NewHandlerProvider(settingsService, app.logger) mbusHandler, err := mbusHandlerProvider.Get(app.platform, app.dirProvider) if err != nil { return bosherr.WrapError(err, "Getting mbus handler") } blobstoreProvider := boshblob.NewProvider(app.platform.GetFs(), app.platform.GetRunner(), app.dirProvider.EtcDir(), app.logger) blobsettings := settingsService.GetSettings().Blobstore blobstore, err := blobstoreProvider.Get(blobsettings.Type, blobsettings.Options) if err != nil { return bosherr.WrapError(err, "Getting blobstore") } monitClientProvider := boshmonit.NewProvider(app.platform, app.logger) monitClient, err := monitClientProvider.Get() if err != nil { return bosherr.WrapError(err, "Getting monit client") } jobSupervisorProvider := boshjobsuper.NewProvider( app.platform, monitClient, app.logger, app.dirProvider, mbusHandler, ) jobSupervisor, err := jobSupervisorProvider.Get(opts.JobSupervisor) if err != nil { return bosherr.WrapError(err, "Getting job supervisor") } notifier := boshnotif.NewNotifier(mbusHandler) applier, compiler := app.buildApplierAndCompiler(app.dirProvider, blobstore, jobSupervisor) uuidGen := boshuuid.NewGenerator() taskService := boshtask.NewAsyncTaskService(uuidGen, app.logger) taskManager := boshtask.NewManagerProvider().NewManager( app.logger, app.platform.GetFs(), app.dirProvider.BoshDir(), ) specFilePath := filepath.Join(app.dirProvider.BoshDir(), "spec.json") specService := boshas.NewConcreteV1Service( app.platform.GetFs(), specFilePath, ) drainScriptProvider := boshdrain.NewConcreteScriptProvider( app.platform.GetRunner(), app.platform.GetFs(), app.dirProvider, ) genericScriptProvider := boshscript.NewGenericScriptProvider( app.platform.GetRunner(), app.platform.GetFs(), ) actionFactory := boshaction.NewFactory( settingsService, app.platform, blobstore, taskService, notifier, applier, compiler, jobSupervisor, specService, drainScriptProvider, genericScriptProvider, app.logger, ) actionRunner := boshaction.NewRunner() actionDispatcher := boshagent.NewActionDispatcher( app.logger, taskService, taskManager, actionFactory, actionRunner, ) syslogServer := boshsyslog.NewServer(33331, net.Listen, app.logger) timeService := clock.NewClock() app.agent = boshagent.New( app.logger, mbusHandler, app.platform, actionDispatcher, jobSupervisor, specService, syslogServer, time.Minute, settingsService, uuidGen, timeService, ) return nil }