本文整理汇总了Golang中github.com/openshift/origin/pkg/util/docker/dockerfile.LastExposedPorts函数的典型用法代码示例。如果您正苦于以下问题:Golang LastExposedPorts函数的具体用法?Golang LastExposedPorts怎么用?Golang LastExposedPorts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LastExposedPorts函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: checkForPorts
func checkForPorts(repo *app.SourceRepository) []string {
info := repo.Info()
if info == nil || info.Dockerfile == nil {
return nil
}
node := info.Dockerfile.AST()
return dockerfile.LastExposedPorts(node)
}
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:8,代码来源:appjson.go
示例2: exposedPortsAreNumeric
func exposedPortsAreNumeric(node *dockerfileparser.Node) error {
for _, port := range dockerfileutil.LastExposedPorts(node) {
if _, err := strconv.ParseInt(port, 10, 32); err != nil {
return fmt.Errorf("could not parse %q: must be numeric", port)
}
}
return nil
}
开发者ID:nak3,项目名称:origin,代码行数:8,代码来源:newapp.go
示例3: FromDockerfile
// FromDockerfile generates an ImageRef from a given name, directory, and context path.
// The directory and context path will be joined and the resulting path should be a
// Dockerfile from where the image's ports will be extracted.
func (g *imageRefGenerator) FromDockerfile(name string, dir string, context string) (*ImageRef, error) {
// Look for Dockerfile in repository
file, err := os.Open(filepath.Join(dir, context, "Dockerfile"))
if err != nil {
return nil, err
}
node, err := parser.Parse(file)
if err != nil {
return nil, err
}
ports := dockerfile.LastExposedPorts(node)
return g.FromNameAndPorts(name, ports)
}
开发者ID:RomainVabre,项目名称:origin,代码行数:18,代码来源:imageref.go
示例4: buildPipelines
// buildPipelines converts a set of resolved, valid references into pipelines.
func (c *AppConfig) buildPipelines(components app.ComponentReferences, environment app.Environment) (app.PipelineGroup, error) {
pipelines := app.PipelineGroup{}
names := map[string]int{}
for _, group := range components.Group() {
glog.V(4).Infof("found group: %#v", group)
common := app.PipelineGroup{}
for _, ref := range group {
var pipeline *app.Pipeline
var name string
if ref.Input().ExpectToBuild {
glog.V(4).Infof("will use %q as the base image for a source build of %q", ref, ref.Input().Uses)
input, err := app.InputImageFromMatch(ref.Input().ResolvedMatch)
if err != nil {
return nil, fmt.Errorf("can't build %q: %v", ref.Input(), err)
}
if !input.AsImageStream {
glog.Warningf("Could not find an image stream match for %q. Make sure that a Docker image with that tag is available on the node for the build to succeed.", ref.Input().ResolvedMatch.Value)
}
strategy, source, err := app.StrategyAndSourceForRepository(ref.Input().Uses, input)
if err != nil {
return nil, fmt.Errorf("can't build %q: %v", ref.Input(), err)
}
// Override resource names from the cli
name = c.Name
if len(name) == 0 {
var ok bool
name, ok = (app.NameSuggestions{source, input}).SuggestName()
if !ok {
return nil, fmt.Errorf("can't suggest a valid name, please specify a name with --name")
}
}
name, err = ensureValidUniqueName(names, name)
source.Name = name
if err != nil {
return nil, err
}
// Append any exposed ports from Dockerfile to input image
if ref.Input().Uses.IsDockerBuild() && ref.Input().Uses.Info() != nil {
node := ref.Input().Uses.Info().Dockerfile.AST()
ports := dockerfileutil.LastExposedPorts(node)
if len(ports) > 0 {
if input.Info == nil {
input.Info = &imageapi.DockerImage{
Config: &imageapi.DockerConfig{},
}
}
input.Info.Config.ExposedPorts = map[string]struct{}{}
for _, p := range ports {
input.Info.Config.ExposedPorts[p] = struct{}{}
}
}
}
if pipeline, err = app.NewBuildPipeline(ref.Input().String(), input, c.OutputDocker, strategy, c.GetBuildEnvironment(environment), source); err != nil {
return nil, fmt.Errorf("can't build %q: %v", ref.Input(), err)
}
} else {
glog.V(4).Infof("will include %q", ref)
input, err := app.InputImageFromMatch(ref.Input().ResolvedMatch)
if err != nil {
return nil, fmt.Errorf("can't include %q: %v", ref.Input(), err)
}
name = c.Name
if len(name) == 0 {
var ok bool
name, ok = input.SuggestName()
if !ok {
return nil, fmt.Errorf("can't suggest a valid name, please specify a name with --name")
}
}
name, err = ensureValidUniqueName(names, name)
if err != nil {
return nil, err
}
input.ObjectName = name
if pipeline, err = app.NewImagePipeline(ref.Input().String(), input); err != nil {
return nil, fmt.Errorf("can't include %q: %v", ref.Input(), err)
}
}
if err := pipeline.NeedsDeployment(environment, c.Labels, name); err != nil {
return nil, fmt.Errorf("can't set up a deployment for %q: %v", ref.Input(), err)
}
common = append(common, pipeline)
}
if err := common.Reduce(); err != nil {
return nil, fmt.Errorf("can't create a pipeline from %s: %v", common, err)
}
pipelines = append(pipelines, common...)
}
return pipelines, nil
}
开发者ID:hloganathan,项目名称:origin,代码行数:96,代码来源:newapp.go
示例5: NewBuildPipeline
// NewBuildPipeline creates a new pipeline with components that are expected to
// be built.
func (pb *pipelineBuilder) NewBuildPipeline(from string, input *ImageRef, sourceRepository *SourceRepository) (*Pipeline, error) {
strategy, source, err := StrategyAndSourceForRepository(sourceRepository, input)
if err != nil {
return nil, fmt.Errorf("can't build %q: %v", from, err)
}
var name string
output := &ImageRef{
OutputImage: true,
AsImageStream: !pb.outputDocker,
}
if len(pb.to) > 0 {
outputImageRef, err := image.ParseDockerImageReference(pb.to)
if err != nil {
return nil, err
}
output.Reference = outputImageRef
name, err = pb.nameGenerator.Generate(NameSuggestions{source, output, input})
if err != nil {
return nil, err
}
} else {
name, err = pb.nameGenerator.Generate(NameSuggestions{source, input})
if err != nil {
return nil, err
}
output.Reference = image.DockerImageReference{
Name: name,
Tag: image.DefaultImageTag,
}
}
source.Name = name
// Append any exposed ports from Dockerfile to input image
if sourceRepository.IsDockerBuild() && sourceRepository.Info() != nil {
node := sourceRepository.Info().Dockerfile.AST()
ports := dockerfile.LastExposedPorts(node)
if len(ports) > 0 {
if input.Info == nil {
input.Info = &image.DockerImage{
Config: &image.DockerConfig{},
}
}
input.Info.Config.ExposedPorts = map[string]struct{}{}
for _, p := range ports {
input.Info.Config.ExposedPorts[p] = struct{}{}
}
}
}
if input != nil {
// TODO: assumes that build doesn't change the image metadata. In the future
// we could get away with deferred generation possibly.
output.Info = input.Info
}
build := &BuildRef{
Source: source,
Input: input,
Strategy: strategy,
Output: output,
Env: pb.environment,
}
return &Pipeline{
Name: name,
From: from,
InputImage: input,
Image: output,
Build: build,
}, nil
}
开发者ID:rhamilto,项目名称:origin,代码行数:74,代码来源:pipeline.go
示例6: NewBuildPipeline
// NewBuildPipeline creates a new pipeline with components that are expected to
// be built.
func (pb *pipelineBuilder) NewBuildPipeline(from string, resolvedMatch *ComponentMatch, sourceRepository *SourceRepository) (*Pipeline, error) {
input, err := InputImageFromMatch(resolvedMatch)
if err != nil {
return nil, fmt.Errorf("can't build %q: %v", from, err)
}
if !input.AsImageStream {
msg := "Could not find an image stream match for %q. Make sure that a Docker image with that tag is available on the node for the build to succeed."
glog.Warningf(msg, resolvedMatch.Value)
}
strategy, source, err := StrategyAndSourceForRepository(sourceRepository, input)
if err != nil {
return nil, fmt.Errorf("can't build %q: %v", from, err)
}
name, err := pb.nameGenerator.Generate(NameSuggestions{source, input})
if err != nil {
return nil, err
}
source.Name = name
// Append any exposed ports from Dockerfile to input image
if sourceRepository.IsDockerBuild() && sourceRepository.Info() != nil {
node := sourceRepository.Info().Dockerfile.AST()
ports := dockerfile.LastExposedPorts(node)
if len(ports) > 0 {
if input.Info == nil {
input.Info = &image.DockerImage{
Config: &image.DockerConfig{},
}
}
input.Info.Config.ExposedPorts = map[string]struct{}{}
for _, p := range ports {
input.Info.Config.ExposedPorts[p] = struct{}{}
}
}
}
output := &ImageRef{
Reference: image.DockerImageReference{
Name: name,
Tag: image.DefaultImageTag,
},
OutputImage: true,
AsImageStream: !pb.outputDocker,
}
if input != nil {
// TODO: assumes that build doesn't change the image metadata. In the future
// we could get away with deferred generation possibly.
output.Info = input.Info
}
build := &BuildRef{
Source: source,
Input: input,
Strategy: strategy,
Output: output,
Env: pb.environment,
}
return &Pipeline{
Name: name,
From: from,
InputImage: input,
Image: output,
Build: build,
}, nil
}
开发者ID:biswajeetparida,项目名称:origin,代码行数:70,代码来源:pipeline.go
示例7: Generate
//.........这里部分代码省略.........
buildPath := appJSON.Repository
if len(buildPath) == 0 && len(g.LocalPath) > 0 {
buildPath = g.LocalPath
}
if len(buildPath) == 0 {
return nil, fmt.Errorf("app.json did not contain a repository URL and no local path was specified")
}
repo, err := app.NewSourceRepository(buildPath, generate.StrategyDocker)
if err != nil {
return nil, err
}
var ports []string
var pipelines app.PipelineGroup
baseImage := g.BaseImage
if len(baseImage) == 0 {
baseImage = appJSON.Image
}
if len(baseImage) == 0 {
return nil, fmt.Errorf("Docker image required: provide an --image flag or 'image' key in app.json")
}
fakeDockerfile := heredoc.Docf(`
# Generated from app.json
FROM %s
`, baseImage)
dockerfilePath := filepath.Join(buildPath, "Dockerfile")
if df, err := app.NewDockerfileFromFile(dockerfilePath); err == nil {
repo.Info().Dockerfile = df
repo.Info().Path = dockerfilePath
ports = dockerfile.LastExposedPorts(df.AST())
}
// TODO: look for procfile for more info?
image, err := imageGen.FromNameAndPorts(baseImage, ports)
if err != nil {
return nil, err
}
image.AsImageStream = true
image.TagDirectly = true
image.ObjectName = name
image.Tag = "from"
pipeline, err := app.NewPipelineBuilder(name, nil, false).To(name).NewBuildPipeline(name, image, repo)
if err != nil {
return nil, err
}
// TODO: this should not be necessary
pipeline.Build.Source.Name = name
pipeline.Build.Source.DockerfileContents = fakeDockerfile
pipeline.Name = name
pipeline.Image.ObjectName = name
glog.V(4).Infof("created pipeline %+v", pipeline)
pipelines = append(pipelines, pipeline)
var errs []error
// create deployments for each formation
var group app.PipelineGroup
for _, component := range formations.List() {
componentName := fmt.Sprintf("%s-%s", name, component)
开发者ID:LalatenduMohanty,项目名称:origin,代码行数:67,代码来源:appjson.go
注:本文中的github.com/openshift/origin/pkg/util/docker/dockerfile.LastExposedPorts函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论