hashicorp / hashicorp/nomad-pack

Too long line lenght breaks `nomad-pack render` output

Open
#152 1 comment 0 reactions 0 assignees View on GitHub
stage/accepted theme/cli theme/template/render type/bug
Dominant language
Go
Stars
447
Forks
65
PR merge metrics
No merged PRs in 30d

Description

Hello!

I found a bug that lives somewhere in output of `render` method.

When we run `nomad-pack render` method, the output will be broken if we have too thin terminal (or too long line in output)

Terminal width:

```bash
$ tput cols
114
```

Broken output:

```bash
$ nomad-pack render -var 'datacenters=["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]' hello_world

hello_world/templates/hello_world.nomad.tpl:

job "hello_world" {

datacenters =
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
] type = "service" group "app" { count = 2 network { port "http" { to = 8000 } } service { name = "webapp" tags = [ "urlprefix-/","traefik.enable=true","traefik.http.routers.http.rule=Path(`/`)" ] port = "http" check { name = "alive" type = "http" path = "/" interval = "10s" timeout = "2s" } } restart { attempts = 2 interval = "30m" delay = "15s" mode = "fail" } task "server" { driver = "docker" config { image = "mnomitch/hello_world_server" ports = ["http"] } env { MESSAGE = "Hello World!" } } }}
```

Now let's run the same command with one "a" less:

```bash
$ nomad-pack render -var 'datacenters=["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]' hello_world
hello_world/templates/hello_world.nomad.tpl:

job "hello_world" {

datacenters = [
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
]
type = "service"

group "app" {
count = 2

network {
port "http" {
to = 8000
}
}

service {
name = "webapp"
tags = [ "urlprefix-/","traefik.enable=true","traefik.http.routers.http.rule=Path(`/`)" ]
port = "http"

check {
name = "alive"
type = "http"
path = "/"
interval = "10s"
timeout = "2s"
}
}

restart {
attempts = 2
interval = "30m"
delay = "15s"
mode = "fail"
}

task "server" {
driver = "docker"

config {
image = "mnomitch/hello_world_server"
ports = ["http"]
}

env {
MESSAGE = "Hello World!"
}
}
}
}
```

What's important: in both cases it will pass `nomad-pack plan` so it's only something about printing the output.

Environment (WSL2 but also confirmed on ubuntu-server):

```bash
$ nomad-pack --version
Nomad Pack v0.0.1-techpreview1
# latest nightly build

$ zsh --version
zsh 5.4.2 (x86_64-ubuntu-linux-gnu)

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"

$ uname -a
Linux DESKTOP-U1CN9I7 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.