本文整理汇总了Golang中github.com/openshift/origin/pkg/deploy/graph/nodes.EnsureDeploymentConfigNode函数的典型用法代码示例。如果您正苦于以下问题:Golang EnsureDeploymentConfigNode函数的具体用法?Golang EnsureDeploymentConfigNode怎么用?Golang EnsureDeploymentConfigNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EnsureDeploymentConfigNode函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: AddToGraph
func (l *dcLoader) AddToGraph(g osgraph.Graph) error {
for i := range l.items {
deploygraph.EnsureDeploymentConfigNode(g, &l.items[i])
}
return nil
}
开发者ID:iconoeugen,项目名称:origin,代码行数:7,代码来源:projectstatus.go
示例2: TestHPADCEdges
func TestHPADCEdges(t *testing.T) {
hpa := &autoscaling.HorizontalPodAutoscaler{}
hpa.Namespace = "test-ns"
hpa.Name = "test-hpa"
hpa.Spec = autoscaling.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscaling.CrossVersionObjectReference{
Name: "test-dc",
Kind: "DeploymentConfig",
},
}
dc := &deployapi.DeploymentConfig{}
dc.Name = "test-dc"
dc.Namespace = "test-ns"
g := osgraph.New()
hpaNode := kubegraph.EnsureHorizontalPodAutoscalerNode(g, hpa)
dcNode := deploygraph.EnsureDeploymentConfigNode(g, dc)
AddHPAScaleRefEdges(g)
if edge := g.Edge(hpaNode, dcNode); edge == nil {
t.Fatalf("edge between HPA and DC missing")
} else {
if !g.EdgeKinds(edge).Has(ScalingEdgeKind) {
t.Errorf("expected edge to have kind %v, got %v", ScalingEdgeKind, edge)
}
}
}
开发者ID:juanluisvaladas,项目名称:origin,代码行数:29,代码来源:edge_test.go
示例3: addDeploymentConfigsToGraph
// addDeploymentConfigsToGraph adds deployment configs to the graph.
//
// Edges are added to the graph from each deployment config to the images
// specified by its pod spec's list of containers, as long as the image is
// managed by OpenShift.
func addDeploymentConfigsToGraph(g graph.Graph, dcs *deployapi.DeploymentConfigList) {
for i := range dcs.Items {
dc := &dcs.Items[i]
glog.V(4).Infof("Examining DeploymentConfig %s/%s", dc.Namespace, dc.Name)
dcNode := deploygraph.EnsureDeploymentConfigNode(g, dc)
addPodSpecToGraph(g, &dc.Template.ControllerTemplate.Template.Spec, dcNode)
}
}
开发者ID:jhadvig,项目名称:origin,代码行数:13,代码来源:imagepruner.go
示例4: MakeGraph
func (d *ProjectStatusDescriber) MakeGraph(namespace string) (osgraph.Graph, error) {
g := osgraph.New()
svcs, err := d.K.Services(namespace).List(labels.Everything())
if err != nil {
return g, err
}
iss, err := d.C.ImageStreams(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return g, err
}
bcs, err := d.C.BuildConfigs(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return g, err
}
dcs, err := d.C.DeploymentConfigs(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return g, err
}
builds := &buildapi.BuildList{}
if len(bcs.Items) > 0 {
if b, err := d.C.Builds(namespace).List(labels.Everything(), fields.Everything()); err == nil {
builds = b
}
}
rcs, err := d.K.ReplicationControllers(namespace).List(labels.Everything())
if err != nil {
rcs = &kapi.ReplicationControllerList{}
}
for i := range iss.Items {
imagegraph.EnsureImageStreamNode(g, &iss.Items[i])
imagegraph.EnsureAllImageStreamTagNodes(g, &iss.Items[i])
}
for i := range bcs.Items {
build := buildgraph.EnsureBuildConfigNode(g, &bcs.Items[i])
buildedges.AddInputOutputEdges(g, build)
buildedges.JoinBuilds(build, builds.Items)
}
for i := range dcs.Items {
deploy := deploygraph.EnsureDeploymentConfigNode(g, &dcs.Items[i])
deployedges.AddTriggerEdges(g, deploy)
deployedges.JoinDeployments(deploy, rcs.Items)
}
for i := range svcs.Items {
service := kubegraph.EnsureServiceNode(g, &svcs.Items[i])
kubeedges.AddExposedPodTemplateSpecEdges(g, service)
}
imageedges.AddAllImageStreamRefEdges(g)
return g, nil
}
开发者ID:lucasjo,项目名称:origin,代码行数:58,代码来源:projectstatus.go
示例5: loadDeploymentConfigs
func loadDeploymentConfigs(g osgraph.Graph, graphLock sync.Mutex, namespace string, kclient kclient.Interface, client client.Interface) error {
dcs, err := client.DeploymentConfigs(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return err
}
graphLock.Lock()
defer graphLock.Unlock()
for i := range dcs.Items {
deploygraph.EnsureDeploymentConfigNode(g, &dcs.Items[i])
}
return nil
}
开发者ID:Risar,项目名称:origin,代码行数:14,代码来源:projectstatus.go
示例6: Describe
// Describe returns the description of the latest deployments for a config
func (d *LatestDeploymentsDescriber) Describe(namespace, name string) (string, error) {
var f formatter
config, err := d.client.getDeploymentConfig(namespace, name)
if err != nil {
return "", err
}
var deployments []kapi.ReplicationController
if d.count == -1 || d.count > 1 {
list, err := d.client.listDeployments(namespace, labels.Everything())
if err != nil && !kerrors.IsNotFound(err) {
return "", err
}
deployments = list.Items
} else {
deploymentName := deployutil.LatestDeploymentNameForConfig(config)
deployment, err := d.client.getDeployment(config.Namespace, deploymentName)
if err != nil && !kerrors.IsNotFound(err) {
return "", err
}
if deployment != nil {
deployments = []kapi.ReplicationController{*deployment}
}
}
g := graph.New()
dcNode := deploygraph.EnsureDeploymentConfigNode(g, config)
for i := range deployments {
kubegraph.EnsureReplicationControllerNode(g, &deployments[i])
}
deployedges.AddTriggerEdges(g, dcNode)
deployedges.AddDeploymentEdges(g, dcNode)
activeDeployment, inactiveDeployments := deployedges.RelevantDeployments(g, dcNode)
return tabbedString(func(out *tabwriter.Writer) error {
descriptions := describeDeployments(f, dcNode, activeDeployment, inactiveDeployments, d.count)
for i, description := range descriptions {
descriptions[i] = fmt.Sprintf("%v %v", name, description)
}
printLines(out, "", 0, descriptions...)
return nil
})
}
开发者ID:Thomas-T,项目名称:origin,代码行数:45,代码来源:deployments.go
示例7: TestNamespaceEdgeMatching
func TestNamespaceEdgeMatching(t *testing.T) {
g := osgraph.New()
fn := func(namespace string, g osgraph.Interface) {
dc := &api.DeploymentConfig{}
dc.Namespace = namespace
dc.Name = "the-dc"
dc.Spec.Selector = map[string]string{"a": "1"}
nodes.EnsureDeploymentConfigNode(g, dc)
rc := &kapi.ReplicationController{}
rc.Namespace = namespace
rc.Name = "the-rc"
rc.Annotations = map[string]string{api.DeploymentConfigAnnotation: "the-dc"}
kubegraph.EnsureReplicationControllerNode(g, rc)
}
fn("ns", g)
fn("other", g)
AddAllDeploymentEdges(g)
if len(g.Edges()) != 4 {
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)
}
}
}
开发者ID:RomainVabre,项目名称:origin,代码行数:38,代码来源:edge_test.go
示例8: 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.BuildStatusFailed,
},
{
ObjectMeta: kapi.ObjectMeta{
Name: "build1-2-abc",
Labels: map[string]string{buildapi.BuildConfigLabel: "build1"},
CreationTimestamp: util.NewTime(now.Add(-5 * time.Second)),
},
Status: buildapi.BuildStatusComplete,
},
{
ObjectMeta: kapi.ObjectMeta{
Name: "build1-3-abc",
Labels: map[string]string{buildapi.BuildConfigLabel: "build1"},
CreationTimestamp: util.NewTime(now.Add(-15 * time.Second)),
},
Status: buildapi.BuildStatusPending,
},
}
bc1Node := buildgraph.EnsureBuildConfigNode(g, &buildapi.BuildConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "build1"},
Triggers: []buildapi.BuildTriggerPolicy{
{
ImageChange: &buildapi.ImageChangeTrigger{},
},
},
Parameters: buildapi.BuildParameters{
Strategy: buildapi.BuildStrategy{
Type: buildapi.SourceBuildStrategyType,
SourceStrategy: &buildapi.SourceBuildStrategy{
From: kapi.ObjectReference{Kind: "ImageStreamTag", Name: "test:base-image"},
},
},
Output: buildapi.BuildOutput{
To: &kapi.ObjectReference{Name: "other"},
Tag: "tag1",
},
},
})
buildedges.JoinBuilds(bc1Node, builds)
bcTestNode := buildgraph.EnsureBuildConfigNode(g, &buildapi.BuildConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "test"},
Parameters: buildapi.BuildParameters{
Output: buildapi.BuildOutput{
To: &kapi.ObjectReference{Name: "other"},
Tag: "base-image",
},
},
})
buildgraph.EnsureBuildConfigNode(g, &buildapi.BuildConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "default", Name: "build2"},
Parameters: buildapi.BuildParameters{
Output: buildapi.BuildOutput{
DockerImageReference: "mycustom/repo/image",
Tag: "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",
},
},
})
deploygraph.EnsureDeploymentConfigNode(g, &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "other", Name: "deploy1"},
Triggers: []deployapi.DeploymentTriggerPolicy{
{
ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{
From: kapi.ObjectReference{Namespace: "default", Name: "other"},
ContainerNames: []string{"1", "2"},
Tag: "tag1",
//.........这里部分代码省略.........
开发者ID:cjnygard,项目名称:origin,代码行数:101,代码来源:graph_test.go
示例9: TestGraph
//.........这里部分代码省略.........
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",
},
},
})
deploygraph.EnsureDeploymentConfigNode(g, &deployapi.DeploymentConfig{
ObjectMeta: kapi.ObjectMeta{Namespace: "other", Name: "deploy1"},
Triggers: []deployapi.DeploymentTriggerPolicy{
{
ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{
From: kapi.ObjectReference{Namespace: "default", Name: "other"},
ContainerNames: []string{"1", "2"},
Tag: "tag1",
},
},
},
Template: deployapi.DeploymentTemplate{
ControllerTemplate: kapi.ReplicationControllerSpec{
Template: &kapi.PodTemplateSpec{
ObjectMeta: kapi.ObjectMeta{
Labels: map[string]string{
"deploymentconfig": "deploy1",
"env": "prod",
},
},
Spec: kapi.PodSpec{
Containers: []kapi.Container{
{
Name: "1",
Image: "mycustom/repo/image",
},
{
Name: "2",
Image: "mycustom/repo/image2",
},
{
Name: "3",
Image: "mycustom/repo/image3",
开发者ID:dctse,项目名称:openshift-cucumber,代码行数:67,代码来源:veneering_test.go
示例10: Describe
// Describe returns the description of a project
func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error) {
project, err := d.C.Projects().Get(namespace)
if err != nil {
return "", err
}
svcs, err := d.K.Services(namespace).List(labels.Everything())
if err != nil {
return "", err
}
bcs, err := d.C.BuildConfigs(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return "", err
}
dcs, err := d.C.DeploymentConfigs(namespace).List(labels.Everything(), fields.Everything())
if err != nil {
return "", err
}
builds := &buildapi.BuildList{}
if len(bcs.Items) > 0 {
if b, err := d.C.Builds(namespace).List(labels.Everything(), fields.Everything()); err == nil {
builds = b
}
}
rcs, err := d.K.ReplicationControllers(namespace).List(labels.Everything())
if err != nil {
rcs = &kapi.ReplicationControllerList{}
}
g := graph.New()
for i := range bcs.Items {
build := buildgraph.EnsureBuildConfigNode(g, &bcs.Items[i])
buildedges.AddInputOutputEdges(g, build)
buildedges.JoinBuilds(build, builds.Items)
}
for i := range dcs.Items {
deploy := deploygraph.EnsureDeploymentConfigNode(g, &dcs.Items[i])
deployedges.AddTriggerEdges(g, deploy)
deployedges.JoinDeployments(deploy, rcs.Items)
}
for i := range svcs.Items {
service := kubegraph.EnsureServiceNode(g, &svcs.Items[i])
kubeedges.AddExposedPodTemplateSpecEdges(g, service)
}
groups := graphveneers.ServiceAndDeploymentGroups(g)
return tabbedString(func(out *tabwriter.Writer) error {
indent := " "
fmt.Fprintf(out, "In project %s\n", projectapi.DisplayNameAndNameForProject(project))
for _, group := range groups {
if len(group.Builds) != 0 {
for _, build := range group.Builds {
fmt.Fprintln(out)
printLines(out, indent, 0, describeStandaloneBuildGroup(build, namespace)...)
printLines(out, indent, 1, describeAdditionalBuildDetail(build.Build, true)...)
}
continue
}
if len(group.Services) == 0 {
for _, deploy := range group.Deployments {
fmt.Fprintln(out)
printLines(out, indent, 0, describeDeploymentInServiceGroup(deploy)...)
}
continue
}
fmt.Fprintln(out)
for _, svc := range group.Services {
printLines(out, indent, 0, describeServiceInServiceGroup(svc)...)
}
for _, deploy := range group.Deployments {
printLines(out, indent, 1, describeDeploymentInServiceGroup(deploy)...)
}
}
if len(groups) == 0 {
fmt.Fprintln(out, "\nYou have no Services, DeploymentConfigs, or BuildConfigs. 'oc new-app' can be used to create applications from scratch from existing Docker images and templates.")
} else {
fmt.Fprintln(out, "\nTo see more information about a Service or DeploymentConfig, use 'oc describe service <name>' or 'oc describe dc <name>'.")
fmt.Fprintln(out, "You can use 'oc get all' to see lists of each of the types described above.")
}
return nil
})
}
开发者ID:cjnygard,项目名称:origin,代码行数:90,代码来源:projectstatus.go
注:本文中的github.com/openshift/origin/pkg/deploy/graph/nodes.EnsureDeploymentConfigNode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论