本文整理匯總了Golang中github.com/cloudfoundry/bosh-utils/uuid.NewGenerator函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewGenerator函數的具體用法?Golang NewGenerator怎麽用?Golang NewGenerator使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewGenerator函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
logger := newLogger()
defer logger.HandlePanic("Main")
fileSystem := boshsys.NewOsFileSystemWithStrictTempRoot(logger)
workspaceRootPath := path.Join(os.Getenv("HOME"), ".bosh_init")
ui := biui.NewConsoleUI(logger)
timeService := clock.NewClock()
cmdFactory := bicmd.NewFactory(
fileSystem,
ui,
timeService,
logger,
boshuuid.NewGenerator(),
workspaceRootPath,
)
cmdRunner := bicmd.NewRunner(cmdFactory)
stage := biui.NewStage(ui, timeService, logger)
err := cmdRunner.Run(stage, os.Args[1:]...)
if err != nil {
displayHelpFunc := func() {
if strings.Contains(err.Error(), "Invalid usage") {
ui.ErrorLinef("")
helpErr := cmdRunner.Run(stage, append([]string{"help"}, os.Args[1:]...)...)
if helpErr != nil {
logger.Error(mainLogTag, "Couldn't print help: %s", helpErr.Error())
}
}
}
fail(err, ui, logger, displayHelpFunc)
}
}
示例2: Run
func (f *actionsFlow) Run(usingLegacyManifest bool) error {
uuid, err := boshuuid.NewGenerator().Generate()
if err != nil {
return err
}
deploymentName := strings.Join([]string{"deployment", uuid}, "-")
cliRunner := f.cliRunnerFactory.Create()
cliRunner.Configure()
defer cliRunner.Clean()
for i, actionInfo := range f.actionInfos {
action, err := f.actionFactory.Create(actionInfo.Name, f.flowNumber, deploymentName, cliRunner, usingLegacyManifest)
if err != nil {
return err
}
err = action.Execute()
if err != nil {
return err
}
if i < len(f.actionInfos)-1 {
time.Sleep(time.Duration(actionInfo.DelayInMilliseconds) * time.Millisecond)
}
}
return nil
}
示例3: NewBlobstore
func NewBlobstore(uri string) BlobClient {
config := davconfig.Config{Endpoint: uri}
client := davclient.NewClient(config, http.DefaultClient)
return BlobClient{
dav: client,
uuidGenerator: uuid.NewGenerator(),
}
}
示例4: loadInstallationParser
func (f *factory) loadInstallationParser() biinstallmanifest.Parser {
if f.installationParser != nil {
return f.installationParser
}
uuidGenerator := boshuuid.NewGenerator()
f.installationParser = biinstallmanifest.NewParser(f.fs, uuidGenerator, f.logger, f.loadInstallationValidator())
return f.installationParser
}
示例5: 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
}
示例6: Create
func (p *PostgresqlDatabase) Create() error {
uuid, err := boshuuid.NewGenerator().Generate()
if err != nil {
return err
}
p.name = strings.Join([]string{"bosh", uuid}, "-")
p.Drop()
_, _, _, err = p.cmdRunner.RunCommand("psql", "-U", p.User(), "-c", "create database \""+p.name+"\";")
if err != nil {
return err
}
return nil
}
示例7: NewRequestRetryable
func NewRequestRetryable(
request *http.Request,
delegate Client,
logger boshlog.Logger,
) RequestRetryable {
return &requestRetryable{
request: request,
delegate: delegate,
attempt: 0,
uuidGenerator: boshuuid.NewGenerator(),
logger: logger,
logTag: "clientRetryable",
}
}
示例8: NewProvider
func NewProvider(
fs system.FileSystem,
runner system.CmdRunner,
configDir string,
logger boshlog.Logger,
) Provider {
return Provider{
uuidGen: boshuuid.NewGenerator(),
fs: fs,
runner: runner,
configDir: configDir,
logger: logger,
}
}
示例9: Create
func (m *MysqlDatabase) Create() error {
uuid, err := boshuuid.NewGenerator().Generate()
if err != nil {
return err
}
m.name = strings.Join([]string{"bosh", uuid}, "-")
m.Drop()
_, _, _, err = m.cmdRunner.RunCommand("mysql", "--user="+m.User(), "--password="+m.Password(), "-e", "create database `"+m.name+"`")
if err != nil {
return err
}
return nil
}
示例10: buildPkg
func buildPkg(bc *fakebc.FakeBundleCollection) (models.Package, *fakebc.FakeBundle) {
uuidGen := boshuuid.NewGenerator()
uuid, err := uuidGen.Generate()
Expect(err).ToNot(HaveOccurred())
pkg := models.Package{
Name: "fake-package-name" + uuid,
Version: "fake-package-name",
Source: models.Source{
Sha1: "fake-blob-sha1",
BlobstoreID: "fake-blobstore-id",
},
}
bundle := bc.FakeGet(pkg)
return pkg, bundle
}
示例11: buildJob
func buildJob(bc *fakebc.FakeBundleCollection) (models.Job, *fakebc.FakeBundle) {
uuidGen := boshuuid.NewGenerator()
uuid, err := uuidGen.Generate()
Expect(err).ToNot(HaveOccurred())
job := models.Job{
Name: "fake-job-name" + uuid,
Version: "fake-job-version",
Source: models.Source{
Sha1: "fake-blob-sha1",
BlobstoreID: "fake-blobstore-id",
PathInArchive: "fake-path-in-archive",
},
Packages: []models.Package{
models.Package{
Name: "fake-package1-name" + uuid,
Version: "fake-package1-version",
Source: models.Source{
Sha1: "fake-package1-sha1",
BlobstoreID: "fake-package1-blobstore-id",
PathInArchive: "",
},
},
models.Package{
Name: "fake-package2-name" + uuid,
Version: "fake-package2-version",
Source: models.Source{
Sha1: "fake-package2-sha1",
BlobstoreID: "fake-package2-blobstore-id",
PathInArchive: "",
},
},
},
}
bundle := bc.FakeGet(job)
return job, bundle
}
示例12:
It("get dummy", func() {
blobstore, err := provider.Get(BlobstoreTypeDummy, map[string]interface{}{})
Expect(err).ToNot(HaveOccurred())
Expect(blobstore).ToNot(BeNil())
})
It("get external when external command in path", func() {
options := map[string]interface{}{"key": "value"}
runner.CommandExistsValue = true
expectedBlobstore := NewExternalBlobstore(
"fake-external-type",
options,
fs,
runner,
boshuuid.NewGenerator(),
"/var/vcap/config/blobstore-fake-external-type.json",
)
expectedBlobstore = NewSHA1VerifiableBlobstore(expectedBlobstore)
expectedBlobstore = NewRetryableBlobstore(expectedBlobstore, 3, logger)
blobstore, err := provider.Get("fake-external-type", options)
Expect(err).ToNot(HaveOccurred())
Expect(blobstore).To(Equal(expectedBlobstore))
err = expectedBlobstore.Validate()
Expect(err).ToNot(HaveOccurred())
})
It("get external errs when external command not in path", func() {
options := map[string]interface{}{"key": "value"}
示例13: buildPackage
func buildPackage() models.Package {
uuidGen := boshuuid.NewGenerator()
uuid, err := uuidGen.Generate()
Expect(err).ToNot(HaveOccurred())
return models.Package{Name: "fake-package-name" + uuid, Version: "fake-package-name"}
}
示例14: buildJob
func buildJob() models.Job {
uuidGen := boshuuid.NewGenerator()
uuid, err := uuidGen.Generate()
Expect(err).ToNot(HaveOccurred())
return models.Job{Name: "fake-job-name" + uuid, Version: "fake-version-name"}
}
示例15: Setup
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(),
//.........這裏部分代碼省略.........