Skip to content

Commit

Permalink
Merge pull request #3 from im2nguyen/docker-v1.0.1-ui-updates
Browse files Browse the repository at this point in the history
Add Docker quickstart, update UI, fix TF v1.0.1 issue
  • Loading branch information
im2nguyen authored Jul 2, 2021
2 parents 8b8fb3a + 556040f commit a173813
Show file tree
Hide file tree
Showing 22 changed files with 155 additions and 38 deletions.
Binary file added .DS_Store
Binary file not shown.
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG TF_VERSION=light

FROM hashicorp/terraform:$TF_VERSION

RUN cp /bin/terraform /usr/local/bin/terraform

COPY ./rover /bin/rover
RUN chmod +x /bin/rover

WORKDIR /src

ENTRYPOINT [ "/bin/rover" ]

# CMD ["rover"]
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,39 @@ Feedback (via issues) and pull requests are appreciated!

![Rover Screenshot](docs/rover-cropped-screenshot.png)

## Quickstart

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`.

```
$ 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...
2021/07/02 06:46:24 Generating plan...
2021/07/02 06:46:25 Parsing configuration...
2021/07/02 06:46:25 Generating resource overview...
2021/07/02 06:46:25 Generating resource map...
2021/07/02 06:46:25 Generating resource graph...
2021/07/02 06:46:25 Done generating assets.
2021/07/02 06:46:25 Rover is running on localhost:9000
```

Once Rover runs on `localhost:9000`, navigate to it to find the visualization!

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

```
$ 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
```

## Installation

You can download Rover binary specific to your system by visiting the [Releases page](https://github.com/im2nguyen/rover/releases). Download the binary, unzip, then move `rover` into your `PATH`.
Expand Down Expand Up @@ -57,6 +90,21 @@ Compile and install the binary. Alternatively, you can use `go build` and move t
$ go install
```

### Build Docker image

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

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

Then, build the Docker image.

```
$ docker build . -t im2nguyen/rover
```


## Basic usage

This repository contains two example Terraform configurations in `example`.
Expand Down Expand Up @@ -88,4 +136,4 @@ You can specify the working directory (where your configuration is living) and t
$ rover -workingDir "example/eks-cluster" -tfPath "/Users/dos/terraform"
```

Once Rover runs on `localhost:9000`, navigate to it to find the visualization!
Once Rover runs on `localhost:9000`, navigate to it to find the visualization!
Binary file modified example/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions example/random-test/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ func GenerateEdges(plan *tfjson.Plan) []Edge {
targetType = DATA_COLOR
}

// For Terraform 1.0, resource references point to specific resource attributes
// Skip if the target is a resource and reference points to an attribute
if targetType == RESOURCE_COLOR && len(strings.Split(dependsOnR, ".")) != 2 {
continue
} else if targetType == DATA_COLOR && len(strings.Split(dependsOnR, ".")) != 3 {
continue
}

id := fmt.Sprintf("%s->%s", resource.Address, dependsOnR)
emo = append(emo, id)
edgeMap[id] = Edge{
Expand Down Expand Up @@ -419,6 +427,14 @@ func GenerateEdges(plan *tfjson.Plan) []Edge {
targetType = DATA_COLOR
}

// For Terraform 1.0, resource references point to specific resource attributes
// Skip if the target is a resource and reference points to an attribute
if targetType == RESOURCE_COLOR && len(strings.Split(dependsOnR, ".")) != 2 {
continue
} else if targetType == DATA_COLOR && len(strings.Split(dependsOnR, ".")) != 3 {
continue
}

id := fmt.Sprintf("%s->%s", fmt.Sprintf("module.%s", mid), dependsOnR)
emo = append(emo, id)
edgeMap[id] = Edge{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified ui/dist/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion ui/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>ui</title><link rel="stylesheet" href="/chota.min.css"><link rel="stylesheet" href="/style.css"><link href="/css/app.bf24ba71.css" rel="preload" as="style"><link href="/js/app.d4ce5b47.js" rel="preload" as="script"><link href="/js/chunk-vendors.0b54d9ce.js" rel="preload" as="script"><link href="/css/app.bf24ba71.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.0b54d9ce.js"></script><script src="/js/app.d4ce5b47.js"></script></body></html>
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>ui</title><link rel="stylesheet" href="/chota.min.css"><link rel="stylesheet" href="/style.css"><link href="/css/app.52fc4fd2.css" rel="preload" as="style"><link href="/js/app.53202c6f.js" rel="preload" as="script"><link href="/js/chunk-vendors.bd6ebaf4.js" rel="preload" as="script"><link href="/css/app.52fc4fd2.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but ui doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.bd6ebaf4.js"></script><script src="/js/app.53202c6f.js"></script></body></html>
2 changes: 2 additions & 0 deletions ui/dist/js/app.53202c6f.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ui/dist/js/app.53202c6f.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions ui/dist/js/app.d4ce5b47.js

This file was deleted.

1 change: 0 additions & 1 deletion ui/dist/js/app.d4ce5b47.js.map

This file was deleted.

Loading

0 comments on commit a173813

Please sign in to comment.