本文整理汇总了Golang中github.com/openshift/origin/pkg/api/graph.ByKey函数的典型用法代码示例。如果您正苦于以下问题:Golang ByKey函数的具体用法?Golang ByKey怎么用?Golang ByKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ByKey函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Describe
// Describe returns the description of a project
func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error) {
g, err := d.MakeGraph(namespace)
if err != nil {
return "", err
}
project, err := d.C.Projects().Get(namespace)
if err != nil {
return "", err
}
coveredNodes := graphview.IntSet{}
services, coveredByServices := graphview.AllServiceGroups(g, coveredNodes)
coveredNodes.Insert(coveredByServices.List()...)
standaloneDCs, coveredByDCs := graphview.AllDeploymentConfigPipelines(g, coveredNodes)
coveredNodes.Insert(coveredByDCs.List()...)
standaloneRCs, coveredByRCs := graphview.AllReplicationControllers(g, coveredNodes)
coveredNodes.Insert(coveredByRCs.List()...)
standaloneImages, coveredByImages := graphview.AllImagePipelinesFromBuildConfig(g, coveredNodes)
coveredNodes.Insert(coveredByImages.List()...)
return tabbedString(func(out *tabwriter.Writer) error {
indent := " "
fmt.Fprintf(out, "In project %s\n", projectapi.DisplayNameAndNameForProject(project))
for _, service := range services {
fmt.Fprintln(out)
printLines(out, indent, 0, describeServiceInServiceGroup(service)...)
for _, dcPipeline := range service.DeploymentConfigPipelines {
printLines(out, indent, 1, describeDeploymentInServiceGroup(dcPipeline)...)
}
rcNode:
for _, rcNode := range service.FulfillingRCs {
for _, coveredDC := range service.FulfillingDCs {
if deployedges.BelongsToDeploymentConfig(coveredDC.DeploymentConfig, rcNode.ReplicationController) {
continue rcNode
}
}
printLines(out, indent, 1, describeRCInServiceGroup(rcNode)...)
}
pod:
for _, podNode := range service.FulfillingPods {
// skip pods that have been displayed in a roll-up of RCs and DCs (by implicit usage of RCs)
for _, coveredRC := range service.FulfillingRCs {
if g.Edge(podNode, coveredRC) != nil {
continue pod
}
}
printLines(out, indent, 1, describePodInServiceGroup(podNode)...)
}
}
for _, standaloneDC := range standaloneDCs {
fmt.Fprintln(out)
printLines(out, indent, 0, describeDeploymentInServiceGroup(standaloneDC)...)
}
for _, standaloneImage := range standaloneImages {
fmt.Fprintln(out)
printLines(out, indent, 0, describeStandaloneBuildGroup(standaloneImage, namespace)...)
printLines(out, indent, 1, describeAdditionalBuildDetail(standaloneImage.Build, standaloneImage.LastSuccessfulBuild, standaloneImage.LastUnsuccessfulBuild, standaloneImage.ActiveBuilds, standaloneImage.DestinationResolved, true)...)
}
for _, standaloneRC := range standaloneRCs {
fmt.Fprintln(out)
printLines(out, indent, 0, describeRCInServiceGroup(standaloneRC.RC)...)
}
// always output warnings
fmt.Fprintln(out)
allMarkers := osgraph.Markers{}
for _, scanner := range getMarkerScanners() {
allMarkers = append(allMarkers, scanner(g)...)
}
sort.Stable(osgraph.ByKey(allMarkers))
sort.Stable(osgraph.ByNodeID(allMarkers))
if errorMarkers := allMarkers.BySeverity(osgraph.ErrorSeverity); len(errorMarkers) > 0 {
fmt.Fprintln(out, "Errors:")
for _, marker := range errorMarkers {
fmt.Fprintln(out, indent+marker.Message)
}
}
if warningMarkers := allMarkers.BySeverity(osgraph.WarningSeverity); len(warningMarkers) > 0 {
fmt.Fprintln(out, "Warnings:")
for _, marker := range warningMarkers {
fmt.Fprintln(out, indent+marker.Message)
}
}
if (len(services) == 0) && (len(standaloneDCs) == 0) && (len(standaloneImages) == 0) {
fmt.Fprintln(out, "You have no services, deployment configs, or build configs.")
//.........这里部分代码省略.........
示例2: Describe
//.........这里部分代码省略.........
for _, standaloneImage := range standaloneImages {
fmt.Fprintln(out)
lines := describeStandaloneBuildGroup(f, standaloneImage, namespace)
lines = append(lines, describeAdditionalBuildDetail(standaloneImage.Build, standaloneImage.LastSuccessfulBuild, standaloneImage.LastUnsuccessfulBuild, standaloneImage.ActiveBuilds, standaloneImage.DestinationResolved, true)...)
printLines(out, indent, 0, lines...)
}
for _, standaloneRC := range standaloneRCs {
fmt.Fprintln(out)
printLines(out, indent, 0, describeRCInServiceGroup(f, standaloneRC.RC)...)
}
monopods, err := filterBoringPods(standalonePods)
if err != nil {
return err
}
for _, monopod := range monopods {
fmt.Fprintln(out)
printLines(out, indent, 0, describeMonopod(f, monopod.Pod)...)
}
allMarkers := osgraph.Markers{}
allMarkers = append(allMarkers, createForbiddenMarkers(forbiddenResources)...)
for _, scanner := range getMarkerScanners(d.LogsCommandName, d.SecurityPolicyCommandFormat, d.SetProbeCommandName) {
allMarkers = append(allMarkers, scanner(g, f)...)
}
// TODO: Provide an option to chase these hidden markers.
allMarkers = allMarkers.FilterByNamespace(namespace)
fmt.Fprintln(out)
sort.Stable(osgraph.ByKey(allMarkers))
sort.Stable(osgraph.ByNodeID(allMarkers))
errorMarkers := allMarkers.BySeverity(osgraph.ErrorSeverity)
errorSuggestions := 0
if len(errorMarkers) > 0 {
fmt.Fprintln(out, "Errors:")
for _, marker := range errorMarkers {
fmt.Fprintln(out, indent+"* "+marker.Message)
if len(marker.Suggestion) > 0 {
errorSuggestions++
if d.Suggest {
switch s := marker.Suggestion.String(); {
case strings.Contains(s, "\n"):
fmt.Fprintln(out)
for _, line := range strings.Split(s, "\n") {
fmt.Fprintln(out, indent+" "+line)
}
case len(s) > 0:
fmt.Fprintln(out, indent+" try: "+s)
}
}
}
}
}
warningMarkers := allMarkers.BySeverity(osgraph.WarningSeverity)
if len(warningMarkers) > 0 {
if d.Suggest {
fmt.Fprintln(out, "Warnings:")
}
for _, marker := range warningMarkers {
if d.Suggest {
示例3: Describe
// Describe returns the description of a project
func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error) {
g, forbiddenResources, err := d.MakeGraph(namespace)
if err != nil {
return "", err
}
project, err := d.C.Projects().Get(namespace)
if err != nil {
return "", err
}
coveredNodes := graphview.IntSet{}
services, coveredByServices := graphview.AllServiceGroups(g, coveredNodes)
coveredNodes.Insert(coveredByServices.List()...)
standaloneDCs, coveredByDCs := graphview.AllDeploymentConfigPipelines(g, coveredNodes)
coveredNodes.Insert(coveredByDCs.List()...)
standaloneRCs, coveredByRCs := graphview.AllReplicationControllers(g, coveredNodes)
coveredNodes.Insert(coveredByRCs.List()...)
standaloneImages, coveredByImages := graphview.AllImagePipelinesFromBuildConfig(g, coveredNodes)
coveredNodes.Insert(coveredByImages.List()...)
return tabbedString(func(out *tabwriter.Writer) error {
indent := " "
fmt.Fprintf(out, describeProjectAndServer(project, d.Server))
for _, service := range services {
if !service.Service.Found() {
continue
}
fmt.Fprintln(out)
printLines(out, indent, 0, describeServiceInServiceGroup(service)...)
for _, dcPipeline := range service.DeploymentConfigPipelines {
printLines(out, indent, 1, describeDeploymentInServiceGroup(dcPipeline)...)
}
rcNode:
for _, rcNode := range service.FulfillingRCs {
for _, coveredDC := range service.FulfillingDCs {
if deployedges.BelongsToDeploymentConfig(coveredDC.DeploymentConfig, rcNode.ReplicationController) {
continue rcNode
}
}
printLines(out, indent, 1, describeRCInServiceGroup(rcNode)...)
}
pod:
for _, podNode := range service.FulfillingPods {
// skip pods that have been displayed in a roll-up of RCs and DCs (by implicit usage of RCs)
for _, coveredRC := range service.FulfillingRCs {
if g.Edge(podNode, coveredRC) != nil {
continue pod
}
}
printLines(out, indent, 1, describePodInServiceGroup(podNode)...)
}
for _, routeNode := range service.ExposingRoutes {
printLines(out, indent, 1, describeRouteInServiceGroup(routeNode)...)
}
}
for _, standaloneDC := range standaloneDCs {
fmt.Fprintln(out)
printLines(out, indent, 0, describeDeploymentInServiceGroup(standaloneDC)...)
}
for _, standaloneImage := range standaloneImages {
fmt.Fprintln(out)
lines := describeStandaloneBuildGroup(standaloneImage, namespace)
lines = append(lines, describeAdditionalBuildDetail(standaloneImage.Build, standaloneImage.LastSuccessfulBuild, standaloneImage.LastUnsuccessfulBuild, standaloneImage.ActiveBuilds, standaloneImage.DestinationResolved, true)...)
printLines(out, indent, 0, lines...)
}
for _, standaloneRC := range standaloneRCs {
fmt.Fprintln(out)
printLines(out, indent, 0, describeRCInServiceGroup(standaloneRC.RC)...)
}
allMarkers := osgraph.Markers{}
allMarkers = append(allMarkers, createForbiddenMarkers(forbiddenResources)...)
for _, scanner := range getMarkerScanners() {
allMarkers = append(allMarkers, scanner(g)...)
}
fmt.Fprintln(out)
sort.Stable(osgraph.ByKey(allMarkers))
sort.Stable(osgraph.ByNodeID(allMarkers))
errorMarkers := allMarkers.BySeverity(osgraph.ErrorSeverity)
errorSuggestions := 0
if len(errorMarkers) > 0 {
fmt.Fprintln(out, "Errors:")
//.........这里部分代码省略.........