Skip to content

Commit

Permalink
Replace glide with Go modules (zalando#544)
Browse files Browse the repository at this point in the history
* And attempt to build with modules and remove glide
* new tools.go file to get code-generator dependency + updated codegen + remove Glide files and update docs
  • Loading branch information
erthalion authored and FxKu committed Oct 2, 2019
1 parent f0e2906 commit baae188
Show file tree
Hide file tree
Showing 21 changed files with 487 additions and 400 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ _testmain.go
*.test
*.prof
/vendor/
/.glide/
/build/
/docker/build/
.idea
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ go:
- "1.12.x"

before_install:
- go get github.com/Masterminds/glide
- go get github.com/mattn/goveralls

install:
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ scm-source.json: .git
echo '{\n "url": "git:$(GITURL)",\n "revision": "$(GITHEAD)",\n "author": "$(USER)",\n "status": "$(GITSTATUS)"\n}' > scm-source.json

tools:
@go get -u honnef.co/go/tools/cmd/staticcheck
@go get -u github.com/Masterminds/glide
GO111MODULE=on go get -u honnef.co/go/tools/cmd/staticcheck
GO111MODULE=on go get k8s.io/[email protected]

fmt:
@gofmt -l -w -s $(DIRS)
Expand All @@ -89,11 +89,11 @@ vet:
@staticcheck $(PKG)

deps:
@glide install --strip-vendor
GO111MODULE=on go mod vendor

test:
hack/verify-codegen.sh
@go test ./...
@go test ./pkg/...

e2e: docker # build operator image to be tested
cd e2e; make tools test clean
9 changes: 0 additions & 9 deletions delivery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ version: "2017-09-20"
pipeline:
- id: build-postgres-operator
type: script
env:
GOPATH: /root/go
OPERATOR_TOP_DIR: /root/go/src/github.com/zalando
commands:
- desc: 'Update'
cmd: |
Expand All @@ -20,10 +17,6 @@ pipeline:
mv go /usr/local
ln -s /usr/local/go/bin/go /usr/bin/go
go version
- desc: 'Symlink sources into the GOPATH'
cmd: |
mkdir -p $OPERATOR_TOP_DIR
ln -s $(pwd) $OPERATOR_TOP_DIR/postgres-operator
- desc: 'Build docker image'
cmd: |
export PATH=$PATH:$HOME/go/bin
Expand All @@ -39,11 +32,9 @@ pipeline:
- desc: 'Run unit tests'
cmd: |
export PATH=$PATH:$HOME/go/bin
cd $OPERATOR_TOP_DIR/postgres-operator
go test ./pkg/...
- desc: 'Run e2e tests'
cmd: |
cd $OPERATOR_TOP_DIR/postgres-operator
make e2e
- desc: 'Push docker image'
cmd: |
Expand Down
24 changes: 7 additions & 17 deletions docs/developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,17 @@ git clone https://github.com/zalando/postgres-operator.git

## Building the operator

You need Glide to fetch all dependencies. Install it with:
We use [Go Modules](https://github.com/golang/go/wiki/Modules) for handling
dependencies. When using Go below v1.13 you need to explicitly enable Go modules
by setting the `GO111MODULE` environment variable to `on`. The make targets do
this for you, so simply run

```bash
make tools
```

Next, install dependencies with glide by issuing:

```bash
make deps
make tools deps
```

This would take a while to complete. You have to redo `make deps` every time
you dependencies list changes, i.e. after adding a new library dependency.
your dependencies list changes, i.e. after adding a new library dependency.

Build the operator with the `make docker` command. You may define the TAG
variable to assign an explicit tag to your docker image and the IMAGE to set
Expand Down Expand Up @@ -214,14 +211,7 @@ dlv connect 127.0.0.1:DLV_PORT
To run all unit tests, you can simply do:

```bash
go test ./...
```

For go 1.9 `vendor` directory would be excluded automatically. For previous
versions you can exclude it manually:

```bash
go test $(glide novendor)
go test ./pkg/...
```

In case if you need to debug your unit test, it's possible to use delve:
Expand Down
Loading

0 comments on commit baae188

Please sign in to comment.