本文整理汇总了Golang中github.com/openshift/origin/pkg/util/docker/dockerfile.LastBaseImage函数的典型用法代码示例。如果您正苦于以下问题:Golang LastBaseImage函数的具体用法?Golang LastBaseImage怎么用?Golang LastBaseImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LastBaseImage函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddMissingComponentsToRefBuilder
// ComponentsForSourceRepositories creates components for repositories that have not been previously associated by a
// builder. These components have already gone through source code detection and have a SourceRepositoryInfo attached
// to them.
func AddMissingComponentsToRefBuilder(
b *app.ReferenceBuilder, repositories app.SourceRepositories, dockerfileResolver, sourceResolver, pipelineResolver app.Resolver,
g *GenerationInputs,
) (app.ComponentReferences, error) {
errs := []error{}
result := app.ComponentReferences{}
for _, repo := range repositories {
info := repo.Info()
switch {
case info == nil:
errs = append(errs, fmt.Errorf("source not detected for repository %q", repo))
continue
case info.Jenkinsfile && (g.Strategy == generate.StrategyUnspecified || g.Strategy == generate.StrategyPipeline):
refs := b.AddComponents([]string{"pipeline"}, func(input *app.ComponentInput) app.ComponentReference {
input.Resolver = pipelineResolver
input.Use(repo)
input.ExpectToBuild = true
repo.UsedBy(input)
repo.SetStrategy(generate.StrategyPipeline)
return input
})
result = append(result, refs...)
case info.Dockerfile != nil && (g.Strategy == generate.StrategyUnspecified || g.Strategy == generate.StrategyDocker):
node := info.Dockerfile.AST()
baseImage := dockerfileutil.LastBaseImage(node)
if baseImage == "" {
errs = append(errs, fmt.Errorf("the Dockerfile in the repository %q has no FROM instruction", info.Path))
continue
}
refs := b.AddComponents([]string{baseImage}, func(input *app.ComponentInput) app.ComponentReference {
input.Resolver = dockerfileResolver
input.Use(repo)
input.ExpectToBuild = true
repo.UsedBy(input)
repo.SetStrategy(generate.StrategyDocker)
return input
})
result = append(result, refs...)
default:
// TODO: Add support for searching for more than one language if len(info.Types) > 1
if len(info.Types) == 0 {
errs = append(errs, fmt.Errorf("no language was detected for repository at %q; please specify a builder image to use with your repository: [builder-image]~%s", repo, repo))
continue
}
refs := b.AddComponents([]string{info.Types[0].Term()}, func(input *app.ComponentInput) app.ComponentReference {
input.Resolver = sourceResolver
input.ExpectToBuild = true
input.Use(repo)
repo.UsedBy(input)
return input
})
result = append(result, refs...)
}
}
return result, kutilerrors.NewAggregate(errs)
}
示例2: componentsForRepos
// componentsForRepos creates components for repositories that have not been previously associated by a builder
// these components have already gone through source code detection and have a SourceRepositoryInfo attached to them
func (c *AppConfig) componentsForRepos(repositories app.SourceRepositories) (app.ComponentReferences, error) {
b := c.refBuilder
errs := []error{}
result := app.ComponentReferences{}
for _, repo := range repositories {
info := repo.Info()
switch {
case info == nil:
errs = append(errs, fmt.Errorf("source not detected for repository %q", repo))
continue
case info.Dockerfile != nil && (len(c.Strategy) == 0 || c.Strategy == "docker"):
node := info.Dockerfile.AST()
baseImage := dockerfileutil.LastBaseImage(node)
if baseImage == "" {
errs = append(errs, fmt.Errorf("the Dockerfile in the repository %q has no FROM instruction", info.Path))
continue
}
refs := b.AddComponents([]string{baseImage}, func(input *app.ComponentInput) app.ComponentReference {
resolver := app.PerfectMatchWeightedResolver{}
if c.imageStreamSearcher != nil {
resolver = append(resolver, app.WeightedResolver{Searcher: c.imageStreamSearcher, Weight: 0.0})
}
if c.dockerSearcher != nil {
resolver = append(resolver, app.WeightedResolver{Searcher: c.dockerSearcher, Weight: 1.0})
}
resolver = append(resolver, app.WeightedResolver{Searcher: &app.PassThroughDockerSearcher{}, Weight: 2.0})
input.Resolver = resolver
input.Use(repo)
input.ExpectToBuild = true
repo.UsedBy(input)
repo.BuildWithDocker()
return input
})
result = append(result, refs...)
default:
// TODO: Add support for searching for more than one language if len(info.Types) > 1
if len(info.Types) == 0 {
errs = append(errs, fmt.Errorf("no language was detected for repository at %q; please specify a builder image to use with your repository: [builder-image]~%s", repo, repo))
continue
}
refs := b.AddComponents([]string{info.Types[0].Term()}, func(input *app.ComponentInput) app.ComponentReference {
resolver := app.PerfectMatchWeightedResolver{}
if c.imageStreamByAnnotationSearcher != nil {
resolver = append(resolver, app.WeightedResolver{Searcher: c.imageStreamByAnnotationSearcher, Weight: 0.0})
}
if c.imageStreamSearcher != nil {
resolver = append(resolver, app.WeightedResolver{Searcher: c.imageStreamSearcher, Weight: 1.0})
}
if c.dockerSearcher != nil {
resolver = append(resolver, app.WeightedResolver{Searcher: c.dockerSearcher, Weight: 2.0})
}
input.Resolver = resolver
input.ExpectToBuild = true
input.Use(repo)
repo.UsedBy(input)
return input
})
result = append(result, refs...)
}
}
return result, errors.NewAggregate(errs)
}
示例3: Generate
//.........这里部分代码省略.........
}
relative = path
break
}
if len(base) == 0 {
return nil, fmt.Errorf("build path outside of the compose file: %s", v.Build)
}
// if this is a Git repository, make the path relative
if root, err := git.NewRepository().GetRootDir(base); err == nil {
if relative, err = filepath.Rel(root, filepath.Join(base, relative)); err != nil {
return nil, fmt.Errorf("unable to find relative path for Git repository: %v", err)
}
base = root
}
buildPath := filepath.Join(base, relative)
// TODO: what if there is no origin for this repo?
glog.V(4).Infof("compose service: %#v", v)
repo, err := app.NewSourceRepositoryWithDockerfile(buildPath, "")
if err != nil {
errs = append(errs, err)
continue
}
repo.BuildWithDocker()
info := repo.Info()
if info == nil || info.Dockerfile == nil {
errs = append(errs, fmt.Errorf("unable to locate a Dockerfile in %s", v.Build))
continue
}
node := info.Dockerfile.AST()
baseImage := dockerfileutil.LastBaseImage(node)
if len(baseImage) == 0 {
errs = append(errs, fmt.Errorf("the Dockerfile in the repository %q has no FROM instruction", info.Path))
continue
}
var ports []string
for _, s := range v.Ports {
container, _ := extractFirstPorts(s)
ports = append(ports, container)
}
image, err := g.FromNameAndPorts(baseImage, ports)
if err != nil {
errs = append(errs, err)
continue
}
image.AsImageStream = true
image.TagDirectly = true
image.ObjectName = k
image.Tag = "from"
pipeline, err := app.NewPipelineBuilder(k, nil, false).To(k).NewBuildPipeline(k, image, repo)
if err != nil {
errs = append(errs, err)
continue
}
if len(relative) > 0 {
pipeline.Build.Source.ContextDir = relative
}
// TODO: this should not be necessary
pipeline.Build.Source.Name = k
pipeline.Name = k