From 58741134c93943a2003017e5de747d46a3369e89 Mon Sep 17 00:00:00 2001 From: Michael Persson Date: Mon, 2 May 2016 15:12:24 -0500 Subject: [PATCH] Add missing vendoring --- ...tcdtool-3.2.ebuild => etcdtool-3.3.ebuild} | 0 .../github.com/codegangsta/cli/errors_test.go | 60 ++++++++++++++++++ .../iodatafmt/yaml_mapstr/yaml_mapstr.go | 63 +++++++++++++++++++ 3 files changed, 123 insertions(+) rename ebuild/dev-db/etcdtool/{etcdtool-3.2.ebuild => etcdtool-3.3.ebuild} (100%) create mode 100644 vendor/src/github.com/codegangsta/cli/errors_test.go create mode 100644 vendor/src/github.com/mickep76/iodatafmt/yaml_mapstr/yaml_mapstr.go diff --git a/ebuild/dev-db/etcdtool/etcdtool-3.2.ebuild b/ebuild/dev-db/etcdtool/etcdtool-3.3.ebuild similarity index 100% rename from ebuild/dev-db/etcdtool/etcdtool-3.2.ebuild rename to ebuild/dev-db/etcdtool/etcdtool-3.3.ebuild diff --git a/vendor/src/github.com/codegangsta/cli/errors_test.go b/vendor/src/github.com/codegangsta/cli/errors_test.go new file mode 100644 index 0000000..6863105 --- /dev/null +++ b/vendor/src/github.com/codegangsta/cli/errors_test.go @@ -0,0 +1,60 @@ +package cli + +import ( + "errors" + "os" + "testing" +) + +func TestHandleExitCoder_nil(t *testing.T) { + exitCode := 0 + called := false + + OsExiter = func(rc int) { + exitCode = rc + called = true + } + + defer func() { OsExiter = os.Exit }() + + HandleExitCoder(nil) + + expect(t, exitCode, 0) + expect(t, called, false) +} + +func TestHandleExitCoder_ExitCoder(t *testing.T) { + exitCode := 0 + called := false + + OsExiter = func(rc int) { + exitCode = rc + called = true + } + + defer func() { OsExiter = os.Exit }() + + HandleExitCoder(NewExitError("galactic perimiter breach", 9)) + + expect(t, exitCode, 9) + expect(t, called, true) +} + +func TestHandleExitCoder_MultiErrorWithExitCoder(t *testing.T) { + exitCode := 0 + called := false + + OsExiter = func(rc int) { + exitCode = rc + called = true + } + + defer func() { OsExiter = os.Exit }() + + exitErr := NewExitError("galactic perimiter breach", 9) + err := NewMultiError(errors.New("wowsa"), errors.New("egad"), exitErr) + HandleExitCoder(err) + + expect(t, exitCode, 9) + expect(t, called, true) +} diff --git a/vendor/src/github.com/mickep76/iodatafmt/yaml_mapstr/yaml_mapstr.go b/vendor/src/github.com/mickep76/iodatafmt/yaml_mapstr/yaml_mapstr.go new file mode 100644 index 0000000..6fd2976 --- /dev/null +++ b/vendor/src/github.com/mickep76/iodatafmt/yaml_mapstr/yaml_mapstr.go @@ -0,0 +1,63 @@ +// Copyright (c) 2015-2016 Michael Persson +// Copyright (c) 2012–2015 Elasticsearch +// +// Originally distributed as part of "beats" repository (https://github.com/elastic/beats). +// Modified specifically for "iodatafmt" package. +// +// Distributed underneath "Apache License, Version 2.0" which is compatible with the LICENSE for this package. + +package yaml_mapstr + +import ( + // Base packages. + "fmt" + + // Third party packages. + "gopkg.in/yaml.v2" +) + +// Unmarshal YAML to map[string]interface{} instead of map[interface{}]interface{}. +func Unmarshal(in []byte, out interface{}) error { + var res interface{} + + if err := yaml.Unmarshal(in, &res); err != nil { + return err + } + *out.(*interface{}) = cleanupMapValue(res) + + return nil +} + +// Marshal YAML wrapper function. +func Marshal(in interface{}) ([]byte, error) { + return yaml.Marshal(in) +} + +func cleanupInterfaceArray(in []interface{}) []interface{} { + res := make([]interface{}, len(in)) + for i, v := range in { + res[i] = cleanupMapValue(v) + } + return res +} + +func cleanupInterfaceMap(in map[interface{}]interface{}) map[string]interface{} { + res := make(map[string]interface{}) + for k, v := range in { + res[fmt.Sprintf("%v", k)] = cleanupMapValue(v) + } + return res +} + +func cleanupMapValue(v interface{}) interface{} { + switch v := v.(type) { + case []interface{}: + return cleanupInterfaceArray(v) + case map[interface{}]interface{}: + return cleanupInterfaceMap(v) + case string: + return v + default: + return fmt.Sprintf("%v", v) + } +}