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


Golang app.NewBinarySourceRepository函数代码示例

本文整理汇总了Golang中github.com/openshift/origin/pkg/generate/app.NewBinarySourceRepository函数的典型用法代码示例。如果您正苦于以下问题:Golang NewBinarySourceRepository函数的具体用法?Golang NewBinarySourceRepository怎么用?Golang NewBinarySourceRepository使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: EnsureHasSource

// EnsureHasSource ensure every builder component has source code associated with it. It takes a list of component references
// that are builders and have not been associated with source, and a set of source repositories that have not been associated
// with a builder
func EnsureHasSource(components app.ComponentReferences, repositories app.SourceRepositories, g *GenerationInputs) error {
	if len(components) == 0 {
		return nil
	}

	switch {
	case len(repositories) > 1:
		if len(components) == 1 {
			component := components[0]
			suggestions := ""

			for _, repo := range repositories {
				suggestions += fmt.Sprintf("%s~%s\n", component, repo)
			}
			return fmt.Errorf("there are multiple code locations provided - use one of the following suggestions to declare which code goes with the image:\n%s", suggestions)
		}
		return fmt.Errorf("the following images require source code: %s\n"+
			" and the following repositories are not used: %s\nUse '[image]~[repo]' to declare which code goes with which image", components, repositories)

	case len(repositories) == 1:
		glog.V(2).Infof("Using %q as the source for build", repositories[0])
		for _, component := range components {
			glog.V(2).Infof("Pairing with component %v", component)
			component.Input().Use(repositories[0])
			repositories[0].UsedBy(component)
		}

	default:
		switch {
		case g.BinaryBuild && g.ExpectToBuild:
			// create new "fake" binary repos for any component that doesn't already have a repo
			// TODO: source repository should possibly be refactored to be an interface or a type that better reflects
			//   the different types of inputs
			for _, component := range components {
				input := component.Input()
				if input.Uses != nil {
					continue
				}
				strategy := generate.StrategySource
				isBuilder := input.ResolvedMatch != nil && input.ResolvedMatch.Builder
				if g.Strategy == generate.StrategyDocker || (g.Strategy == generate.StrategyUnspecified && !isBuilder) {
					strategy = generate.StrategyDocker
				}
				repo := app.NewBinarySourceRepository(strategy)
				input.Use(repo)
				repo.UsedBy(input)
				input.ExpectToBuild = true
			}
		case g.ExpectToBuild:
			return errors.New("you must specify at least one source repository URL, provide a Dockerfile, or indicate you wish to use binary builds")
		default:
			for _, component := range components {
				component.Input().ExpectToBuild = false
			}
		}
	}
	return nil
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:61,代码来源:resolve.go

示例2: ensureHasSource

// ensureHasSource ensure every builder component has source code associated with it. It takes a list of component references
// that are builders and have not been associated with source, and a set of source repositories that have not been associated
// with a builder
func (c *AppConfig) ensureHasSource(components app.ComponentReferences, repositories app.SourceRepositories) error {
	if len(components) > 0 {
		switch {
		case len(repositories) > 1:
			if len(components) == 1 {
				component := components[0]
				suggestions := ""

				for _, repo := range repositories {
					suggestions += fmt.Sprintf("%s~%s\n", component, repo)
				}
				return fmt.Errorf("there are multiple code locations provided - use one of the following suggestions to declare which code goes with the image:\n%s", suggestions)
			}
			return fmt.Errorf("the following images require source code: %s\n"+
				" and the following repositories are not used: %s\nUse '[image]~[repo]' to declare which code goes with which image", components, repositories)
		case len(repositories) == 1:
			glog.Infof("Using %q as the source for build", repositories[0])
			for _, component := range components {
				component.Input().Use(repositories[0])
				repositories[0].UsedBy(component)
			}
		default:
			switch {
			case c.BinaryBuild && c.ExpectToBuild:
				// create new "fake" binary repos for any component that doesn't already have a repo
				// TODO: source repository should possibly be refactored to be an interface or a type that better reflects
				//   the different types of inputs
				for _, component := range components {
					input := component.Input()
					if input.Uses != nil {
						continue
					}
					repo := app.NewBinarySourceRepository()
					if c.Strategy == "docker" || len(c.Strategy) == 0 {
						repo.BuildWithDocker()
					}
					input.Use(repo)
					repo.UsedBy(input)
					input.ExpectToBuild = true
				}
			case c.ExpectToBuild:
				return fmt.Errorf("you must specify at least one source repository URL, provide a Dockerfile, or indicate you wish to use binary builds")
			default:
				for _, component := range components {
					component.Input().ExpectToBuild = false
				}
			}
		}
		glog.V(4).Infof("ensureHasSource: %#v", components[0])
	}
	return nil
}
开发者ID:dzungdo,项目名称:origin,代码行数:55,代码来源:newapp.go


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