Skip to content

Commit

Permalink
Keep command lines apps in cmd folder (#335)
Browse files Browse the repository at this point in the history
Have a consistent pattern of folder structure keep builds applications
under the `cmd` folder.

* `cli/cli.go` -> `cmd/cli/cli.go`
* `cmd/toxiproxy.go` -> `cmd/server/server.go`

It remove confusion of 2 folders in same folder: `cli` and `client`.
  • Loading branch information
miry authored Oct 22, 2021
1 parent 3c89301 commit 6934e8e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ before:
builds:
- &build_default
id: server
main: ./cmd
main: ./cmd/server
binary: toxiproxy-server-{{.Os}}-{{.Arch}}
no_unique_dist_dir: true
env:
Expand Down Expand Up @@ -39,7 +39,7 @@ builds:

- <<: *build_default
id: client
main: ./cli
main: ./cmd/cli
binary: toxiproxy-cli-{{.Os}}-{{.Arch}}


Expand All @@ -51,7 +51,7 @@ builds:
- <<: *build_default
id: pkg-client
no_unique_dist_dir: false
main: ./cli
main: ./cmd/cli
binary: toxiproxy-cli

checksum:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# [Unreleased]

* Store all the executable `main` packages in `cmd` folder. (#335, @miry)

# [2.2.0]

* Update linux packages to use `/usr/bin` folder as binary destination and change the executable names to
Expand Down
15 changes: 9 additions & 6 deletions CREATING_TOXICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ This is used instead of just a plain `byte[]` so that toxics like latency can fi
how long a chunk of data has been waiting in the proxy.

Toxics are registered in an `init()` function so that they can be used by the server:

```go
func init() {
toxics.Register("toxic_name", new(ExampleToxic))
}
```

In order to use your own toxics, you will need to compile your own binary. This can be
done by copying [toxiproxy.go](https://github.com/Shopify/toxiproxy/blob/master/cmd/toxiproxy.go)
into a new project and registering your toxic with the server. This will allow you to add toxics
without having to make a full fork of the project. If you think your toxics will be useful
to others, contribute them back with a Pull Request.
In order to use your own toxics, you will need to compile your own binary.
This can be done by copying [server
](https://github.com/Shopify/toxiproxy/blob/master/cmd/server/server.go)
into a new project and registering your toxic with the server.
This will allow you to add toxics without having to make a full fork of the project.
If you think your toxics will be useful to others,
contribute them back with a Pull Request.

An example project for building a separate binary can be found here:
An example project for building a separate binary can be found here:
https://github.com/xthexder/toxic-example

## A basic toxic
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ e2e: build

.PHONY: build
build: dist clean
go build -ldflags="-s -w" -o ./dist/toxiproxy-server ./cmd
go build -ldflags="-s -w" -o ./dist/toxiproxy-cli ./cli
go build -ldflags="-s -w" -o ./dist/toxiproxy-server ./cmd/server
go build -ldflags="-s -w" -o ./dist/toxiproxy-cli ./cmd/cli

.PHONY: release
release:
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 6934e8e

Please sign in to comment.