Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uplift code to remove deprecations, update go & packages #139

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ plan.out

.idea/

build/
build/

rover
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ COPY ./ui/src ./src
RUN NODE_OPTIONS='--openssl-legacy-provider' npm run build

# Build rover
FROM golang:1.21 AS rover
FROM golang:1.23.2 AS rover
WORKDIR /src
# Copy full source
COPY . .
Expand All @@ -32,6 +32,7 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o rover .
FROM hashicorp/terraform:$TF_VERSION AS release
# Copy terraform binary to the rover's default terraform path
RUN cp /bin/terraform /usr/local/bin/terraform

# Copy rover binary
COPY --from=rover /src/rover /bin/rover
RUN chmod +x /bin/rover
Expand Down
72 changes: 36 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The fastest way to get up and running with Rover is through Docker.

Run the following command in any Terraform workspace to generate a visualization. This command copies all the files in your current directory to the Rover container and exposes port `:9000`.

```
```shell
$ docker run --rm -it -p 9000:9000 -v $(pwd):/src im2nguyen/rover
2021/07/02 06:46:23 Starting Rover...
2021/07/02 06:46:23 Initializing Terraform...
Expand All @@ -39,23 +39,23 @@ Use `-planJSONPath` to start Rover on Terraform plan file. The `plan.json` file

First, generate the plan file in JSON format.

```
$ terraform plan -out plan.out
$ terraform show -json plan.out > plan.json
```shell
terraform plan -out plan.out
terraform show -json plan.out > plan.json
```

Then, run Rover on it.

```
$ docker run --rm -it -p 9000:9000 -v $(pwd)/plan.json:/src/plan.json im2nguyen/rover:latest -planJSONPath=plan.json
```shell
docker run --rm -it -p 9000:9000 -v $(pwd)/plan.json:/src/plan.json im2nguyen/rover:latest -planJSONPath=plan.json
```

### Standalone mode

Standalone mode generates a `rover.zip` file containing all the static assets.

```
$ docker run --rm -it -p 9000:9000 -v "$(pwd):/src" im2nguyen/rover -standalone true
```shell
docker run --rm -it -p 9000:9000 -v "$(pwd):/src" im2nguyen/rover -standalone true
```

After all the assets are generated, unzip `rover.zip` and open `rover/index.html` in your favourite web browser.
Expand All @@ -64,30 +64,30 @@ After all the assets are generated, unzip `rover.zip` and open `rover/index.html

Use `--env` or `--env-file` to set environment variables in the Docker container. For example, you can save your AWS credentials to a `.env` file.

```
$ printenv | grep "AWS" > .env
```shell
printenv | grep "AWS" > .env
```

Then, add it as environment variables to your Docker container with `--env-file`.

```
$ docker run --rm -it -p 9000:9000 -v "$(pwd):/src" --env-file ./.env im2nguyen/rover
```shell
docker run --rm -it -p 9000:9000 -v "$(pwd):/src" --env-file ./.env im2nguyen/rover
```

### Define tfbackend, tfvars and Terraform variables

Use `-tfBackendConfig` to define backend config files and `-tfVarsFile` or `-tfVar` to define variables. For example, you can run the following in the `example/random-test` directory to overload variables.

```
$ docker run --rm -it -p 9000:9000 -v "$(pwd):/src" im2nguyen/rover -tfBackendConfig test.tfbackend -tfVarsFile test.tfvars -tfVar max_length=4
```shell
docker run --rm -it -p 9000:9000 -v "$(pwd):/src" im2nguyen/rover -tfBackendConfig test.tfbackend -tfVarsFile test.tfvars -tfVar max_length=4
```

### Image generation

Use `-genImage` to generate and save the visualization as a SVG image.

```
$ docker run --rm -it -v "$(pwd):/src" im2nguyen/rover -genImage true
```shell
docker run --rm -it -v "$(pwd):/src" im2nguyen/rover -genImage true
```

