HewlettPackard / oneview-golang

Golang bindings for OneView api's
Apache License 2.0
27 stars 21 forks source link

Building DockerImage fails with the current Go version #106

Closed soodpr closed 6 years ago

soodpr commented 6 years ago

Trying to build the image results in below error: Step 1/6 : FROM golang:1.6.2

---> 8ecba0e9bd48

Step 2/6 : RUN go get github.com/golang/lint/golint github.com/mattn/goveralls golang.org/x/tools/cover github.com/tools/godep github.com/aktau/github-release

---> Running in 44f55cfe816c

# golang.org/x/tools/go/internal/gcimporter src/golang.org/x/tools/go/internal/gcimporter/iimport.go:90: undefined: io.SeekCurrent src/golang.org/x/tools/go/internal/gcimporter/iimport.go:93: undefined: io.SeekCurrent src/golang.org/x/tools/go/internal/gcimporter/iimport.go:169: undefined: io.SeekCurrent src/golang.org/x/tools/go/internal/gcimporter/iimport.go:200: r.declReader.Reset undefined (type bytes.Reader has no field or method Reset) src/golang.org/x/tools/go/internal/gcimporter/iimport.go:239: r.declReader.Reset undefined (type bytes.Reader has no field or method Reset)  # github.com/aktau/github-release src/github.com/aktau/github-release/cmd.go:96: enc.SetIndent undefined (type *json.Encoder has no field or method SetIndent)  Removing intermediate container 44f55cfe816c

The command '/bin/sh -c go get github.com/golang/lint/golint github.com/mattn/goveralls golang.org/x/tools/cover github.com/tools/godep github.com/aktau/github-release' returned a non-zero code: 2

Solution: Can be fixed by upgrading the Go version from 1.6.2 to 1.10.4

patrickdappollonio commented 6 years ago

Hello @soodpr,

I'm no longer with HPE but I used to work on this project before. You're technically not using the vendored dependencies, but rather, using your own. Rather than using go get to fetch the dependencies, please use glide, or by default, pin the dependency versions to the proper versions as specified in the glide.lock file.

The project pulls with no issue at all... If you do go get -u github.com/HewlettPackard/oneview-golang the download is successful and after doing go test you do get:

?       github.com/HewlettPackard/oneview-golang    [no test files]
?       github.com/HewlettPackard/oneview-golang/i3s    [no test files]
?       github.com/HewlettPackard/oneview-golang/icsp   [no test files]
ok      github.com/HewlettPackard/oneview-golang/liboneview 0.016s
?       github.com/HewlettPackard/oneview-golang/ov [no test files]
ok      github.com/HewlettPackard/oneview-golang/rest   0.019s
ok      github.com/HewlettPackard/oneview-golang/testconfig 0.009s [no tests to run]
ok      github.com/HewlettPackard/oneview-golang/utils  0.016s

Edit: I'm building the app with Go 1.11. Go has a compatibility promise. As long as the code doesn't change you can build old Go applications with newer versions of Go, so updating from Go 1.6.2 to 1.10.4 shouldn't make a difference in compilation result, but rather only in the compiled binary.

dh2mom247 commented 6 years ago

+1 - thanks Patrick!

soodpr commented 6 years ago

@patrickdappollonio - Thanks for the response. I am trying to build the docker image which refers to DockerFile that contains go get commands as shown here https://github.com/HewlettPackard/oneview-golang/blob/ac3de6c231b1527a7ee0197f182b30f063d11416/Dockerfile#L3

I've modified the Go version to 1.10.4 and was able to build the docker image with the docker build command. So, thought that go get commands are failing with the previous GO version.

patrickdappollonio commented 6 years ago

Unfortunately, during my time there, I don't think anyone updated that file after we moved the code to glide. I can provide some updated Dockerfile in a couple of hours if you guys can wait.

Edit: most likely that Dockerfile was going to be used eventually to automate releases via Github (the project github-release is being pulled), which makes me believe it wasn't really used. You can remove these lines or leave something like this:

FROM golang:1.11

WORKDIR /go/src/github.com/HewlettPackard/oneview-golang

COPY . /go/src/github.com/HewlettPackard/oneview-golang
RUN go build github.com/HewlettPackard/oneview-golang