deref / exo

A process manager & log viewer for dev
https://exo.deref.io
Apache License 2.0
415 stars 17 forks source link

[BUG] Formatting manifest replaces docker file with exo file #527

Open BenElgar opened 3 years ago

BenElgar commented 3 years ago
❯ cat docker-compose.yml
services:
  t0:
    image: bash
    command: "sleep infinity"
  t1:
    image: bash
    command: "sleep infinity"
    depends_on:
      - "t0"

❯ dexo manifest format docker-compose.yml

❯ cat docker-compose.yml
exo = "0.1"
components {
  network "default" {
    driver = "bridge"
    name   = "unnamed_default"
  }
  container "t0" {
    command        = "sleep infinity"
    container_name = "unnamed_t0_1"
    image          = "bash"
    labels         = { "com.docker.compose.project" = "unnamed", "com.docker.compose.service" = "t0" }
    networks       = ["unnamed_default"]
    _ {
      depends_on = ["default"]
    }
  }
  container "t1" {
    command        = "sleep infinity"
    container_name = "unnamed_t1_1"
    depends_on     = ["t0"]
    image          = "bash"
    labels         = { "com.docker.compose.project" = "unnamed", "com.docker.compose.service" = "t1" }
    networks       = ["unnamed_default"]
    _ {
      depends_on = ["default", "t0"]
    }
  }
}

❯ dexo manifest format docker-compose.yml
Error: yaml: unmarshal errors:
  line 1: cannot unmarshal !!str `exo = "...` into compose.Project

Error: invalid manifest
invalid manifest
brandonbloom commented 3 years ago

D'oh - more issues with this not-intended-to-be-released-yet format command :)

This one is because the only output format supported is exo.hcl, which is clearly a problem when the output file is the same as the input file with a different format.

A potential workaround is to use the redirection form:

exo manifest format < docker-compose.yml

This is similar to exo manifest convert with the output format will always as "exo.hcl", which isn't what you want if you're trying to format a compose yaml file, but we don't support that yet anyway.