2 Commits

Author SHA1 Message Date
John R. Lenton
0a04c5a8c6 strutil: detect and bail out of Unmarshal on duplicate key
Without this change strutil.OrderedMap would panic on a duplicate
key. This change instead makes it return an error.

This means that, if you're `try`ing a snap, edit its `snap.yaml` to
accidentally have a duplicate key, instead of snapd getting
depramestrated the user will see an error. See [lp:1782990] for the
panic you used to get; with this change instead you get

```
$ snap info xyzzy --verbose
name:      xyzzy
summary:   ""
publisher: –
license:   unset
description: |

notes:
  private:           false
  confinement:
  devmode:           false
  jailmode:          false
  trymode:           true
  enabled:           true
  broken:            true (cannot use installed snap "xyzzy" at revision x1: cannot parse snap.yaml: found duplicate key "foo")
  ignore-validation: false
refresh-date: today at 11:22 BST
installed:     (x1) 0B
```

[lp:1782990]: https://bugs.launchpad.net/snapd/+bug/1782990
2018-07-24 11:23:53 +01:00
Michael Vogt
ecbd545cb1 snap-exec: support nested environment variables in environment: (#2769)
This allows to use nested env vars in the `environment:` block of a snap. It supports both the pre-existing environment (PATH, PS1, SNAP_*) and from within the environment. E.g.:
```
environment:
  FOO: 1
  BAR: $FOO/2
  BAZ: $PATH:/something
```
will work. 

The current search order is: 
1. app specific environment
2. snap specific environment
3. os environment
2017-02-14 14:37:18 -02:00