## Installation
Expand All @@ -106,48 +106,48 @@ You can build Rover manually by cloning this repository, then building the front

First, navigate to the `ui`.

```
$ cd ui
```shell
cd ui
```

Then, install the dependencies.

```
$ npm install
```shell
npm install
```

Finally, build the frontend.

```
$ npm run build
```shell
npm run build
```

#### Compile binary

Navigate to the root directory.

```
$ cd ..
```shell
cd ..
```

Compile and install the binary. Alternatively, you can use `go build` and move the binary into your `PATH`.

```
$ go install
```shell
go install
```

### Build Docker image

First, compile the binary for `linux/amd64`.

```
$ env GOOS=linux GOARCH=amd64 go build .
```shell
env GOOS=linux GOARCH=amd64 go build .
```

Then, build the Docker image.

```
$ docker build . -t im2nguyen/rover --no-cache
```shell
docker build . -t im2nguyen/rover --no-cache
```


Expand All @@ -157,13 +157,13 @@ This repository contains two examples of Terraform configurations in `example`.

Navigate into `random-test` example configuration. This directory contains configuration that showcases a wide variety of features common in Terraform (modules, count, output, locals, etc) with the [`random`](https://registry.terraform.io/providers/hashicorp/random/latest) provider.

```
$ cd example/random-test
```shell
cd example/random-test
```

Run Rover. Rover will start running in the current directory and assume the Terraform binary lives in `/usr/local/bin/terraform` by default.
Run Rover. Rover will start running in the current directory and assume the Terraform binary lives in `/opt/homebrew/bin/terraform` on Linux and `/opt/homebrew/bin/terraform` on MacOS.

```
```shell
$ rover
2021/06/23 22:51:27 Starting Rover...
2021/06/23 22:51:27 Initializing Terraform...
Expand All @@ -178,8 +178,8 @@ $ rover

You can specify the working directory (where your configuration is living) and the Terraform binary location using flags.

```
$ rover -workingDir "example/eks-cluster" -tfPath "/Users/dos/terraform"
```shell
rover -workingDir "example/eks-cluster" -tfPath "/Users/dos/terraform"
```

Once Rover runs on `0.0.0.0:9000`, navigate to it to find the visualization!
50 changes: 28 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
module rover

go 1.21
go 1.22.0

toolchain go1.23.2

require (
github.com/chromedp/cdproto v0.0.0-20211205231339-d2673e93eee4
github.com/chromedp/chromedp v0.7.6
github.com/hashicorp/terraform-config-inspect v0.0.0-20210511202847-ad33d83d7650
github.com/hashicorp/terraform-exec v0.15.0
github.com/hashicorp/terraform-json v0.13.0
golang.org/x/net v0.0.0-20210924151903-3ad01bbaa167 // indirect
github.com/chromedp/cdproto v0.0.0-20241003230502-a4a8f7c660df
github.com/chromedp/chromedp v0.10.0
github.com/hashicorp/terraform-config-inspect v0.0.0-20240801114854-6714b46f5fe4
github.com/hashicorp/terraform-exec v0.21.0
github.com/hashicorp/terraform-json v0.22.1
golang.org/x/net v0.30.0 // indirect
)

require github.com/hashicorp/go-tfe v0.20.0
require github.com/hashicorp/go-tfe v1.68.0

require (
github.com/agext/levenshtein v1.2.2 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/chromedp/sysutil v1.0.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.1.0 // indirect
github.com/gobwas/ws v1.4.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.0 // indirect
github.com/hashicorp/go-slug v0.7.0 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f // indirect
github.com/hashicorp/hcl/v2 v2.0.0 // indirect
github.com/hashicorp/jsonapi v0.0.0-20210826224640-ee7dae0fb22d // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/go-slug v0.16.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
github.com/hashicorp/jsonapi v1.3.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/zclconf/go-cty v1.9.1 // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/tools v0.26.0 // indirect
)
Loading