本文整理汇总了Golang中github.com/openshift/origin/pkg/build/api.StrategyType函数的典型用法代码示例。如果您正苦于以下问题:Golang StrategyType函数的具体用法?Golang StrategyType怎么用?Golang StrategyType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StrategyType函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: printBuildConfig
func printBuildConfig(bc *buildapi.BuildConfig, w io.Writer, opts kctl.PrintOptions) error {
name := formatResourceName(opts.Kind, bc.Name, opts.WithKind)
from := describeSourceShort(bc.Spec.CommonSpec)
if bc.Spec.Strategy.CustomStrategy != nil {
if opts.WithNamespace {
if _, err := fmt.Fprintf(w, "%s\t", bc.Namespace); err != nil {
return err
}
}
_, err := fmt.Fprintf(w, "%s\t%v\t%s\t%d\n", name, buildapi.StrategyType(bc.Spec.Strategy), bc.Spec.Strategy.CustomStrategy.From.Name, bc.Status.LastVersion)
return err
}
if opts.WithNamespace {
if _, err := fmt.Fprintf(w, "%s\t", bc.Namespace); err != nil {
return err
}
}
if _, err := fmt.Fprintf(w, "%s\t%v\t%s\t%d", name, buildapi.StrategyType(bc.Spec.Strategy), from, bc.Status.LastVersion); err != nil {
return err
}
if err := appendItemLabels(bc.Labels, w, opts.ColumnLabels, opts.ShowLabels); err != nil {
return err
}
return nil
}
开发者ID:ncdc,项目名称:origin,代码行数:26,代码来源:printer.go
示例2: printBuild
func printBuild(build *buildapi.Build, w io.Writer, opts kctl.PrintOptions) error {
if opts.WithNamespace {
if _, err := fmt.Fprintf(w, "%s\t", build.Namespace); err != nil {
return err
}
}
var created string
if build.Status.StartTimestamp != nil {
created = fmt.Sprintf("%s ago", formatRelativeTime(build.Status.StartTimestamp.Time))
}
var duration string
if build.Status.Duration > 0 {
duration = build.Status.Duration.String()
}
from := describeSourceShort(build.Spec.CommonSpec)
status := string(build.Status.Phase)
if len(build.Status.Reason) > 0 {
status = fmt.Sprintf("%s (%s)", status, build.Status.Reason)
}
if _, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s", build.Name, buildapi.StrategyType(build.Spec.Strategy), from, status, created, duration); err != nil {
return err
}
if err := appendItemLabels(build.Labels, w, opts.ColumnLabels, opts.ShowLabels); err != nil {
return err
}
return nil
}
开发者ID:sgallagher,项目名称:origin,代码行数:27,代码来源:printer.go
示例3: printBuildConfig
func printBuildConfig(bc *buildapi.BuildConfig, w io.Writer, opts kctl.PrintOptions) error {
if bc.Spec.Strategy.CustomStrategy != nil {
_, err := fmt.Fprintf(w, "%s\t%v\t%s\t%d\n", bc.Name, buildapi.StrategyType(bc.Spec.Strategy), bc.Spec.Strategy.CustomStrategy.From.Name, bc.Status.LastVersion)
return err
}
from := describeSourceShort(bc.Spec.BuildSpec)
if opts.WithNamespace {
if _, err := fmt.Fprintf(w, "%s\t", bc.Namespace); err != nil {
return err
}
}
_, err := fmt.Fprintf(w, "%s\t%v\t%s\t%d\n", bc.Name, buildapi.StrategyType(bc.Spec.Strategy), from, bc.Status.LastVersion)
return err
}
开发者ID:erinboyd,项目名称:origin,代码行数:16,代码来源:printer.go
示例4: printBuildConfig
func printBuildConfig(bc *buildapi.BuildConfig, w io.Writer, withNamespace, wide, showAll bool, columnLabels []string) error {
if bc.Spec.Strategy.CustomStrategy != nil {
_, err := fmt.Fprintf(w, "%s\t%v\t%s\t%d\n", bc.Name, buildapi.StrategyType(bc.Spec.Strategy), bc.Spec.Strategy.CustomStrategy.From.Name, bc.Status.LastVersion)
return err
}
from := describeSourceShort(bc.Spec.BuildSpec)
if withNamespace {
if _, err := fmt.Fprintf(w, "%s\t", bc.Namespace); err != nil {
return err
}
}
_, err := fmt.Fprintf(w, "%s\t%v\t%s\t%d\n", bc.Name, buildapi.StrategyType(bc.Spec.Strategy), from, bc.Status.LastVersion)
return err
}
开发者ID:johnmccawley,项目名称:origin,代码行数:16,代码来源:printer.go
示例5: printBuild
func printBuild(build *buildapi.Build, w io.Writer, withNamespace, wide, showAll bool, columnLabels []string) error {
if withNamespace {
if _, err := fmt.Fprintf(w, "%s\t", build.Namespace); err != nil {
return err
}
}
var created string
if build.Status.StartTimestamp != nil {
created = fmt.Sprintf("%s ago", formatRelativeTime(build.Status.StartTimestamp.Time))
}
var duration string
if build.Status.Duration > 0 {
duration = build.Status.Duration.String()
}
from := describeSourceShort(build.Spec)
status := string(build.Status.Phase)
if len(build.Status.Reason) > 0 {
status = fmt.Sprintf("%s (%s)", status, build.Status.Reason)
}
_, err := fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\n", build.Name, buildapi.StrategyType(build.Spec.Strategy), from, status, created, duration)
return err
}
开发者ID:johnmccawley,项目名称:origin,代码行数:22,代码来源:printer.go
示例6: describeCommonSpec
func describeCommonSpec(p buildapi.CommonSpec, out *tabwriter.Writer) {
formatString(out, "\nStrategy", buildapi.StrategyType(p.Strategy))
noneType := true
if p.Source.Git != nil {
noneType = false
formatString(out, "URL", p.Source.Git.URI)
if len(p.Source.Git.Ref) > 0 {
formatString(out, "Ref", p.Source.Git.Ref)
}
if len(p.Source.ContextDir) > 0 {
formatString(out, "ContextDir", p.Source.ContextDir)
}
if p.Source.SourceSecret != nil {
formatString(out, "Source Secret", p.Source.SourceSecret.Name)
}
squashGitInfo(p.Revision, out)
}
if p.Source.Dockerfile != nil {
if len(strings.TrimSpace(*p.Source.Dockerfile)) == 0 {
formatString(out, "Dockerfile", "")
} else {
fmt.Fprintf(out, "Dockerfile:\n")
for _, s := range strings.Split(*p.Source.Dockerfile, "\n") {
fmt.Fprintf(out, " %s\n", s)
}
}
}
switch {
case p.Strategy.DockerStrategy != nil:
describeDockerStrategy(p.Strategy.DockerStrategy, out)
case p.Strategy.SourceStrategy != nil:
describeSourceStrategy(p.Strategy.SourceStrategy, out)
case p.Strategy.CustomStrategy != nil:
describeCustomStrategy(p.Strategy.CustomStrategy, out)
case p.Strategy.JenkinsPipelineStrategy != nil:
describeJenkinsPipelineStrategy(p.Strategy.JenkinsPipelineStrategy, out)
}
if p.Output.To != nil {
formatString(out, "Output to", fmt.Sprintf("%s %s", p.Output.To.Kind, nameAndNamespace(p.Output.To.Namespace, p.Output.To.Name)))
}
if p.Source.Binary != nil {
noneType = false
if len(p.Source.Binary.AsFile) > 0 {
formatString(out, "Binary", fmt.Sprintf("provided as file %q on build", p.Source.Binary.AsFile))
} else {
formatString(out, "Binary", "provided on build")
}
}
if len(p.Source.Secrets) > 0 {
result := []string{}
for _, s := range p.Source.Secrets {
result = append(result, fmt.Sprintf("%s->%s", s.Secret.Name, filepath.Clean(s.DestinationDir)))
}
formatString(out, "Build Secrets", strings.Join(result, ","))
}
if len(p.Source.Images) == 1 && len(p.Source.Images[0].Paths) == 1 {
noneType = false
image := p.Source.Images[0]
path := image.Paths[0]
formatString(out, "Image Source", fmt.Sprintf("copies %s from %s to %s", path.SourcePath, nameAndNamespace(image.From.Namespace, image.From.Name), path.DestinationDir))
} else {
for _, image := range p.Source.Images {
noneType = false
formatString(out, "Image Source", fmt.Sprintf("%s", nameAndNamespace(image.From.Namespace, image.From.Name)))
for _, path := range image.Paths {
fmt.Fprintf(out, "\t- %s -> %s\n", path.SourcePath, path.DestinationDir)
}
}
}
if noneType {
formatString(out, "Empty Source", "no input source provided")
}
describePostCommitHook(p.PostCommit, out)
if p.Output.PushSecret != nil {
formatString(out, "Push Secret", p.Output.PushSecret.Name)
}
if p.CompletionDeadlineSeconds != nil {
formatString(out, "Fail Build After", time.Duration(*p.CompletionDeadlineSeconds)*time.Second)
}
}
开发者ID:rhamilto,项目名称:origin,代码行数:87,代码来源:describer.go
示例7: describeBuildSpec
func describeBuildSpec(p buildapi.BuildSpec, out *tabwriter.Writer) {
formatString(out, "Strategy", buildapi.StrategyType(p.Strategy))
if p.Source.Dockerfile != nil {
if len(strings.TrimSpace(*p.Source.Dockerfile)) == 0 {
formatString(out, "Dockerfile", "")
} else {
fmt.Fprintf(out, "Dockerfile:\n")
for _, s := range strings.Split(*p.Source.Dockerfile, "\n") {
fmt.Fprintf(out, " %s\n", s)
}
}
}
if p.Source.Git != nil {
formatString(out, "URL", p.Source.Git.URI)
if len(p.Source.Git.Ref) > 0 {
formatString(out, "Ref", p.Source.Git.Ref)
}
if len(p.Source.ContextDir) > 0 {
formatString(out, "ContextDir", p.Source.ContextDir)
}
if p.Source.SourceSecret != nil {
formatString(out, "Source Secret", p.Source.SourceSecret.Name)
}
if p.Revision != nil && p.Revision.Git != nil {
rev := p.Revision.Git
formatString(out, "Commit", rev.Commit)
if len(rev.Author.Name) != 0 {
formatString(out, "Author", rev.Author.Name)
}
if len(rev.Committer.Name) != 0 {
formatString(out, "Committer", rev.Committer.Name)
}
formatString(out, "Message", rev.Message)
}
}
if p.Source.Binary != nil {
if len(p.Source.Binary.AsFile) > 0 {
formatString(out, "Binary", fmt.Sprintf("provided as file %q on build", p.Source.Binary.AsFile))
} else {
formatString(out, "Binary", "provided on build")
}
}
switch {
case p.Strategy.DockerStrategy != nil:
describeDockerStrategy(p.Strategy.DockerStrategy, out)
case p.Strategy.SourceStrategy != nil:
describeSourceStrategy(p.Strategy.SourceStrategy, out)
case p.Strategy.CustomStrategy != nil:
describeCustomStrategy(p.Strategy.CustomStrategy, out)
}
if p.Output.To != nil {
if len(p.Output.To.Namespace) != 0 {
formatString(out, "Output to", fmt.Sprintf("%s %s/%s", p.Output.To.Kind, p.Output.To.Namespace, p.Output.To.Name))
} else {
formatString(out, "Output to", fmt.Sprintf("%s %s", p.Output.To.Kind, p.Output.To.Name))
}
}
if p.Output.PushSecret != nil {
formatString(out, "Push Secret", p.Output.PushSecret.Name)
}
if p.Revision != nil && p.Revision.Git != nil {
buildDescriber := &BuildDescriber{}
formatString(out, "Git Commit", p.Revision.Git.Commit)
buildDescriber.DescribeUser(out, "Revision Author", p.Revision.Git.Author)
buildDescriber.DescribeUser(out, "Revision Committer", p.Revision.Git.Committer)
if len(p.Revision.Git.Message) > 0 {
formatString(out, "Revision Message", p.Revision.Git.Message)
}
}
if p.CompletionDeadlineSeconds != nil {
formatString(out, "Fail Build After", time.Duration(*p.CompletionDeadlineSeconds)*time.Second)
}
}
开发者ID:johnmccawley,项目名称:origin,代码行数:79,代码来源:describer.go
示例8: notAllowed
func notAllowed(strategy buildapi.BuildStrategy, attr admission.Attributes) error {
return admission.NewForbidden(attr, fmt.Errorf("build strategy %s is not allowed", buildapi.StrategyType(strategy)))
}
开发者ID:ZenoRewn,项目名称:origin,代码行数:3,代码来源:admission.go
示例9: describeBuildSpec
func describeBuildSpec(p buildapi.BuildSpec, out *tabwriter.Writer) {
formatString(out, "Strategy", buildapi.StrategyType(p.Strategy))
if p.Source.Dockerfile != nil {
if len(strings.TrimSpace(*p.Source.Dockerfile)) == 0 {
formatString(out, "Dockerfile", "")
} else {
fmt.Fprintf(out, "Dockerfile:\n")
for _, s := range strings.Split(*p.Source.Dockerfile, "\n") {
fmt.Fprintf(out, " %s\n", s)
}
}
}
if p.Source.Git != nil {
formatString(out, "URL", p.Source.Git.URI)
if len(p.Source.Git.Ref) > 0 {
formatString(out, "Ref", p.Source.Git.Ref)
}
if len(p.Source.ContextDir) > 0 {
formatString(out, "ContextDir", p.Source.ContextDir)
}
if p.Source.SourceSecret != nil {
formatString(out, "Source Secret", p.Source.SourceSecret.Name)
}
if p.Revision != nil && p.Revision.Git != nil {
rev := p.Revision.Git
formatString(out, "Commit", rev.Commit)
if len(rev.Author.Name) != 0 {
formatString(out, "Author", rev.Author.Name)
}
if len(rev.Committer.Name) != 0 {
formatString(out, "Committer", rev.Committer.Name)
}
formatString(out, "Message", rev.Message)
}
}
if p.Source.Binary != nil {
if len(p.Source.Binary.AsFile) > 0 {
formatString(out, "Binary", fmt.Sprintf("provided as file %q on build", p.Source.Binary.AsFile))
} else {
formatString(out, "Binary", "provided on build")
}
}
if len(p.Source.Secrets) > 0 {
result := []string{}
for _, s := range p.Source.Secrets {
result = append(result, fmt.Sprintf("%s->%s", s.Secret.Name, filepath.Clean(s.DestinationDir)))
}
formatString(out, "Build Secrets", strings.Join(result, ","))
}
if len(p.Source.Images) == 1 && len(p.Source.Images[0].Paths) == 1 {
image := p.Source.Images[0]
path := image.Paths[0]
formatString(out, "Image Source", fmt.Sprintf("copies %s from %s to %s", path.SourcePath, nameAndNamespace(image.From.Namespace, image.From.Name), path.DestinationDir))
} else {
for _, image := range p.Source.Images {
formatString(out, "Image Source", fmt.Sprintf("%s", nameAndNamespace(image.From.Namespace, image.From.Name)))
for _, path := range image.Paths {
fmt.Fprintf(out, "\t- %s -> %s\n", path.SourcePath, path.DestinationDir)
}
}
}
switch {
case p.Strategy.DockerStrategy != nil:
describeDockerStrategy(p.Strategy.DockerStrategy, out)
case p.Strategy.SourceStrategy != nil:
describeSourceStrategy(p.Strategy.SourceStrategy, out)
case p.Strategy.CustomStrategy != nil:
describeCustomStrategy(p.Strategy.CustomStrategy, out)
}
if p.Output.To != nil {
formatString(out, "Output to", fmt.Sprintf("%s %s", p.Output.To.Kind, nameAndNamespace(p.Output.To.Namespace, p.Output.To.Name)))
}
if p.Output.PushSecret != nil {
formatString(out, "Push Secret", p.Output.PushSecret.Name)
}
if p.Revision != nil && p.Revision.Git != nil {
buildDescriber := &BuildDescriber{}
formatString(out, "Git Commit", p.Revision.Git.Commit)
buildDescriber.DescribeUser(out, "Revision Author", p.Revision.Git.Author)
buildDescriber.DescribeUser(out, "Revision Committer", p.Revision.Git.Committer)
if len(p.Revision.Git.Message) > 0 {
formatString(out, "Revision Message", p.Revision.Git.Message)
}
}
if p.CompletionDeadlineSeconds != nil {
formatString(out, "Fail Build After", time.Duration(*p.CompletionDeadlineSeconds)*time.Second)
}
}
开发者ID:rrati,项目名称:origin,代码行数:94,代码来源:describer.go
注:本文中的github.com/openshift/origin/pkg/build/api.StrategyType函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论