当前位置: 首页>>代码示例>>Golang>>正文


Golang Input.FindJobByName方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/bosh-fuzz-tests/input.Input.FindJobByName方法的典型用法代码示例。如果您正苦于以下问题:Golang Input.FindJobByName方法的具体用法?Golang Input.FindJobByName怎么用?Golang Input.FindJobByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/bosh-fuzz-tests/input.Input的用法示例。


在下文中一共展示了Input.FindJobByName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getJobStaticIpsToReuse

func (n *assigner) getJobStaticIpsToReuse(previousInput bftinput.Input, jobName string, networkName string) []string {
	staticIps := []string{}

	previousJob, found := previousInput.FindJobByName(jobName)
	if !found {
		return staticIps
	}

	for _, jobNetwork := range previousJob.Networks {
		if jobNetwork.Name == networkName {
			for _, ip := range jobNetwork.StaticIps {
				staticIps = append(staticIps, ip)
			}
		}
	}

	if len(staticIps) == 0 {
		return staticIps
	}

	shuffledStaticIPsIdsx := rand.Perm(len(staticIps))
	ipsToReuse := rand.Intn(len(staticIps))

	shuffledStaticIps := []string{}

	for i := 0; i < ipsToReuse; i++ {
		shuffledStaticIps = append(shuffledStaticIps, staticIps[shuffledStaticIPsIdsx[i]])
	}

	return shuffledStaticIps
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-fuzz-tests,代码行数:31,代码来源:assigner.go

示例2: jobStemcellChanged

func (s *stemcellComparator) jobStemcellChanged(job bftinput.Job, currentInput bftinput.Input, mostRecentInput bftinput.Input) bool {
	prevJob, found := mostRecentInput.FindJobByName(job.Name)
	if !found {
		return false
	}

	var currentStemcell bftinput.StemcellConfig
	if job.Stemcell != "" {
		currentStemcell = s.findStemcellByAlias(job.Stemcell, currentInput)
	} else {
		currentStemcell = s.findResourcePoolStemcell(job.ResourcePool, currentInput)
	}

	if prevJob.Stemcell != "" {
		prevStemcell := s.findStemcellByAlias(prevJob.Stemcell, mostRecentInput)
		if prevStemcell.Version != currentStemcell.Version {
			s.logger.Debug("stemcell_comparator", "Stemcell versions don't match. Previous input: %#v, new input: %#v", mostRecentInput, currentInput)
			return true
		}
	} else {
		prevStemcell := s.findResourcePoolStemcell(prevJob.ResourcePool, mostRecentInput)
		if prevStemcell.Version != currentStemcell.Version {
			s.logger.Debug("stemcell_comparator", "Stemcell versions don't match. Previous input: %#v, new input: %#v", mostRecentInput, currentInput)
			return true
		}
	}

	return false
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-fuzz-tests,代码行数:29,代码来源:stemcell_comparator.go

示例3: Apply

func (f *fixedMigratedFrom) Apply(input bftinput.Input, previousInput bftinput.Input) bftinput.Input {
	for foundJobIdx, job := range input.Jobs {
		previousJob, found := previousInput.FindJobByName(job.Name)
		if found {
			if len(previousJob.AvailabilityZones) == 0 && len(job.AvailabilityZones) > 0 {
				staticIPs := f.sameStaticIps(job, previousJob, input)
				for _, ip := range staticIPs {
					f.assignMigratedFromBasedOnIp(ip, &input.Jobs[foundJobIdx])
				}
			}
		}
	}

	return input
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-fuzz-tests,代码行数:15,代码来源:fixed_migrated_from.go

示例4: isMigratingFromAzsToNoAzsAndReusingStaticIps

func (a *analyzer) isMigratingFromAzsToNoAzsAndReusingStaticIps(previousInput bftinput.Input, currentInput bftinput.Input) bool {
	for _, job := range currentInput.Jobs {
		previousJob, found := previousInput.FindJobByName(job.Name)
		if found && (len(previousJob.AvailabilityZones) > 0 && len(job.AvailabilityZones) == 0) {
			for _, network := range job.Networks {
				previousNetwork, networkFound := previousJob.FindNetworkByName(network.Name)
				if networkFound {
					for _, currentIP := range network.StaticIps {
						for _, prevIP := range previousNetwork.StaticIps {
							if prevIP == currentIP {
								return true
							}
						}
					}
				}
			}
		}
	}

	return false
}
开发者ID:cloudfoundry-incubator,项目名称:bosh-fuzz-tests,代码行数:21,代码来源:analyzer.go


注:本文中的github.com/cloudfoundry-incubator/bosh-fuzz-tests/input.Input.FindJobByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。