func (app *app) setupBlobstore(blobstoreSettings boshsettings.Blobstore, blobManager boshblob.BlobManagerInterface) (boshblob.Blobstore, error) { blobstoreProvider := boshblob.NewProvider( app.platform.GetFs(), app.platform.GetRunner(), app.dirProvider.EtcDir(), app.digestProvider, app.logger, ) blobstore, err := blobstoreProvider.Get(blobstoreSettings.Type, blobstoreSettings.Options) if err != nil { return nil, bosherr.WrapError(err, "Getting blobstore") } return boshagentblobstore.NewCascadingBlobstore(blobstore, blobManager, app.logger), nil }
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, ) timeService := clock.NewClock() jobScriptProvider := boshscript.NewConcreteJobScriptProvider( app.platform.GetRunner(), app.platform.GetFs(), app.platform.GetDirProvider(), timeService, app.logger, ) actionFactory := boshaction.NewFactory( settingsService, app.platform, blobstore, taskService, notifier, applier, compiler, jobSupervisor, specService, jobScriptProvider, app.logger, ) actionRunner := boshaction.NewRunner() actionDispatcher := boshagent.NewActionDispatcher( app.logger, taskService, taskManager, actionFactory, actionRunner, ) syslogServer := boshsyslog.NewServer(33331, net.Listen, app.logger) app.agent = boshagent.New( app.logger, mbusHandler, app.platform, actionDispatcher, jobSupervisor, specService, syslogServer, time.Minute, settingsService, uuidGen, timeService, ) return nil }