本文整理匯總了Golang中github.com/openshift/origin/test/extended/util.CLI.WithoutNamespace方法的典型用法代碼示例。如果您正苦於以下問題:Golang CLI.WithoutNamespace方法的具體用法?Golang CLI.WithoutNamespace怎麽用?Golang CLI.WithoutNamespace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/openshift/origin/test/extended/util.CLI
的用法示例。
在下文中一共展示了CLI.WithoutNamespace方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: testPruneImages
func testPruneImages(oc *exutil.CLI, schemaVersion int) {
var mediaType string
switch schemaVersion {
case 1:
mediaType = schema1.MediaTypeManifest
case 2:
mediaType = schema2.MediaTypeManifest
default:
g.Fail(fmt.Sprintf("unexpected schema version %d", schemaVersion))
}
oc.SetOutputDir(exutil.TestContext.OutputDir)
outSink := g.GinkgoWriter
cleanUp := cleanUpContainer{}
defer tearDownPruneImagesTest(oc, &cleanUp)
dClient, err := testutil.NewDockerClient()
o.Expect(err).NotTo(o.HaveOccurred())
g.By(fmt.Sprintf("build two images using Docker and push them as schema %d", schemaVersion))
imgPruneName, err := BuildAndPushImageOfSizeWithDocker(oc, dClient, "prune", "latest", testImageSize, 2, outSink, true)
o.Expect(err).NotTo(o.HaveOccurred())
cleanUp.imageNames = append(cleanUp.imageNames, imgPruneName)
pruneSize, err := getRegistryStorageSize(oc)
o.Expect(err).NotTo(o.HaveOccurred())
imgKeepName, err := BuildAndPushImageOfSizeWithDocker(oc, dClient, "prune", "latest", testImageSize, 2, outSink, true)
o.Expect(err).NotTo(o.HaveOccurred())
cleanUp.imageNames = append(cleanUp.imageNames, imgKeepName)
keepSize, err := getRegistryStorageSize(oc)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(pruneSize < keepSize).To(o.BeTrue())
g.By(fmt.Sprintf("ensure uploaded image is of schema %d", schemaVersion))
imgPrune, err := oc.AsAdmin().Client().Images().Get(imgPruneName)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(imgPrune.DockerImageManifestMediaType).To(o.Equal(mediaType))
imgKeep, err := oc.AsAdmin().Client().Images().Get(imgKeepName)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(imgKeep.DockerImageManifestMediaType).To(o.Equal(mediaType))
g.By("prune the first image uploaded (dry-run)")
output, err := oc.WithoutNamespace().Run("adm").Args("prune", "images", "--keep-tag-revisions=1", "--keep-younger-than=0").Output()
g.By("verify images, layers and configs about to be pruned")
o.Expect(output).To(o.ContainSubstring(imgPruneName))
if schemaVersion == 1 {
o.Expect(output).NotTo(o.ContainSubstring(imgPrune.DockerImageMetadata.ID))
} else {
o.Expect(output).To(o.ContainSubstring(imgPrune.DockerImageMetadata.ID))
}
for _, layer := range imgPrune.DockerImageLayers {
if !strings.Contains(output, layer.Name) {
o.Expect(output).To(o.ContainSubstring(layer.Name))
}
}
o.Expect(output).NotTo(o.ContainSubstring(imgKeepName))
o.Expect(output).NotTo(o.ContainSubstring(imgKeep.DockerImageMetadata.ID))
for _, layer := range imgKeep.DockerImageLayers {
if !strings.Contains(output, layer.Name) {
o.Expect(output).NotTo(o.ContainSubstring(layer.Name))
}
}
noConfirmSize, err := getRegistryStorageSize(oc)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(noConfirmSize).To(o.Equal(keepSize))
g.By("prune the first image uploaded (confirm)")
output, err = oc.WithoutNamespace().Run("adm").Args("prune", "images", "--keep-tag-revisions=1", "--keep-younger-than=0", "--confirm").Output()
g.By("verify images, layers and configs about to be pruned")
o.Expect(output).To(o.ContainSubstring(imgPruneName))
if schemaVersion == 1 {
o.Expect(output).NotTo(o.ContainSubstring(imgPrune.DockerImageMetadata.ID))
} else {
o.Expect(output).To(o.ContainSubstring(imgPrune.DockerImageMetadata.ID))
}
for _, layer := range imgPrune.DockerImageLayers {
if !strings.Contains(output, layer.Name) {
o.Expect(output).To(o.ContainSubstring(layer.Name))
}
}
o.Expect(output).NotTo(o.ContainSubstring(imgKeepName))
o.Expect(output).NotTo(o.ContainSubstring(imgKeep.DockerImageMetadata.ID))
for _, layer := range imgKeep.DockerImageLayers {
if !strings.Contains(output, layer.Name) {
o.Expect(output).NotTo(o.ContainSubstring(layer.Name))
}
}
confirmSize, err := getRegistryStorageSize(oc)
o.Expect(err).NotTo(o.HaveOccurred())
g.By(fmt.Sprintf("confirming storage size: sizeOfKeepImage=%d <= sizeAfterPrune=%d < beforePruneSize=%d", imgKeep.DockerImageMetadata.Size, confirmSize, keepSize))
o.Expect(confirmSize >= imgKeep.DockerImageMetadata.Size).To(o.BeTrue())
o.Expect(confirmSize < keepSize).To(o.BeTrue())
g.By(fmt.Sprintf("confirming pruned size: sizeOfPruneImage=%d <= (sizeAfterPrune=%d - sizeBeforePrune=%d)", imgPrune, keepSize, confirmSize))
o.Expect(imgPrune.DockerImageMetadata.Size <= keepSize-confirmSize).To(o.BeTrue())
//.........這裏部分代碼省略.........