本文整理汇总了Golang中github.com/openshift/origin/pkg/api/kubegraph/nodes.EnsureSecretNode函数的典型用法代码示例。如果您正苦于以下问题:Golang EnsureSecretNode函数的具体用法?Golang EnsureSecretNode怎么用?Golang EnsureSecretNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EnsureSecretNode函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddToGraph
func (l *secretLoader) AddToGraph(g osgraph.Graph) error {
for i := range l.items {
kubegraph.EnsureSecretNode(g, &l.items[i])
}
return nil
}
示例2: TestSecretEdges
func TestSecretEdges(t *testing.T) {
sa := &kapi.ServiceAccount{}
sa.Namespace = "ns"
sa.Name = "shultz"
sa.Secrets = []kapi.ObjectReference{{Name: "i-know-nothing"}, {Name: "missing"}}
secret1 := &kapi.Secret{}
secret1.Namespace = "ns"
secret1.Name = "i-know-nothing"
pod := &kapi.Pod{}
pod.Namespace = "ns"
pod.Name = "the-pod"
pod.Spec.Volumes = []kapi.Volume{{Name: "rose", VolumeSource: kapi.VolumeSource{Secret: &kapi.SecretVolumeSource{SecretName: "i-know-nothing"}}}}
g := osgraph.New()
saNode := kubegraph.EnsureServiceAccountNode(g, sa)
secretNode := kubegraph.EnsureSecretNode(g, secret1)
podNode := kubegraph.EnsurePodNode(g, pod)
AddAllMountableSecretEdges(g)
AddAllMountedSecretEdges(g)
if edge := g.Edge(saNode, secretNode); edge == nil {
t.Errorf("edge missing")
} else {
if !g.EdgeKinds(edge).Has(MountableSecretEdgeKind) {
t.Errorf("expected %v, got %v", MountableSecretEdgeKind, edge)
}
}
podSpecNodes := g.SuccessorNodesByNodeAndEdgeKind(podNode, kubegraph.PodSpecNodeKind, osgraph.ContainsEdgeKind)
if len(podSpecNodes) != 1 {
t.Fatalf("wrong number of podspecs: %v", podSpecNodes)
}
if edge := g.Edge(podSpecNodes[0], secretNode); edge == nil {
t.Errorf("edge missing")
} else {
if !g.EdgeKinds(edge).Has(MountedSecretEdgeKind) {
t.Errorf("expected %v, got %v", MountedSecretEdgeKind, edge)
}
}
}