Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 12 additions & 27 deletions Demo.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,16 @@ Move into the go-test-bench directory.

`cd go-test-bench`

## Step 3 - Copy contrast_security.yaml to the go-test-bench directory
## Step 3 - Download contrast_security.yaml to the go-test-bench directory

Download your configuration YAML file from the Contrast environment by selecting the "Add agent" button.
To download your configuration YAML file from the Contrast environment, select "Add new" at the top right.
Select "Application". Select "Go" for your language, and select your operating system. Click "Install manually",
and choose "Direct download" for your installation method. Scroll down to "Configure the agent" >
"Use Connection Token" > "Use configuration editor".

In the configuration edtor, click "Export" in the top right. Click YAML > "Download".

To move the yaml file to the go-test-bench directory, run

`cp /path/to/config/contrast_security.yaml .`

Expand All @@ -44,6 +51,8 @@ The Go Test Bench supports the following frameworks:
* std (standard library `net/http`)
* [gin](https://github.com/gin-gonic/gin)
* [julienschmidt](https://github.com/julienschmidt/httprouter)
* [chi](https://github.com/go-chi/chi)
* [go-swagger](https://github.com/go-swagger/go-swagger)

If no framework is specified, the standard library is used.

Expand All @@ -55,32 +64,8 @@ If no framework is specified, the standard library is used.

---

## Maintaining your DEMO Environment

### Updating

To ensure an updated environment for demonstrations execute the following command from the go-test-bench directory.

```bash
./demo.sh update
```

### Resetting your DEMO environment

To ensure a clean and updated environment for demonstrations execute the following command from the go-test-bench directory.

```bash
./demo.sh reset
```

This will re-build your test bench with the most recent copies of the go-agent, contrast-service and test bench.

## Troubleshooting

### I updated my config but nothing changed

If you've updated your config locally you will need to reset your environment using the following command from your go-test-bench directory.

```bash
./demo.sh reset
```
If you've updated your config locally you will need to rebuild the image by running `./demo.sh` again.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.21
ARG GO_VERSION=latest
FROM golang:${GO_VERSION} AS builder

WORKDIR /build
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.agent
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GO_VERSION=1.21
ARG GO_VERSION=latest
FROM golang:${GO_VERSION} AS builder

WORKDIR /build
Expand Down
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,14 @@ the dir this README.md is in.
## How to Run Using Docker

```bash
# To stand up application with standard library
docker-compose up std -d
# Alternative: To stand up application with Gin framework
# docker-compose up gin -d
# To stand up application with Julienschmidt/httprouter:
# docker-compose up julienschmidt -d

# To stop app container and related service containers
docker-compose down
docker build -t image-name .
docker run -p 8080:8080 image-name
```

View app at [http://0.0.0.0:8080](http://0.0.0.0:8080)
To run with gin instead, pass in `--build-args FRAMEWORK=gin` in the build command,
and likewise for `chi`, `go-swagger`, or `julienschmidt`.

View app at [http://localhost:8080](http://localhost:8080)

## Acknowledgements

Expand Down
42 changes: 11 additions & 31 deletions demo.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,18 @@
#!/bin/bash

function clean() {
echo "Stopping Go Demo Containers"
docker-compose -f docker-compose.demo.yml stop

echo "Removing Go Demo Containers"
docker-compose -f docker-compose.demo.yml rm
}

function rebuild() {
echo "Re-Building Go Demo Environment"
docker-compose -f docker-compose.demo.yml build --no-cache
}

if [[ "$1" == "reset" ]]
then
clean
rebuild
elif [[ "$1" == "update" ]] ; then

clean

echo "Updating Go Test Bench"
git stash
git pull origin

rebuild
elif [[ "$1" == "gin" ]]; then
if [[ "$1" == "gin" ]]; then
echo "Starting Go Demo Container for Gin framework"
docker-compose -f docker-compose.demo.yml up gin
elif [[ "$1" == "julienschmidt" ]]; then
echo "Starting Go Demo Container for Julienschmidt/httprouter framework"
docker-compose -f docker-compose.demo.yml up julienschmidt
elif [[ "$1" == "go-swagger" ]]; then
echo "Starting Go Demo Container for Swagger framework"
elif [[ "$1" == "chi" ]]; then
echo "Starting Go Demo Container for Chi v5 framework"
else
echo "Starting Go Demo Container for standard library"
docker-compose -f docker-compose.demo.yml up std
fi
docker build -f Dockerfile.agent -t contrast-go-demo .
docker run -p 8080:8080 contrast-go-demo
exit 0
fi
docker build --build-arg FRAMEWORK=$1 -f Dockerfile.agent -t contrast-go-demo .
docker run -p 8080:8080 contrast-go-demo
46 changes: 0 additions & 46 deletions docker-compose.demo.yml

This file was deleted.

20 changes: 0 additions & 20 deletions docker-compose.yml

This file was deleted.

Loading