-
Notifications
You must be signed in to change notification settings - Fork 4
/
images.go
40 lines (32 loc) · 972 Bytes
/
images.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package helpers
import (
"encoding/base32"
"fmt"
"strings"
docker "github.com/fsouza/go-dockerclient"
"github.com/hyperledger/fabric/common/util"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
func AssertImagesExist(imageNames ...string) {
dockerClient, err := docker.NewClientFromEnv()
Expect(err).NotTo(HaveOccurred())
for _, imageName := range imageNames {
images, err := dockerClient.ListImages(docker.ListImagesOptions{
Filters: map[string][]string{"reference": {imageName}},
})
ExpectWithOffset(1, err).NotTo(HaveOccurred())
if len(images) != 1 {
Fail(fmt.Sprintf("missing required image: %s", imageName), 1)
}
}
}
// UniqueName generates base-32 enocded UUIDs for container names.
func UniqueName() string {
name := base32.StdEncoding.WithPadding(base32.NoPadding).EncodeToString(util.GenerateBytesUUID())
return strings.ToLower(name)
}