diff --git a/README.md b/README.md index f702003..bc984fc 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ or download from [releases](https://github.com/upsight/ron/releases) ### Upgrade - LATEST_URL=https://github.com/upsight/ron/releases/download/v1.1.2/ron-linux-v1.1.2 ron upgrade + LATEST_URL=https://github.com/upsight/ron/releases/download/v1.1.3/ron-linux-v1.1.3 ron upgrade ### Testing diff --git a/doc.go b/doc.go index cc81e2b..b38674f 100644 --- a/doc.go +++ b/doc.go @@ -237,7 +237,7 @@ Upgrade Ron can be upgraded if you already have it installed. The easiest way is to just provide a LATEST_URL to the upgrade command: - $ LATEST_URL=https://github.com/upsight/ron/releases/download/v1.1.2/ron-linux-v1.1.2 ron upgrade + $ LATEST_URL=https://github.com/upsight/ron/releases/download/v1.1.3/ron-linux-v1.1.3 ron upgrade Version diff --git a/ron.yaml b/ron.yaml index b641a60..735ab95 100644 --- a/ron.yaml +++ b/ron.yaml @@ -17,7 +17,7 @@ envs: - CURDIR: +pwd - UNAME: +uname | tr '[:upper:]' '[:lower:]' - PACKAGE_VERSION: +git describe --always --dirty --tags | tr '-' '_' - - TAG: v1.1.2 + - TAG: v1.1.3 - LATEST_URL: "https://github.com/upsight/ron/releases/download/$TAG/ron-${UNAME}-latest" - REPO: github.com/upsight/ron - RELEASES: linux darwin windows diff --git a/target/configs.go b/target/configs.go index d1d8d45..ce438e7 100644 --- a/target/configs.go +++ b/target/configs.go @@ -74,19 +74,14 @@ func NewConfigs(configs []*RawConfig, remoteEnv string, stdOut io.Writer, stdErr return nil, err } f.Env = e + if parentFile != nil { + parentFile.Env.MergeTo(f.Env) + } confs.Files = append(confs.Files, f) if strings.HasSuffix(config.Filepath, ConfigFileName) { parentFile = f } } - for i := len(confs.Files) - 1; i >= 0; i-- { - curFile := confs.Files[i] - parent := confs.Files[i].Env.parent - for parent != nil { - curFile.Env.Merge(parent.Env) - parent = parent.Env.parent - } - } if remoteEnv != "" { // find any remote hosts if set. diff --git a/target/default.go b/target/default.go index c0dd700..6aff634 100644 --- a/target/default.go +++ b/target/default.go @@ -68,7 +68,7 @@ func (fi bindataFileInfo) Sys() interface{} { return nil } -var _targetDefaultYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x90\xc1\x6a\xf3\x30\x10\x84\xef\x7e\x8a\x21\x04\x7c\x08\xb2\xc9\xcf\x4f\x0f\xba\x89\xd4\x24\xa1\x69\x1a\x1c\xa7\x97\x52\x8c\x62\x29\xb6\xc1\x96\x8c\x24\xc7\x84\xa6\xef\x5e\x2c\x87\x5e\x7a\x9b\xd9\x1d\xbe\x65\x47\xaa\xab\xa5\x01\x40\xc0\x0e\x07\x0a\xa3\xd5\x64\xd2\xd5\x86\x82\xb7\xe2\xe9\xbf\xf7\xab\x53\xfa\xbc\x4d\x29\x16\xdd\x20\xfc\xe0\xb4\x67\xaf\x09\xc5\xa2\x57\xbc\x95\xb8\xc3\x19\x84\x1f\xb4\xef\x3a\x69\xe8\x67\x38\xea\x46\x0f\x5e\xfb\xf8\x81\xad\x5e\xd8\x3a\xc9\xdf\x93\xf4\xb8\x7d\xdb\x53\x2c\xca\xda\x41\x48\x5b\x98\xfa\x2c\x41\x08\x6f\x06\x7e\xb3\x20\x44\xd4\xc6\xdd\x40\x88\xe3\xa5\x7d\x70\x49\x88\x30\x9f\x38\x19\x5b\x53\x5c\x97\xd1\x32\xfa\xe7\xfd\x8e\x65\xc9\x31\xcb\x4f\xe9\x8e\x62\x56\x39\xd7\x59\x1a\xc7\x65\xed\xaa\xfe\x1c\x15\xba\x8d\xfb\xce\xd6\x65\xe5\x62\xa3\x55\x6c\x64\x23\xb9\x95\x36\x16\x7a\x50\x8d\xe6\x22\x9e\x67\x6c\x3d\xae\xc8\xfc\xcb\xff\xf3\x4d\xc6\xc9\x2c\x70\xdc\x94\xd2\xf9\x5e\xf2\x4a\x36\x8d\x1e\x15\x50\xb4\x82\xe2\xee\x25\x20\x8b\x4a\x63\x33\x2e\x03\xe0\xdc\x9b\xb2\x57\xe2\x36\xe5\xa6\xb7\x3a\x57\x6b\x45\xa7\x08\x2e\x46\xb7\x63\xb9\x91\x0f\xf0\x8b\x93\x86\x3e\x40\xe4\x71\xe3\xef\x09\xa3\xd5\x2f\x39\xf8\x09\x00\x00\xff\xff\x01\xe9\xa3\x28\xa9\x01\x00\x00") +var _targetDefaultYaml = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x64\x90\xc1\x6a\xf3\x30\x10\x84\xef\x7e\x8a\x21\x04\x7c\x08\xb2\x09\xff\x4f\x0f\xba\x89\xd4\x24\xa1\x69\x1a\x1c\xa7\x97\x52\x8c\x62\x29\xb6\xc1\x96\x8c\x24\xc7\x84\xa6\xef\x5e\x2c\x87\x5e\x7a\x9b\xd9\x1d\xbe\x65\x47\xaa\xab\xa5\x01\x40\xc0\x0e\x07\x0a\xa3\xd5\x64\xd2\xd5\x86\x82\xb7\xe2\xe9\xbf\xf7\xab\x53\xfa\xbc\x4d\x29\x16\xdd\x20\xfc\xe0\xb4\x67\xaf\x09\xc5\xa2\x57\xbc\x95\xb8\xc3\x19\x84\x1f\xb4\xef\x3a\x69\xe8\x67\x38\xea\x46\x0f\x5e\xfb\xf8\x81\xad\x5e\xd8\x3a\xc9\xdf\x93\xf4\xb8\x7d\xdb\x53\x2c\xca\xda\x41\x48\x5b\x98\xfa\x2c\x41\x08\x6f\x06\x7e\xb3\x20\x44\xd4\xc6\xdd\x40\x88\xe3\xa5\x7d\x70\x49\x88\x30\x9f\x38\x19\x5b\x53\x5c\x97\xd1\x32\xfa\xe7\xfd\x8e\x65\xc9\x31\xcb\x4f\xe9\x8e\x62\x56\x39\xd7\x59\x1a\xc7\x65\xed\xaa\xfe\x1c\x15\xba\x8d\xfb\xce\xd6\x65\xe5\x62\xa3\x55\x6c\x64\x23\xb9\x95\x36\x16\x7a\x50\x8d\xe6\x22\x9e\x67\x6c\x3d\xae\xc8\xfc\xcb\xff\xf3\x4d\xc6\xc9\x2c\x70\xdc\x94\xd2\xf9\x5e\xf2\x4a\x36\x8d\x1e\x15\x50\xb4\x82\xe2\xee\x25\x20\x8b\x4a\x63\x33\x2e\x03\xe0\xdc\x9b\xb2\x57\xe2\x36\xe5\xa6\xb7\x3a\x57\x6b\x45\xa7\x08\x2e\x46\xb7\x63\xb9\x91\x0f\xf0\x8b\x93\x86\x3e\x40\xe4\x71\xe3\xef\x09\xa3\xd5\x2f\x39\xf8\x09\x00\x00\xff\xff\x0c\x19\xd4\x28\xa9\x01\x00\x00") func targetDefaultYamlBytes() ([]byte, error) { return bindataRead( @@ -83,7 +83,7 @@ func targetDefaultYaml() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "target/default.yaml", size: 425, mode: os.FileMode(416), modTime: time.Unix(1510610409, 0)} + info := bindataFileInfo{name: "target/default.yaml", size: 425, mode: os.FileMode(416), modTime: time.Unix(1510963621, 0)} a := &asset{bytes: bytes, info: info} return a, nil } diff --git a/target/default.yaml b/target/default.yaml index 53478fe..f83a04e 100644 --- a/target/default.yaml +++ b/target/default.yaml @@ -4,7 +4,7 @@ envs: - CURDIR: +pwd - UNAME: +uname | tr '[:upper:]' '[:lower:]' - PACKAGE_VERSION: +git describe --always --dirty --tags | tr '-' '_' - - TAG: v1.1.2 + - TAG: v1.1.3 - LATEST_URL: "https://github.com/upsight/ron/releases/download/$TAG/ron-${UNAME}-$TAG" targets: _hello: diff --git a/target/env.go b/target/env.go index c566e42..eff3bae 100644 --- a/target/env.go +++ b/target/env.go @@ -78,8 +78,8 @@ func (e *Env) Config() (MSS, error) { return e.config, nil } -// Merge the current env into any missing keys for the input node. -func (e *Env) Merge(node *Env) error { +// MergeTo the current env into any missing keys for the input node. +func (e *Env) MergeTo(node *Env) error { for k, v := range e.config { if _, ok := node.config[k]; !ok { node.config[k] = v diff --git a/target/env_test.go b/target/env_test.go index c71122d..fb95c38 100644 --- a/target/env_test.go +++ b/target/env_test.go @@ -204,23 +204,24 @@ func TestEnv_PrintRawBadWriter(t *testing.T) { e.PrintRaw() } -func TestEnv_Merge(t *testing.T) { +func TestEnv_MergeTo(t *testing.T) { writer := &bytes.Buffer{} e1Config := ` +- ABC: +pwd - APP: ron - HELLO: hello -- ABC: +pwd ` e2Config := ` -- GOOD: bye - BLAH: +pwd +- GOOD: bye +- HELLO: bye ` e1, _ := NewEnv(nil, &RawConfig{Envs: e1Config}, ParseOSEnvs([]string{}), writer) e2, _ := NewEnv(nil, &RawConfig{Envs: e2Config}, ParseOSEnvs([]string{}), writer) - e1.Merge(e2) + e1.MergeTo(e2) + equals(t, e2.config["ABC"], "+pwd") equals(t, e2.config["APP"], "ron") - equals(t, e2.config["GOOD"], "bye") equals(t, e2.config["BLAH"], "+pwd") - equals(t, e2.config["ABC"], "+pwd") - equals(t, e2.config["HELLO"], "hello") + equals(t, e2.config["GOOD"], "bye") + equals(t, e2.config["HELLO"], "bye") }