本文整理汇总了Golang中github.com/openshift/origin/pkg/build/graph/nodes.EnsureBuildNode函数的典型用法代码示例。如果您正苦于以下问题:Golang EnsureBuildNode函数的具体用法?Golang EnsureBuildNode怎么用?Golang EnsureBuildNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EnsureBuildNode函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddToGraph
func (l *buildLoader) AddToGraph(g osgraph.Graph) error {
for i := range l.items {
buildgraph.EnsureBuildNode(g, &l.items[i])
}
return nil
}
示例2: addBuildsToGraph
// addBuildsToGraph adds builds to the graph.
//
// Edges are added to the graph from each build to the image specified by its strategy.from.
func addBuildsToGraph(g graph.Graph, builds *buildapi.BuildList) {
for i := range builds.Items {
build := &builds.Items[i]
glog.V(4).Infof("Examining build %s/%s", build.Namespace, build.Name)
buildNode := buildgraph.EnsureBuildNode(g, build)
addBuildStrategyImageReferencesToGraph(g, build.Spec.Strategy, buildNode)
}
}
示例3: loadBuilds
func loadBuilds(g osgraph.Graph, graphLock sync.Mutex, namespace string, kclient kclient.Interface, client client.Interface) error {
builds, err := client.Builds(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return err
}
graphLock.Lock()
defer graphLock.Unlock()
for i := range builds.Items {
buildgraph.EnsureBuildNode(g, &builds.Items[i])
}
return nil
}
示例4: TestNamespaceEdgeMatching
func TestNamespaceEdgeMatching(t *testing.T) {
g := osgraph.New()
fn := func(namespace string, g osgraph.Interface) {
bc := &api.BuildConfig{}
bc.Namespace = namespace
bc.Name = "the-bc"
nodes.EnsureBuildConfigNode(g, bc)
b := &api.Build{}
b.Namespace = namespace
b.Name = "the-build"
b.Labels = map[string]string{api.BuildConfigLabel: "the-bc"}
b.Annotations = map[string]string{api.BuildConfigAnnotation: "the-bc"}
nodes.EnsureBuildNode(g, b)
}
fn("ns", g)
fn("other", g)
AddAllBuildEdges(g)
if len(g.Edges()) != 2 {
t.Fatal(g)
}
for _, edge := range g.Edges() {
nsTo, err := namespaceFor(edge.To())
if err != nil {
t.Fatal(err)
}
nsFrom, err := namespaceFor(edge.From())
if err != nil {
t.Fatal(err)
}
if nsFrom != nsTo {
t.Errorf("edge %#v crosses namespace: %s %s", edge, nsFrom, nsTo)
}
}
}
示例5: TestGraph
func TestGraph(t *testing.T) {
g := osgraph.New()
now := time.Now()
builds := []buildapi.Build{
{
ObjectMeta: kapi.ObjectMeta{
Name: "build1-1-abc",
Labels: map[string]string{buildapi.BuildConfigLabel: "build1"},
CreationTimestamp: util.NewTime(now.Add(-10 * time.Second)),
},
Status: buildapi.BuildStatus{
Phase: buildapi.BuildPhaseFailed,
},
},
{
ObjectMeta: kapi.ObjectMeta{
Name: "build1-2-abc",
Labels: map[string]string{buildapi.BuildConfigLabel: "build1"},
CreationTimestamp: util.NewTime(now.Add(-5 * time.Second)),
},
Status: buildapi.BuildStatus{
Phase: buildapi.BuildPhaseComplete,
},
},
{
ObjectMeta: kapi.ObjectMeta{
Name: "build1-3-abc",
Labels: map[string]string{buildapi.BuildConfigLabel: "build1"},
CreationTimestamp: util.NewTime(now.Add(-15 * time.Second)),
},
Status: buildapi.BuildStatus{
Phase: buildapi.BuildPhasePending,
},
},
}
for i := range builds {
buildgraph.EnsureBuildNode(g, &builds[i])
}
buildgraph.EnsureBuildConfigNode(g, &buildapi.BuildConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "build1"},
Spec: buildapi.BuildConfigSpec{
Triggers: []buildapi.BuildTriggerPolicy{
{
ImageChange: &buildapi.ImageChangeTrigger{},
},
},
BuildSpec: buildapi.BuildSpec{
Strategy: buildapi.BuildStrategy{
Type: buildapi.SourceBuildStrategyType,
SourceStrategy: &buildapi.SourceBuildStrategy{
From: kapi.ObjectReference{Kind: "ImageStreamTag", Name: "test:base-image"},
},
},
Output: buildapi.BuildOutput{
To: &kapi.ObjectReference{Kind: "ImageStreamTag", Name: "other:tag1"},
},
},
},
})
bcTestNode := buildgraph.EnsureBuildConfigNode(g, &buildapi.BuildConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "test"},
Spec: buildapi.BuildConfigSpec{
BuildSpec: buildapi.BuildSpec{
Output: buildapi.BuildOutput{
To: &kapi.ObjectReference{Kind: "ImageStreamTag", Name: "other:base-image"},
},
},
},
})
buildgraph.EnsureBuildConfigNode(g, &buildapi.BuildConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "build2"},
Spec: buildapi.BuildConfigSpec{
BuildSpec: buildapi.BuildSpec{
Output: buildapi.BuildOutput{
To: &kapi.ObjectReference{Kind: "DockerImage", Name: "mycustom/repo/image:tag2"},
},
},
},
})
kubegraph.EnsureServiceNode(g, &kapi.Service{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "svc-is-ignored"},
Spec: kapi.ServiceSpec{
Selector: nil,
},
})
kubegraph.EnsureServiceNode(g, &kapi.Service{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "svc1"},
Spec: kapi.ServiceSpec{
Selector: map[string]string{
"deploymentconfig": "deploy1",
},
},
})
kubegraph.EnsureServiceNode(g, &kapi.Service{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "svc2"},
Spec: kapi.ServiceSpec{
Selector: map[string]string{
"deploymentconfig": "deploy1",
"env": "prod",
//.........这里部分代码省略.........