aboutsummaryrefslogtreecommitdiff
path: root/CONTRIBUTING.md
blob: aa145a841d4c31301e4cd653eb71746af05732bf (plain)
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
41
42
# Coding style

Before submitting a pull request:

- Please format your code with `gofmt` or `goimports`.
- Please fix warnings generated by `golint` and `go vet`.
- When changing the API, run `godoc -http=:6060`, point your browser to
  http://localhost:6060/pkg/github.com/majewsky/schwift and check how your documentation looks.

As a general rule of thumb, we prefer idiomatic Go code as described in:

- [Effective Go](https://golang.org/doc/effective_go.html)
- [Collected Go Code Review Comments](https://github.com/golang/go/wiki/CodeReviewComments)

# Running the unit tests

The unit tests require a Swift server (duh).

## Using a Swift cluster

The preferred option is a regular Swift deployment: Run `go test` with the same authentication variables that you give
to the official `swift` client:

- for Swift inside an OpenStack cluster: `OS_AUTH_URL`, `OS_USERNAME`, `OS_PASSWORD`, etc.
- for Swift using its builtin authentication: `ST_AUTH`, `ST_USER`, `ST_KEY`

## Using a Swift All-in-One container

If you don't have a Swift deployment at your disposal where you're running the unit tests, you can use the scripts in
the [`testing` subdirectory](./testing/) to run a Swift all-in-one (SAIO) [development setup in a Docker
container](https://github.com/bouncestorage/docker-swift).

1. Run `./testing/start-saio.sh` to start the SAIO container (possibly with `sudo` if your user is not in the `docker`
   group). Once that has come up successfully, press Ctrl-C to get back to your terminal prompt; the SAIO container will
   continue running.

2. Run the tests with `./testing/with-saio.sh go test`. The script will find how to access the Swift API inside the
   container, and configure the auth environment variables accordingly. You can use this with any command that requires
   Swift credentials, e.g. `./testing/with-saio.sh swift stat`.

**WARNING:** At the time of this writing, https://github.com/bouncestorage/docker-swift/pull/30 has not been merged, so
you need to patch the proxy-server.conf manually to get the symlink-related tests to pass.