@@ -23,19 +23,19 @@ import (
2323 "strings"
2424 "time"
2525
26+ "github.com/aws/aws-sdk-go/aws"
27+ "github.com/aws/aws-sdk-go/aws/credentials"
28+ "github.com/aws/aws-sdk-go/service/s3"
2629 "github.com/docker/docker/opts"
2730 "github.com/docker/docker/pkg/integration"
31+ "github.com/docker/docker/pkg/integration/checker"
2832 "github.com/docker/docker/pkg/ioutils"
2933 "github.com/docker/docker/pkg/stringutils"
3034 HyperCli "github.com/docker/engine-api/client"
3135 "github.com/docker/engine-api/types"
3236 "github.com/docker/go-connections/sockets"
3337 "github.com/docker/go-connections/tlsconfig"
3438 "github.com/go-check/check"
35- "github.com/aws/aws-sdk-go/service/s3"
36- "github.com/aws/aws-sdk-go/aws"
37- "github.com/aws/aws-sdk-go/aws/credentials"
38- "github.com/docker/docker/pkg/integration/checker"
3939)
4040
4141var flag_host = ""
@@ -622,7 +622,7 @@ func newRequestClient(method, endpoint string, data io.Reader, ct string) (*http
622622 client := httputil .NewClientConn (c , nil )
623623
624624 //save to postData
625- postData := fmt .Sprintf ("%v" ,data )
625+ postData := fmt .Sprintf ("%v" , data )
626626
627627 req , err := http .NewRequest (method , fmt .Sprintf ("/v1.23%s" , endpoint ), data )
628628 if err != nil {
@@ -644,13 +644,13 @@ func newRequestClient(method, endpoint string, data io.Reader, ct string) (*http
644644 if endpoint == debugEndpoint {
645645 //output curl command line
646646 fmt .Println ("\n --------------------------------------------------------------------------------------------" )
647- fmt .Printf ("debugEndpoint: %v (expired after 5min)\n " ,debugEndpoint )
647+ fmt .Printf ("debugEndpoint: %v (expired after 5min)\n " , debugEndpoint )
648648 fmt .Println ("--------------------------------------------------------------------------------------------" )
649649 fmt .Println ("curl -v -k \\ " )
650650 for k , v := range req .Header {
651651 fmt .Printf (" -H \" %v: %v\" \\ \n " , k , v [0 ])
652652 }
653- fmt .Printf (" -X %v \\ \n " , method )
653+ fmt .Printf (" -X %v \\ \n " , method )
654654 if req .Body != nil {
655655 fmt .Printf (" -d '%v' \\ \n " , postData )
656656 }
@@ -778,7 +778,6 @@ func getAllSnapshots() ([]*types.Snapshot, error) {
778778 return snapshots .Snapshots , nil
779779}
780780
781-
782781func deleteAllVolumes () error {
783782 volumes , err := getAllVolumes ()
784783 if err != nil {
@@ -934,6 +933,14 @@ func pullImageIfNotExist(image string) error {
934933 return nil
935934}
936935
936+ func pathExist (_path string ) bool {
937+ _ , err := os .Stat (_path )
938+ if err != nil && os .IsNotExist (err ) {
939+ return false
940+ }
941+ return true
942+ }
943+
937944func dockerCmdWithError (args ... string ) (string , int , error ) {
938945 arg := []string {"--host=" + os .Getenv ("DOCKER_HOST" )}
939946 args = append (arg , args ... )
@@ -1881,7 +1888,7 @@ func printTestDuration(start time.Time) {
18811888 fmt .Printf (" - %.6f sec\n " , duration )
18821889}
18831890
1884- func generateS3PreSignedURL (region ,s3bucket ,s3key string ) (string , error ) {
1891+ func generateS3PreSignedURL (region , s3bucket , s3key string ) (string , error ) {
18851892
18861893 accessKey := os .Getenv ("AWS_ACCESS_KEY" )
18871894 secretKey := os .Getenv ("AWS_SECRET_KEY" )
@@ -1892,7 +1899,7 @@ func generateS3PreSignedURL(region,s3bucket,s3key string) (string, error) {
18921899
18931900 s3cli := s3 .New (& aws.Config {
18941901 Credentials : credentials .NewStaticCredentials (accessKey , secretKey , "" ),
1895- Region : & region ,
1902+ Region : & region ,
18961903 })
18971904
18981905 r , _ := s3cli .GetObjectRequest (& s3.GetObjectInput {
@@ -1917,30 +1924,29 @@ func getImageInspect(c *check.C, imageName string) *types.ImageInspect {
19171924 return & image
19181925}
19191926
1920- func ensureImageExist (c * check.C , imageName string ){
1927+ func ensureImageExist (c * check.C , imageName string ) {
19211928 for i := 0 ; i < 3 ; i ++ {
19221929 if _err := pullImageIfNotExist (imageName ); _err != nil {
1923- c .Logf ("couldn't find the %s image locally and failed to pull it, try againt\n " ,imageName )
1930+ c .Logf ("couldn't find the %s image locally and failed to pull it, try againt\n " , imageName )
19241931 } else {
19251932 break
19261933 }
19271934 }
19281935}
19291936
19301937//get containerId or imageId from hyper command output
1931- func getIDfromOutput (c * check.C , output string )( string ) {
1938+ func getIDfromOutput (c * check.C , output string ) string {
19321939 outAry := strings .Split (output , "\n " )
1933- c .Assert (len (outAry ), checker .GreaterOrEqualThan ,2 )
1940+ c .Assert (len (outAry ), checker .GreaterOrEqualThan , 2 )
19341941 id := outAry [len (outAry )- 2 ]
19351942 return strings .TrimSpace (id )
19361943}
19371944
1938-
19391945func checkImage (c * check.C , shouldExist bool , imageName string ) {
19401946 images , _ := dockerCmd (c , "images" , imageName )
19411947 if shouldExist {
19421948 c .Assert (images , checker .Contains , imageName )
19431949 } else {
19441950 c .Assert (images , check .Not (checker .Contains ), imageName )
19451951 }
1946- }
1952+ }
0 commit comments