本文整理汇总了Golang中github.com/pivotal-golang/archiver/extractor/test_helper.CreateZipArchive函数的典型用法代码示例。如果您正苦于以下问题:Golang CreateZipArchive函数的具体用法?Golang CreateZipArchive怎么用?Golang CreateZipArchive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CreateZipArchive函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: createEnvBuildpack
func createEnvBuildpack() string {
tmpPath, err := ioutil.TempDir("", "buildpack-cats")
Expect(err).ToNot(HaveOccurred())
buildpackArchivePath := path.Join(tmpPath, "buildpack.zip")
archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{
{
Name: "bin/compile",
Body: `#!/usr/bin/env bash
echo "STAGED WITH CUSTOM BUILDPACK"
mkdir -p $1 $2
if [ -f "$2/cached-file" ]; then
cp $2/cached-file $1/content
else
echo "cache not found" > $1/content
fi
env
content=$(cat $1/content)
echo "web: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo "custom buildpack contents - $content"; } | nc -l \$PORT; done" > $1/Procfile
echo "here's a cache" > $2/cached-file
`,
},
{
Name: "bin/detect",
Body: `#!/bin/bash
echo no
exit 1
`,
},
{
Name: "bin/release",
Body: `#!/usr/bin/env bash
cat <<EOF
---
config_vars:
PATH: bin:/usr/local/bin:/usr/bin:/bin
FROM_BUILD_PACK: "yes"
default_process_types:
web: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo "custom buildpack contents - $content"; } | nc -l \$PORT; done
EOF
`,
},
})
return buildpackArchivePath
}
开发者ID:cf-routing,项目名称:cf-acceptance-tests,代码行数:54,代码来源:service_bindings_test.go
示例2:
archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{
{
Name: "bin/compile",
Body: `#!/usr/bin/env bash
sleep 5 # give loggregator time to start streaming the logs
echo "Staging with Simple Buildpack"
sleep 10
`,
},
{
Name: "bin/detect",
Body: fmt.Sprintf(`#!/bin/bash
if [ -f "${1}/%s" ]; then
echo Simple
else
echo no
exit 1
fi
`, matchingFilename(appName)),
},
{
Name: "bin/release",
Body: `#!/usr/bin/env bash
cat <<EOF
---
config_vars:
PATH: bin:/usr/local/bin:/usr/bin:/bin
FROM_BUILD_PACK: "yes"
default_process_types:
web: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo "hi from a simple admin buildpack"; } | nc -l \$PORT; done
EOF
`,
},
})
开发者ID:naheedmk,项目名称:cf-acceptance-tests,代码行数:39,代码来源:admin_buildpack_lifecycle_test.go
示例3:
archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{
{
Name: "bin/compile",
Body: `#!/usr/bin/env bash
mkdir -p $1 $2
if [ -f "$2/cached-file" ]; then
cp $2/cached-file $1/content
else
echo "cache not found" > $1/content
fi
echo "here's a cache" > $2/cached-file
`,
},
{
Name: "bin/detect",
Body: fmt.Sprintf(`#!/bin/bash
if [ -f "${1}/%s" ]; then
echo Buildpack that needs cache
else
echo no
exit 1
fi
`, matchingFilename(appName)),
},
{
Name: "bin/release",
Body: `#!/usr/bin/env bash
content=$(cat $1/content)
cat <<EOF
---
config_vars:
PATH: bin:/usr/local/bin:/usr/bin:/bin
FROM_BUILD_PACK: "yes"
default_process_types:
web: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo "custom buildpack contents - $content"; } | nc -l \$PORT; done
EOF
`,
},
})
开发者ID:naheedmk,项目名称:cf-acceptance-tests,代码行数:44,代码来源:buildpack_cache_test.go
示例4:
archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{
{
Name: "bin/compile",
Body: `#!/usr/bin/env bash
sleep 5
echo RUBY_LOCATION=$(which ruby)
echo RUBY_VERSION=$(ruby --version)
sleep 10
`,
},
{
Name: "bin/detect",
Body: fmt.Sprintf(`#!/bin/bash
if [ -f "${1}/%s" ]; then
echo Simple
else
echo no
exit 1
fi
`, matchingFilename(appName)),
},
{
Name: "bin/release",
Body: `#!/usr/bin/env bash
cat <<EOF
---
config_vars:
PATH: bin:/usr/local/bin:/usr/bin:/bin
FROM_BUILD_PACK: "yes"
default_process_types:
web: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo "hi from a simple admin buildpack"; } | nc -l \$PORT; done
EOF
`,
},
})
开发者ID:naheedmk,项目名称:cf-acceptance-tests,代码行数:40,代码来源:app_staging_environment_test.go
示例5:
"-cellID", cellBID,
"-listenAddr", cellBRepAddr,
"-evacuationTimeout", "30s",
"-containerOwnerName", cellBID+"-executor",
)
cellA = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
{"rep", cellARepRunner},
}))
cellB = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
{"rep", cellBRepRunner},
}))
test_helper.CreateZipArchive(
filepath.Join(fileServerStaticDir, "lrp.zip"),
fixtures.GoServerApp(),
)
})
AfterEach(func() {
helpers.StopProcesses(runtime, cellA, cellB)
})
It("handles evacuation", func() {
By("desiring an LRP")
lrp := helpers.DefaultLRPCreateRequest(processGuid, "log-guid", 1)
lrp.Setup = &models.DownloadAction{
From: fmt.Sprintf("http://%s/v1/static/%s", componentMaker.Addresses.FileServer, "lrp.zip"),
To: "/tmp",
User: "vcap",
}
开发者ID:Gerg,项目名称:inigo,代码行数:32,代码来源:evacuation_test.go
示例6:
archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{
{
Name: "bin/compile",
Body: `#!/usr/bin/env bash
sleep 5
cat /etc/lsb-release
sleep 10
`,
},
{
Name: "bin/detect",
Body: fmt.Sprintf(`#!/bin/bash
if [ -f "${1}/%s" ]; then
echo Simple
else
echo no
exit 1
fi
`, matchingFilename(appName)),
},
{
Name: "bin/release",
Body: `#!/usr/bin/env bash
cat <<EOF
---
config_vars:
PATH: bin:/usr/local/bin:/usr/bin:/bin
FROM_BUILD_PACK: "yes"
default_process_types:
web: while true; do { echo -e 'HTTP/1.1 200 OK\r\n'; echo -e "\$(cat /etc/lsb-release)"; } | nc -l \$PORT; done
EOF
`,
},
})
开发者ID:vito,项目名称:cf-acceptance-tests,代码行数:39,代码来源:app_stack_test.go
示例7:
BeforeEach(func() {
buildpacksToUse, _ = createBuildpack("test-buildpack", "test-buildpack-key", buildpack_zip)
outputGuid = helpers.GenerateGuid()
memory = 128
helpers.Copy(
componentMaker.Artifacts.Lifecycles[componentMaker.DefaultStack()],
filepath.Join(fileServerStaticDir, world.LifecycleFilename),
)
//make and upload an app
var appFiles = []zip_helper.ArchiveFile{
{Name: "my-app", Body: "scooby-doo"},
}
zip_helper.CreateZipArchive(filepath.Join(fileServerStaticDir, "app.zip"), appFiles)
//make and upload a buildpack
zip_helper.CreateZipArchive(
filepath.Join(fileServerStaticDir, buildpack_zip),
adminBuildpackFiles,
)
var bustedAdminBuildpackFiles = []zip_helper.ArchiveFile{
{
Name: "bin/detect",
Body: `#!/bin/sh
exit 1
`},
{Name: "bin/compile", Body: `#!/bin/sh`},
{Name: "bin/release", Body: `#!/bin/sh`},
开发者ID:Gerg,项目名称:inigo,代码行数:31,代码来源:stager_test.go
示例8:
tmpPath, err := ioutil.TempDir("", "env-group-staging")
Expect(err).ToNot(HaveOccurred())
buildpackArchivePath := path.Join(tmpPath, "buildpack.zip")
archive_helpers.CreateZipArchive(buildpackArchivePath, []archive_helpers.ArchiveFile{
{
Name: "bin/compile",
Body: `#!/usr/bin/env bash
sleep 5
echo $CATS_STAGING_TEST_VAR
exit 1
`,
},
{
Name: "bin/detect",
Body: `#!/bin/bash
exit 1
`,
},
{
Name: "bin/release",
Body: `#!/usr/bin/env bash
exit 1
`,
},
})
return buildpackArchivePath
}
var originalRunningEnv string
开发者ID:JordanICollier,项目名称:cf-acceptance-tests,代码行数:32,代码来源:environment_variables_group_test.go
示例9:
runningLRPsPoller func() []receptor.ActualLRPResponse
helloWorldInstancePoller func() []string
)
BeforeEach(func() {
fileServer, fileServerStaticDir := componentMaker.FileServer()
runtime = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
{"file-server", fileServer},
{"route-emitter", componentMaker.RouteEmitter()},
{"router", componentMaker.Router()},
}))
archive_helper.CreateZipArchive(
filepath.Join(fileServerStaticDir, "lrp.zip"),
fixtures.HelloWorldIndexLRP(),
)
appId = helpers.GenerateGuid()
processGuid = helpers.GenerateGuid()
runningLRPsPoller = func() []receptor.ActualLRPResponse {
return helpers.ActiveActualLRPs(receptorClient, processGuid)
}
helloWorldInstancePoller = helpers.HelloWorldInstancePoller(componentMaker.Addresses.Router, helpers.DefaultHost)
})
AfterEach(func() {
By("Stopping all the processes")
开发者ID:Gerg,项目名称:inigo,代码行数:31,代码来源:converger_test.go
示例10:
{"receptor", componentMaker.Receptor()},
{"rep", componentMaker.Rep()},
{"auctioneer", componentMaker.Auctioneer()},
{"route-emitter", componentMaker.RouteEmitter()},
{"converger", componentMaker.Converger()},
{"router", componentMaker.Router()},
{"file-server", fileServer},
}))
bridge = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
{"tps-listener", componentMaker.TPSListener()},
{"nsync-listener", componentMaker.NsyncListener()},
}))
archive_helper.CreateZipArchive(
filepath.Join(fileServerStaticDir, "droplet.zip"),
fixtures.HelloWorldIndexApp(),
)
helpers.Copy(
componentMaker.Artifacts.Lifecycles[componentMaker.DefaultStack()],
filepath.Join(fileServerStaticDir, world.LifecycleFilename),
)
})
AfterEach(func() {
helpers.StopProcesses(runtime, bridge)
})
Describe("Start an application", func() {
guid := "process-guid"
开发者ID:Gerg,项目名称:inigo,代码行数:31,代码来源:cc_app_test.go
示例11:
fileServer, fileServerStaticDir = componentMaker.FileServer()
runtime = ginkgomon.Invoke(grouper.NewParallel(os.Kill, grouper.Members{
{"router", componentMaker.Router()},
{"file-server", fileServer},
{"rep", componentMaker.Rep()},
{"converger", componentMaker.Converger()},
{"auctioneer", componentMaker.Auctioneer()},
{"route-emitter", componentMaker.RouteEmitter()},
}))
archiveFiles = fixtures.GoServerApp()
})
JustBeforeEach(func() {
archive_helper.CreateZipArchive(
filepath.Join(fileServerStaticDir, "lrp.zip"),
archiveFiles,
)
})
AfterEach(func() {
helpers.StopProcesses(runtime)
})
Describe("desiring", func() {
var lrp receptor.DesiredLRPCreateRequest
BeforeEach(func() {
lrp = helpers.DefaultLRPCreateRequest(processGuid, "log-guid", 1)
lrp.Setup = &models.DownloadAction{
From: fmt.Sprintf("http://%s/v1/static/%s", componentMaker.Addresses.FileServer, "lrp.zip"),
To: "/tmp",
开发者ID:Gerg,项目名称:inigo,代码行数:32,代码来源:lrp_test.go
示例12:
Expect(emptyDirInfo.IsDir()).To(BeTrue())
target, err := os.Readlink(filepath.Join(extractionDest, "some-symlink"))
Expect(err).NotTo(HaveOccurred())
Expect(target).To(Equal("some-file"))
symlinkInfo, err := os.Lstat(filepath.Join(extractionDest, "some-symlink"))
Expect(err).NotTo(HaveOccurred())
Expect(symlinkInfo.Mode() & 0755).To(Equal(os.FileMode(0755)))
}
Context("when the file is a zip archive", func() {
BeforeEach(func() {
test_helper.CreateZipArchive(extractionSrc, archiveFiles)
})
Context("when 'unzip' is on the PATH", func() {
BeforeEach(func() {
_, err := exec.LookPath("unzip")
Expect(err).NotTo(HaveOccurred())
})
It("extracts the ZIP's files, generating directories, and honoring file permissions and symlinks", extractionTest)
})
Context("when 'unzip' is not in the PATH", func() {
var oldPATH string
BeforeEach(func() {
开发者ID:gitter-badger,项目名称:alkasir,代码行数:30,代码来源:extractor_test.go
注:本文中的github.com/pivotal-golang/archiver/extractor/test_helper.CreateZipArchive函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论