本文整理汇总了Golang中github.com/cloudfoundry/bosh-init/deployment/manifest.Manifest.FindJobByName方法的典型用法代码示例。如果您正苦于以下问题:Golang Manifest.FindJobByName方法的具体用法?Golang Manifest.FindJobByName怎么用?Golang Manifest.FindJobByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/bosh-init/deployment/manifest.Manifest
的用法示例。
在下文中一共展示了Manifest.FindJobByName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BuildInitialState
func (b *builder) BuildInitialState(jobName string, instanceID int, deploymentManifest bideplmanifest.Manifest) (State, error) {
deploymentJob, found := deploymentManifest.FindJobByName(jobName)
if !found {
return nil, bosherr.Errorf("Job '%s' not found in deployment manifest", jobName)
}
networkInterfaces, err := deploymentManifest.NetworkInterfaces(deploymentJob.Name)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Finding networks for job '%s", jobName)
}
// convert map to array
networkRefs := make([]NetworkRef, 0, len(networkInterfaces))
for networkName, networkInterface := range networkInterfaces {
genericMap := make(map[string]interface{}, len(networkInterface))
for k, v := range networkInterface {
genericMap[k] = v
}
networkRefs = append(networkRefs, NetworkRef{
Name: networkName,
Interface: genericMap,
})
}
return &state{
deploymentName: deploymentManifest.Name,
name: jobName,
id: instanceID,
networks: networkRefs,
}, nil
}
示例2: Build
func (b *builder) Build(jobName string, instanceID int, deploymentManifest bideplmanifest.Manifest, stage biui.Stage) (State, error) {
deploymentJob, found := deploymentManifest.FindJobByName(jobName)
if !found {
return nil, bosherr.Errorf("Job '%s' not found in deployment manifest", jobName)
}
releaseJobs, err := b.resolveJobs(deploymentJob.Templates)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Resolving jobs for instance '%s/%d'", jobName, instanceID)
}
renderedJobTemplates, err := b.renderJobTemplates(releaseJobs, deploymentJob.Properties, deploymentManifest.Properties, deploymentManifest.Name, stage)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Rendering job templates for instance '%s/%d'", jobName, instanceID)
}
compiledPackageRefs, err := b.jobDependencyCompiler.Compile(releaseJobs, stage)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Compiling job package dependencies for instance '%s/%d'", jobName, instanceID)
}
networkInterfaces, err := deploymentManifest.NetworkInterfaces(deploymentJob.Name)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Finding networks for job '%s", jobName)
}
// convert map to array
networkRefs := make([]NetworkRef, 0, len(networkInterfaces))
for networkName, networkInterface := range networkInterfaces {
networkRefs = append(networkRefs, NetworkRef{
Name: networkName,
Interface: networkInterface,
})
}
compiledDeploymentPackageRefs := make([]PackageRef, len(compiledPackageRefs), len(compiledPackageRefs))
for i, compiledPackageRef := range compiledPackageRefs {
compiledDeploymentPackageRefs[i] = PackageRef{
Name: compiledPackageRef.Name,
Version: compiledPackageRef.Version,
Archive: BlobRef{
BlobstoreID: compiledPackageRef.BlobstoreID,
SHA1: compiledPackageRef.SHA1,
},
}
}
// convert array to array
renderedJobRefs := make([]JobRef, len(releaseJobs), len(releaseJobs))
for i, releaseJob := range releaseJobs {
renderedJobRefs[i] = JobRef{
Name: releaseJob.Name,
Version: releaseJob.Fingerprint,
}
}
renderedJobListArchiveBlobRef := BlobRef{
BlobstoreID: renderedJobTemplates.BlobstoreID,
SHA1: renderedJobTemplates.Archive.SHA1(),
}
return &state{
deploymentName: deploymentManifest.Name,
name: jobName,
id: instanceID,
networks: networkRefs,
compiledPackages: compiledDeploymentPackageRefs,
renderedJobs: renderedJobRefs,
renderedJobListArchive: renderedJobListArchiveBlobRef,
hash: renderedJobTemplates.Archive.Fingerprint(),
}, nil
}
示例3: Build
func (b *builder) Build(jobName string, instanceID int, deploymentManifest bideplmanifest.Manifest, stage biui.Stage, agentState agentclient.AgentState) (State, error) {
initialState, err := b.BuildInitialState(jobName, instanceID, deploymentManifest)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Building initial state '%s", jobName)
}
deploymentJob, found := deploymentManifest.FindJobByName(jobName)
if !found {
return nil, bosherr.Errorf("Job '%s' not found in deployment manifest", jobName)
}
releaseJobs, err := b.resolveJobs(deploymentJob.Templates)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Resolving jobs for instance '%s/%d'", jobName, instanceID)
}
releaseJobProperties := make(map[string]*biproperty.Map)
for _, releaseJob := range deploymentJob.Templates {
releaseJobProperties[releaseJob.Name] = releaseJob.Properties
}
defaultAddress, err := b.defaultAddress(initialState.NetworkInterfaces(), agentState)
if err != nil {
return nil, err
}
renderedJobTemplates, err := b.renderJobTemplates(releaseJobs, releaseJobProperties, deploymentJob.Properties, deploymentManifest.Properties, deploymentManifest.Name, defaultAddress, stage)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Rendering job templates for instance '%s/%d'", jobName, instanceID)
}
compiledPackageRefs, err := b.jobDependencyCompiler.Compile(releaseJobs, stage)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Compiling job package dependencies for instance '%s/%d'", jobName, instanceID)
}
compiledDeploymentPackageRefs := make([]PackageRef, len(compiledPackageRefs), len(compiledPackageRefs))
for i, compiledPackageRef := range compiledPackageRefs {
compiledDeploymentPackageRefs[i] = PackageRef{
Name: compiledPackageRef.Name,
Version: compiledPackageRef.Version,
Archive: BlobRef{
BlobstoreID: compiledPackageRef.BlobstoreID,
SHA1: compiledPackageRef.SHA1,
},
}
}
// convert array to array
renderedJobRefs := make([]JobRef, len(releaseJobs), len(releaseJobs))
for i, releaseJob := range releaseJobs {
renderedJobRefs[i] = JobRef{
Name: releaseJob.Name,
Version: releaseJob.Fingerprint,
}
}
renderedJobListArchiveBlobRef := BlobRef{
BlobstoreID: renderedJobTemplates.BlobstoreID,
SHA1: renderedJobTemplates.Archive.SHA1(),
}
return &state{
deploymentName: deploymentManifest.Name,
name: jobName,
id: instanceID,
networks: initialState.NetworkInterfaces(),
compiledPackages: compiledDeploymentPackageRefs,
renderedJobs: renderedJobRefs,
renderedJobListArchive: renderedJobListArchiveBlobRef,
hash: renderedJobTemplates.Archive.Fingerprint(),
}, nil
}