assh icon indicating copy to clipboard operation
assh copied to clipboard

Does not honour YAML syntax

Open renard opened this issue 5 years ago • 1 comments

Let's use a simple yaml file to generate a configuration:

hosts:
  host.example.com:
    Inherits: "tpl-example"
  host2.example.com: {Inherits: "tpl-example"}
 
templates:
  tpl-example:
    User: foo

The result is:

# This file was automatically generated by assh v2.8.0+dev
# on 2019-07-31 00:51:28 +0200 CEST, based on ~/.ssh/assh.yml
#
# more info: https://github.com/moul/assh

# host-based configuration
Host host.example.com
  Port 22
  User foo
  # Inherits: [tpl-example]

Host host2.example.com

# global configuration
Host *
  ProxyCommand assh connect --port=%p %h

As you can see host2 inheritance does not seem to be honoured as is should be.

I use this syntax because sometime it is more handy to have one host per line.

I use:

Debug mode (client): false
CLI Path: /Users/renard/Src/assh/assh
Go version: go1.12.7
OS/Arch: darwin/amd64
Version: 2.8.0+dev (HEAD)

RC files:
- ~/.ssh/assh.yml

Statistics:
- 2 hosts
- 1 templates
- 1 included files

renard avatar Jul 30 '19 22:07 renard

Hi @renard

I'm not 100% sure, but I think that's because YAML is case-sensitive and I made a hack to be more flexible and support case-insensitive YAML files (see https://github.com/go-yaml/yaml/issues/123)

Basically, https://github.com/moul/flexyaml is very naive and replaces the first word of a line that contains ":"

In your case, I'm pretty sure that flexyaml didn't lowered the "Inherits" word and just considered it as an unknown attribute

Hopefully, the thread here https://github.com/go-yaml/yaml/issues/123 just woke up after 3 years, so maybe we will have a better handling of case-insensitive YAML that supports the whole YAML syntax \o/

For now,I can only suggest you to try to replace "Inherits" by "inherits" or just use the multiline format

moul avatar Oct 09 '19 20:10 moul