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