本文整理汇总了Golang中github.com/openshift/origin/pkg/api/kubegraph.AddAllExposedPodTemplateSpecEdges函数的典型用法代码示例。如果您正苦于以下问题:Golang AddAllExposedPodTemplateSpecEdges函数的具体用法?Golang AddAllExposedPodTemplateSpecEdges怎么用?Golang AddAllExposedPodTemplateSpecEdges使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddAllExposedPodTemplateSpecEdges函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestBareDCGroup
func TestBareDCGroup(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/bare-dc.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllExposedPodTemplateSpecEdges(g)
buildedges.AddAllInputOutputEdges(g)
deployedges.AddAllTriggerEdges(g)
coveredNodes := IntSet{}
serviceGroups, coveredByServiceGroups := AllServiceGroups(g, coveredNodes)
coveredNodes.Insert(coveredByServiceGroups.List()...)
bareDCPipelines, coveredByDCs := AllDeploymentConfigPipelines(g, coveredNodes)
coveredNodes.Insert(coveredByDCs.List()...)
bareBCPipelines, coveredByBCs := AllImagePipelinesFromBuildConfig(g, coveredNodes)
coveredNodes.Insert(coveredByBCs.List()...)
if e, a := 0, len(serviceGroups); e != a {
t.Errorf("expected %v, got %v", e, a)
}
if e, a := 1, len(bareDCPipelines); e != a {
t.Errorf("expected %v, got %v", e, a)
}
if e, a := 0, len(bareBCPipelines); e != a {
t.Errorf("expected %v, got %v", e, a)
}
if e, a := 1, len(bareDCPipelines[0].Images); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
示例2: TestBareRCGroup
func TestBareRCGroup(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/bare-rc.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllExposedPodTemplateSpecEdges(g)
kubeedges.AddAllExposedPodEdges(g)
kubeedges.AddAllManagedByRCPodEdges(g)
coveredNodes := IntSet{}
serviceGroups, coveredByServiceGroups := AllServiceGroups(g, coveredNodes)
coveredNodes.Insert(coveredByServiceGroups.List()...)
bareRCs, coveredByRCs := AllReplicationControllers(g, coveredNodes)
coveredNodes.Insert(coveredByRCs.List()...)
if e, a := 1, len(serviceGroups); e != a {
t.Errorf("expected %v, got %v", e, a)
}
if e, a := 1, len(bareRCs); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
示例3: MakeGraph
func (d *ProjectStatusDescriber) MakeGraph(namespace string) (osgraph.Graph, sets.String, error) {
g := osgraph.New()
loaders := []GraphLoader{
&serviceLoader{namespace: namespace, lister: d.K},
&serviceAccountLoader{namespace: namespace, lister: d.K},
&secretLoader{namespace: namespace, lister: d.K},
&rcLoader{namespace: namespace, lister: d.K},
&podLoader{namespace: namespace, lister: d.K},
// TODO check swagger for feature enablement and selectively add bcLoader and buildLoader
// then remove errors.TolerateNotFoundError method.
&bcLoader{namespace: namespace, lister: d.C},
&buildLoader{namespace: namespace, lister: d.C},
&isLoader{namespace: namespace, lister: d.C},
&dcLoader{namespace: namespace, lister: d.C},
&routeLoader{namespace: namespace, lister: d.C},
}
loadingFuncs := []func() error{}
for _, loader := range loaders {
loadingFuncs = append(loadingFuncs, loader.Load)
}
forbiddenResources := sets.String{}
if errs := parallel.Run(loadingFuncs...); len(errs) > 0 {
actualErrors := []error{}
for _, err := range errs {
if kapierrors.IsForbidden(err) {
forbiddenErr := err.(*kapierrors.StatusError)
if (forbiddenErr.Status().Details != nil) && (len(forbiddenErr.Status().Details.Kind) > 0) {
forbiddenResources.Insert(forbiddenErr.Status().Details.Kind)
}
continue
}
actualErrors = append(actualErrors, err)
}
if len(actualErrors) > 0 {
return g, forbiddenResources, utilerrors.NewAggregate(actualErrors)
}
}
for _, loader := range loaders {
loader.AddToGraph(g)
}
kubeedges.AddAllExposedPodTemplateSpecEdges(g)
kubeedges.AddAllExposedPodEdges(g)
kubeedges.AddAllManagedByRCPodEdges(g)
kubeedges.AddAllRequestedServiceAccountEdges(g)
kubeedges.AddAllMountableSecretEdges(g)
kubeedges.AddAllMountedSecretEdges(g)
buildedges.AddAllInputOutputEdges(g)
buildedges.AddAllBuildEdges(g)
deployedges.AddAllTriggerEdges(g)
deployedges.AddAllDeploymentEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
routeedges.AddAllRouteEdges(g)
return g, forbiddenResources, nil
}
示例4: MakeGraph
func (d *ProjectStatusDescriber) MakeGraph(namespace string) (osgraph.Graph, error) {
g := osgraph.New()
loaders := []GraphLoader{
&serviceLoader{namespace: namespace, lister: d.K},
&serviceAccountLoader{namespace: namespace, lister: d.K},
&secretLoader{namespace: namespace, lister: d.K},
&rcLoader{namespace: namespace, lister: d.K},
&podLoader{namespace: namespace, lister: d.K},
&bcLoader{namespace: namespace, lister: d.C},
&buildLoader{namespace: namespace, lister: d.C},
&isLoader{namespace: namespace, lister: d.C},
&dcLoader{namespace: namespace, lister: d.C},
}
loadingFuncs := []func() error{}
for _, loader := range loaders {
loadingFuncs = append(loadingFuncs, loader.Load)
}
if errs := parallel.Run(loadingFuncs...); len(errs) > 0 {
return g, utilerrors.NewAggregate(errs)
}
for _, loader := range loaders {
loader.AddToGraph(g)
}
kubeedges.AddAllExposedPodTemplateSpecEdges(g)
kubeedges.AddAllExposedPodEdges(g)
kubeedges.AddAllManagedByRCPodEdges(g)
kubeedges.AddAllRequestedServiceAccountEdges(g)
kubeedges.AddAllMountableSecretEdges(g)
kubeedges.AddAllMountedSecretEdges(g)
buildedges.AddAllInputOutputEdges(g)
buildedges.AddAllBuildEdges(g)
deployedges.AddAllTriggerEdges(g)
deployedges.AddAllDeploymentEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
return g, nil
}
示例5: MakeGraph
func (d *ProjectStatusDescriber) MakeGraph(namespace string) (osgraph.Graph, error) {
g := osgraph.New()
loadingFuncs := []GraphLoadingFunc{loadServices, loadBuildConfigs, loadImageStreams, loadDeploymentConfigs, loadBuilds, loadReplicationControllers}
listingWaitGroup := sync.WaitGroup{}
graphLock := sync.Mutex{}
errorChannel := make(chan error, len(loadingFuncs))
for _, loadingFunc := range loadingFuncs {
listingWaitGroup.Add(1)
go func(loadingFunc GraphLoadingFunc) {
defer listingWaitGroup.Done()
if err := loadingFunc(g, graphLock, namespace, d.K, d.C); err != nil {
errorChannel <- err
}
}(loadingFunc)
}
listingWaitGroup.Wait()
close(errorChannel)
// if we had an error. Aggregate them and return them
errlist := []error{}
for err := range errorChannel {
errlist = append(errlist, err)
}
if len(errlist) > 0 {
return g, utilerrors.NewAggregate(errlist)
}
kubeedges.AddAllExposedPodTemplateSpecEdges(g)
buildedges.AddAllInputOutputEdges(g)
buildedges.AddAllBuildEdges(g)
deployedges.AddAllTriggerEdges(g)
deployedges.AddAllDeploymentEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
return g, nil
}
示例6: TestGraph
//.........这里部分代码省略.........
Name: "3",
Image: "mycustom/repo/image3",
},
},
},
},
},
},
})
deploygraph.EnsureDeploymentConfigNode(g, &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "deploy2"},
Template: deployapi.DeploymentTemplate{
ControllerTemplate: kapi.ReplicationControllerSpec{
Template: &kapi.PodTemplateSpec{
ObjectMeta: kapi.ObjectMeta{
Labels: map[string]string{
"deploymentconfig": "deploy2",
"env": "dev",
},
},
Spec: kapi.PodSpec{
Containers: []kapi.Container{
{
Name: "1",
Image: "someother/image:v1",
},
},
},
},
},
},
})
kubeedges.AddAllExposedPodTemplateSpecEdges(g)
buildedges.AddAllInputOutputEdges(g)
deployedges.AddAllTriggerEdges(g)
t.Log(g)
ir, dc, bc, other := 0, 0, 0, 0
for _, node := range g.NodeList() {
switch g.Object(node).(type) {
case *deployapi.DeploymentConfig:
if g.Kind(node) != deploygraph.DeploymentConfigNodeKind {
t.Fatalf("unexpected kind: %v", g.Kind(node))
}
dc++
case *buildapi.BuildConfig:
if g.Kind(node) != buildgraph.BuildConfigNodeKind {
t.Fatalf("unexpected kind: %v", g.Kind(node))
}
bc++
case *imageapi.ImageStream:
// TODO resolve this check for 2 kinds, since both have the same object type
if g.Kind(node) != imagegraph.ImageStreamNodeKind && g.Kind(node) != imagegraph.ImageStreamTagNodeKind {
t.Fatalf("unexpected kind: %v", g.Kind(node))
}
ir++
default:
other++
}
}
if dc != 2 || bc != 3 || ir != 3 || other != 12 {
t.Errorf("unexpected nodes: %d %d %d %d", dc, bc, ir, other)
}
示例7: TestGraph
//.........这里部分代码省略.........
Name: "3",
Image: "mycustom/repo/image3",
},
},
},
},
},
},
})
deploygraph.EnsureDeploymentConfigNode(g, &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "deploy2"},
Template: deployapi.DeploymentTemplate{
ControllerTemplate: kapi.ReplicationControllerSpec{
Template: &kapi.PodTemplateSpec{
ObjectMeta: kapi.ObjectMeta{
Labels: map[string]string{
"deploymentconfig": "deploy2",
"env": "dev",
},
},
Spec: kapi.PodSpec{
Containers: []kapi.Container{
{
Name: "1",
Image: "someother/image:v1",
},
},
},
},
},
},
})
kubeedges.AddAllExposedPodTemplateSpecEdges(g)
buildedges.AddAllInputOutputEdges(g)
buildedges.AddAllBuildEdges(g)
deployedges.AddAllTriggerEdges(g)
deployedges.AddAllDeploymentEdges(g)
t.Log(g)
for _, edge := range g.Edges() {
if g.EdgeKinds(edge).Has(osgraph.UnknownEdgeKind) {
t.Errorf("edge reported unknown kind: %#v", edge)
}
}
// imagestreamtag default/other:base-image
istID := 0
for _, node := range g.Nodes() {
if g.Name(node) == "ImageStreamTag|default/other:base-image" {
istID = node.ID()
break
}
}
edge := g.Edge(concrete.Node(bcTestNode.ID()), concrete.Node(istID))
if edge == nil {
t.Fatalf("failed to find edge between %d and %d", bcTestNode.ID(), istID)
}
if len(g.SubgraphWithNodes([]graph.Node{edge.From(), edge.To()}, osgraph.ExistingDirectEdge).Edges()) != 1 {
t.Fatalf("expected one edge")
}
if len(g.SubgraphWithNodes([]graph.Node{edge.To(), edge.From()}, osgraph.ExistingDirectEdge).Edges()) != 1 {
t.Fatalf("expected one edge")
}