本文整理匯總了Golang中github.com/openshift/origin/pkg/api/graph.UniqueName函數的典型用法代碼示例。如果您正苦於以下問題:Golang UniqueName函數的具體用法?Golang UniqueName怎麽用?Golang UniqueName使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了UniqueName函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestMissingSecrets
func TestMissingSecrets(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/bad_secret_refs.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllRequestedServiceAccountEdges(g)
kubeedges.AddAllMountableSecretEdges(g)
kubeedges.AddAllMountedSecretEdges(g)
markers := FindMissingSecrets(g, osgraph.DefaultNamer)
if e, a := 1, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
actualDC := osgraph.GetTopLevelContainerNode(g, markers[0].Node)
expectedDC := g.Find(osgraph.UniqueName("DeploymentConfig|/docker-nfs-server"))
if e, a := expectedDC.ID(), actualDC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
actualSecret := markers[0].RelatedNodes[0]
expectedSecret := g.Find(osgraph.UniqueName("Secret|/missing-secret"))
if e, a := expectedSecret.ID(), actualSecret.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
示例2: TestUnpushableBuild
func TestUnpushableBuild(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/unpushable-build.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
markers := FindUnpushableBuildConfigs(g)
if e, a := 1, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
actualBC := osgraph.GetTopLevelContainerNode(g, markers[0].Node)
expectedBC := g.Find(osgraph.UniqueName("BuildConfig|/ruby-hello-world"))
if e, a := expectedBC.ID(), actualBC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
actualIST := markers[0].RelatedNodes[0]
expectedIST := g.Find(osgraph.UniqueName("ImageStreamTag|/ruby-hello-world:latest"))
if e, a := expectedIST.ID(), actualIST.ID(); e != a {
t.Errorf("expected %v, got %v: \n%v", e, a, g)
}
}
示例3: TestDuelingRC
func TestDuelingRC(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/dueling-rcs.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllManagedByControllerPodEdges(g)
markers := FindDuelingReplicationControllers(g, osgraph.DefaultNamer)
if e, a := 2, len(markers); e != a {
t.Errorf("expected %v, got %v", e, a)
}
expectedRC1 := g.Find(osgraph.UniqueName("ReplicationController|/rc-1"))
expectedRC2 := g.Find(osgraph.UniqueName("ReplicationController|/rc-2"))
found1 := false
found2 := false
for i := 0; i < 2; i++ {
actualPod := osgraph.GetTopLevelContainerNode(g, markers[i].RelatedNodes[0])
expectedPod := g.Find(osgraph.UniqueName("Pod|/conflicted-pod"))
if e, a := expectedPod.ID(), actualPod.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
actualOtherRC := osgraph.GetTopLevelContainerNode(g, markers[i].RelatedNodes[1])
actualRC := markers[i].Node
if e, a := expectedRC1.ID(), actualRC.ID(); e == a {
found1 = true
expectedOtherRC := expectedRC2
if e, a := expectedOtherRC.ID(), actualOtherRC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
if e, a := expectedRC2.ID(), actualRC.ID(); e == a {
found2 = true
expectedOtherRC := expectedRC1
if e, a := expectedOtherRC.ID(), actualOtherRC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
}
if !found1 {
t.Errorf("expected %v, got %v", expectedRC1, markers)
}
if !found2 {
t.Errorf("expected %v, got %v", expectedRC2, markers)
}
}
示例4: TestUnpushableBuild
func TestUnpushableBuild(t *testing.T) {
// Unconfigured internal registry
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/unpushable-build.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
imageedges.AddAllImageStreamImageRefEdges(g)
markers := FindUnpushableBuildConfigs(g, osgraph.DefaultNamer)
if e, a := 2, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
if got, expected := markers[0].Key, MissingRequiredRegistryErr; got != expected {
t.Fatalf("expected marker key %q, got %q", expected, got)
}
actualBC := osgraph.GetTopLevelContainerNode(g, markers[0].Node)
expectedBC1 := g.Find(osgraph.UniqueName("BuildConfig|example/ruby-hello-world"))
expectedBC2 := g.Find(osgraph.UniqueName("BuildConfig|example/ruby-hello-world-2"))
if e1, e2, a := expectedBC1.ID(), expectedBC2.ID(), actualBC.ID(); e1 != a && e2 != a {
t.Errorf("expected either %v or %v, got %v", e1, e2, a)
}
actualIST := markers[0].RelatedNodes[0]
expectedIST := g.Find(osgraph.UniqueName("ImageStreamTag|example/ruby-hello-world:latest"))
if e, a := expectedIST.ID(), actualIST.ID(); e != a {
t.Errorf("expected %v, got %v: \n%v", e, a, g)
}
// Missing image stream
g, _, err = osgraphtest.BuildGraph("../../../api/graph/test/unpushable-build-2.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
buildedges.AddAllInputOutputEdges(g)
imageedges.AddAllImageStreamRefEdges(g)
imageedges.AddAllImageStreamImageRefEdges(g)
markers = FindUnpushableBuildConfigs(g, osgraph.DefaultNamer)
if e, a := 1, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
if got, expected := markers[0].Key, MissingOutputImageStreamErr; got != expected {
t.Fatalf("expected marker key %q, got %q", expected, got)
}
}
示例5: SourceRepositoryNodeName
func SourceRepositoryNodeName(source buildapi.BuildSource) osgraph.UniqueName {
switch {
case source.Git != nil:
sourceType, uri, ref := "git", source.Git.URI, source.Git.Ref
return osgraph.UniqueName(fmt.Sprintf("%s|%s|%s#%s", SourceRepositoryNodeKind, sourceType, uri, ref))
default:
panic(fmt.Sprintf("invalid build source: %v", source))
}
}
示例6: TestUnmountableSecrets
func TestUnmountableSecrets(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/bad_secret_refs.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllRequestedServiceAccountEdges(g)
kubeedges.AddAllMountableSecretEdges(g)
kubeedges.AddAllMountedSecretEdges(g)
markers := FindUnmountableSecrets(g, osgraph.DefaultNamer)
if e, a := 2, len(markers); e != a {
t.Errorf("expected %v, got %v", e, a)
}
expectedSecret1 := g.Find(osgraph.UniqueName("Secret|/missing-secret"))
expectedSecret2 := g.Find(osgraph.UniqueName("Secret|/unmountable-secret"))
found1 := false
found2 := false
for i := 0; i < 2; i++ {
actualDC := osgraph.GetTopLevelContainerNode(g, markers[i].Node)
expectedDC := g.Find(osgraph.UniqueName("DeploymentConfig|/docker-nfs-server"))
if e, a := expectedDC.ID(), actualDC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
actualSecret := markers[i].RelatedNodes[0]
if e, a := expectedSecret1.ID(), actualSecret.ID(); e == a {
found1 = true
}
if e, a := expectedSecret2.ID(), actualSecret.ID(); e == a {
found2 = true
}
}
if !found1 {
t.Errorf("expected %v, got %v", expectedSecret1, markers)
}
if !found2 {
t.Errorf("expected %v, got %v", expectedSecret2, markers)
}
}
示例7: TestMissingLivenessProbes
func TestMissingLivenessProbes(t *testing.T) {
g, _, err := osgraphtest.BuildGraph("../../../api/graph/test/simple-deployment.yaml")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
kubeedges.AddAllExposedPodEdges(g)
markers := FindMissingLivenessProbes(g, osgraph.DefaultNamer, "oc set probe")
if e, a := 1, len(markers); e != a {
t.Fatalf("expected %v, got %v", e, a)
}
actualDC := osgraph.GetTopLevelContainerNode(g, markers[0].Node)
expectedDC := g.Find(osgraph.UniqueName("DeploymentConfig|/simple-deployment"))
if e, a := expectedDC.ID(), actualDC.ID(); e != a {
t.Errorf("expected %v, got %v", e, a)
}
}
示例8: PodSpecNodeName
func PodSpecNodeName(o *kapi.PodSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", PodSpecNodeKind, ownerName))
}
示例9: ReplicationControllerSpecNodeName
func ReplicationControllerSpecNodeName(o *kapi.ReplicationControllerSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", ReplicationControllerSpecNodeKind, ownerName))
}
示例10: ImageLayerNodeName
func ImageLayerNodeName(layer string) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%s", ImageLayerNodeKind, layer))
}
示例11: DockerImageRepositoryNodeName
func DockerImageRepositoryNodeName(o imageapi.DockerImageReference) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%s", DockerRepositoryNodeKind, o.String()))
}
示例12: PetSetSpecNodeName
func PetSetSpecNodeName(o *kapps.PetSetSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", PetSetSpecNodeKind, ownerName))
}
示例13: ImageComponentNodeName
func ImageComponentNodeName(name string) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%s", ImageComponentNodeKind, name))
}
示例14: ImageStreamTagNodeName
func ImageStreamTagNodeName(o *imageapi.ImageStream, tag string) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%s/%s:%s", ImageStreamTagNodeKind, o.Namespace, o.Name, tag))
}
示例15: StatefulSetSpecNodeName
func StatefulSetSpecNodeName(o *kapps.StatefulSetSpec, ownerName osgraph.UniqueName) osgraph.UniqueName {
return osgraph.UniqueName(fmt.Sprintf("%s|%v", StatefulSetSpecNodeKind, ownerName))
}