本文整理汇总了Golang中github.com/docker/docker/pkg/stringutils.GenerateRandomAlphaOnlyString函数的典型用法代码示例。如果您正苦于以下问题:Golang GenerateRandomAlphaOnlyString函数的具体用法?Golang GenerateRandomAlphaOnlyString怎么用?Golang GenerateRandomAlphaOnlyString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GenerateRandomAlphaOnlyString函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: newRemoteFileServer
func newRemoteFileServer(ctx *FakeContext) (*remoteFileServer, error) {
var (
image = fmt.Sprintf("fileserver-img-%s", strings.ToLower(stringutils.GenerateRandomAlphaOnlyString(10)))
container = fmt.Sprintf("fileserver-cnt-%s", strings.ToLower(stringutils.GenerateRandomAlphaOnlyString(10)))
)
// Build the image
if err := fakeContextAddDockerfile(ctx, `FROM httpserver
COPY . /static`); err != nil {
return nil, fmt.Errorf("Cannot add Dockerfile to context: %v", err)
}
if _, err := buildImageFromContext(image, ctx, false); err != nil {
return nil, fmt.Errorf("failed building file storage container image: %v", err)
}
// Start the container
runCmd := exec.Command(dockerBinary, "run", "-d", "-P", "--name", container, image)
if out, ec, err := runCommandWithOutput(runCmd); err != nil {
return nil, fmt.Errorf("failed to start file storage container. ec=%v\nout=%s\nerr=%v", ec, out, err)
}
// Find out the system assigned port
out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "port", container, "80/tcp"))
if err != nil {
return nil, fmt.Errorf("failed to find container port: err=%v\nout=%s", err, out)
}
return &remoteFileServer{
container: container,
image: image,
host: strings.Trim(out, "\n"),
ctx: ctx}, nil
}
开发者ID:bkeyoumarsi,项目名称:docker,代码行数:33,代码来源:docker_utils.go
示例2: RandomTmpDirPath
// RandomTmpDirPath provides a temporary path with rand string appended.
// does not create or checks if it exists.
func RandomTmpDirPath(s string) string {
tmp := "/tmp"
if runtime.GOOS == "windows" {
tmp = os.Getenv("TEMP")
}
return filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10)))
}
开发者ID:ai-traders,项目名称:docker,代码行数:9,代码来源:utils.go
示例3: TestTagInvalidPrefixedRepo
// ensure we don't allow the use of invalid tags; these tag operations should fail
func (s *DockerSuite) TestTagInvalidPrefixedRepo(c *check.C) {
longTag := stringutils.GenerateRandomAlphaOnlyString(121)
invalidTags := []string{"repo:fo$z$", "repo:[email protected]", "repo:Foo$3", "repo:Foo*3", "repo:Fo^3", "repo:Foo!3", "repo:%goodbye", "repo:#hashtagit", "repo:F)xcz(", "repo:-foo", "repo:..", longTag}
for _, repotag := range invalidTags {
out, _, err := dockerCmdWithError("tag", "busybox", repotag)
c.Assert(err, checker.NotNil, check.Commentf("tag busybox %v should have failed : %v", repotag, out))
}
}
开发者ID:CadeLaRen,项目名称:docker-3,代码行数:11,代码来源:docker_cli_tag_test.go
示例4: RandomTmpDirPath
// RandomTmpDirPath provides a temporary path with rand string appended.
// does not create or checks if it exists.
func RandomTmpDirPath(s string, platform string) string {
tmp := "/tmp"
if platform == "windows" {
tmp = os.Getenv("TEMP")
}
path := filepath.Join(tmp, fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10)))
if platform == "windows" {
return filepath.FromSlash(path) // Using \
}
return filepath.ToSlash(path) // Using /
}
开发者ID:CWSpear,项目名称:docker,代码行数:13,代码来源:utils.go
示例5: TestTagInvalidPrefixedRepo
// ensure we don't allow the use of invalid tags; these tag operations should fail
func (s *DockerSuite) TestTagInvalidPrefixedRepo(c *check.C) {
longTag := stringutils.GenerateRandomAlphaOnlyString(121)
invalidTags := []string{"repo:fo$z$", "repo:[email protected]", "repo:Foo$3", "repo:Foo*3", "repo:Fo^3", "repo:Foo!3", "repo:%goodbye", "repo:#hashtagit", "repo:F)xcz(", "repo:-foo", "repo:..", longTag}
for _, repotag := range invalidTags {
_, _, err := dockerCmdWithError("tag", "busybox", repotag)
if err == nil {
c.Fatalf("tag busybox %v should have failed", repotag)
}
}
}
开发者ID:nixuw,项目名称:docker,代码行数:13,代码来源:docker_cli_tag_test.go
示例6: newRemoteFileServer
func newRemoteFileServer(c *check.C, ctx *FakeContext) *remoteFileServer {
var (
image = fmt.Sprintf("fileserver-img-%s", strings.ToLower(stringutils.GenerateRandomAlphaOnlyString(10)))
container = fmt.Sprintf("fileserver-cnt-%s", strings.ToLower(stringutils.GenerateRandomAlphaOnlyString(10)))
)
c.Assert(ensureHTTPServerImage(), checker.IsNil)
// Build the image
fakeContextAddDockerfile(c, ctx, `FROM httpserver
COPY . /static`)
buildImageSuccessfully(c, image, withoutCache, withExternalBuildContext(ctx))
// Start the container
dockerCmd(c, "run", "-d", "-P", "--name", container, image)
// Find out the system assigned port
out, _ := dockerCmd(c, "port", container, "80/tcp")
fileserverHostPort := strings.Trim(out, "\n")
_, port, err := net.SplitHostPort(fileserverHostPort)
if err != nil {
c.Fatalf("unable to parse file server host:port: %v", err)
}
dockerHostURL, err := url.Parse(daemonHost())
if err != nil {
c.Fatalf("unable to parse daemon host URL: %v", err)
}
host, _, err := net.SplitHostPort(dockerHostURL.Host)
if err != nil {
c.Fatalf("unable to parse docker daemon host:port: %v", err)
}
return &remoteFileServer{
container: container,
image: image,
host: fmt.Sprintf("%s:%s", host, port),
ctx: ctx}
}
开发者ID:jfrazelle,项目名称:docker,代码行数:40,代码来源:docker_utils_test.go
示例7: TestInitializeCannotStatPathFileNameTooLong
// os.Stat(v.Path) is NOT returning ErrNotExist so skip and return error from
// initialize
func TestInitializeCannotStatPathFileNameTooLong(t *testing.T) {
// ENAMETOOLONG
v := &Volume{Path: stringutils.GenerateRandomAlphaOnlyString(300)}
err := v.initialize()
if err == nil {
t.Fatal("Expected not to initialize volume with a non existent path")
}
if !strings.Contains(err.Error(), "file name too long") {
t.Fatalf("Expected to get ENAMETOOLONG error, got %s", err)
}
}
开发者ID:nicholaskh,项目名称:docker,代码行数:15,代码来源:volume_test.go
示例8: TestInitializeCannotStatPathFileNameTooLong
// os.Stat(v.Path) is NOT returning ErrNotExist so skip and return error from
// initialize
func TestInitializeCannotStatPathFileNameTooLong(t *testing.T) {
// ENAMETOOLONG
v := &Volume{Path: stringutils.GenerateRandomAlphaOnlyString(300)}
err := v.initialize()
if err == nil {
t.Fatal("Expected not to initialize volume with a non existent path")
}
if os.IsNotExist(err) {
t.Fatal("Expected to not get ErrNotExist")
}
}
开发者ID:colebrumley,项目名称:docker,代码行数:15,代码来源:volume_test.go
示例9: TestTagInvalidPrefixedRepo
// ensure we don't allow the use of invalid tags; these tag operations should fail
func TestTagInvalidPrefixedRepo(t *testing.T) {
longTag := stringutils.GenerateRandomAlphaOnlyString(121)
invalidTags := []string{"repo:fo$z$", "repo:[email protected]", "repo:Foo$3", "repo:Foo*3", "repo:Fo^3", "repo:Foo!3", "repo:%goodbye", "repo:#hashtagit", "repo:F)xcz(", "repo:-foo", "repo:..", longTag}
for _, repotag := range invalidTags {
tagCmd := exec.Command(dockerBinary, "tag", "busybox", repotag)
_, _, err := runCommandWithOutput(tagCmd)
if err == nil {
t.Fatalf("tag busybox %v should have failed", repotag)
}
}
logDone("tag - busybox with invalid repo:tagnames --> must not work")
}
开发者ID:jankeromnes,项目名称:docker,代码行数:15,代码来源:docker_cli_tag_test.go
示例10: randomUnixTmpDirPath
// randomUnixTmpDirPath provides a temporary unix path with rand string appended.
// does not create or checks if it exists.
func randomUnixTmpDirPath(s string) string {
return path.Join("/tmp", fmt.Sprintf("%s.%s", s, stringutils.GenerateRandomAlphaOnlyString(10)))
}
开发者ID:paultag,项目名称:docker,代码行数:5,代码来源:utils.go
注:本文中的github.com/docker/docker/pkg/stringutils.GenerateRandomAlphaOnlyString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论