summaryrefslogtreecommitdiff
path: root/vendor/github.com/varlink/go/cmd
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-02-05 11:51:41 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-02-06 11:14:06 +0100
commit9ac0ebb0791851aea81ecc847802db5a39bfb6e7 (patch)
tree30ad98bcc2c2dd1136f46a48cbc44d422adfa184 /vendor/github.com/varlink/go/cmd
parent51714d5da7aaa19014fd67b48b79dfbd5f69c1f0 (diff)
downloadpodman-9ac0ebb0791851aea81ecc847802db5a39bfb6e7.tar.gz
podman-9ac0ebb0791851aea81ecc847802db5a39bfb6e7.tar.bz2
podman-9ac0ebb0791851aea81ecc847802db5a39bfb6e7.zip
Cirrus: add vendor_check_task
* Make sure that all vendored dependencies are in sync with the code and the vendor.conf by running `make vendor` with a follow-up status check of the git tree. * Vendor ginkgo and gomega to include the test dependencies. Signed-off-by: Chris Evic <cevich@redhat.com> Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/varlink/go/cmd')
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go45
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink/main.go28
2 files changed, 50 insertions, 23 deletions
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
index 6be01f580..98a983c5e 100644
--- a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
+++ b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/main.go
@@ -109,6 +109,36 @@ func generateTemplate(description string) (string, []byte, error) {
b.WriteString("\n\n")
}
+ for _, a := range midl.Errors {
+ writeDocString(&b, a.Doc)
+ b.WriteString("type " + a.Name + " ")
+ writeType(&b, a.Type, true, 0)
+ b.WriteString("\nfunc (e " + a.Name + ") Error() string {\n")
+ b.WriteString("\treturn \"" + midl.Name + "." + a.Name + "\"\n")
+ b.WriteString("}\n\n")
+ }
+
+ b.WriteString("func Dispatch_Error(err error) error {\n")
+ b.WriteString("\tif e, ok := err.(*varlink.Error); ok {\n")
+ b.WriteString("\t\tswitch e.Name {\n")
+ for _, a := range midl.Errors {
+ b.WriteString("\t\tcase \"" + midl.Name + "." + a.Name + "\":\n")
+ b.WriteString("\t\t\terrorRawParameters := e.Parameters.(*json.RawMessage)\n")
+ b.WriteString("\t\t\tif errorRawParameters == nil {\n")
+ b.WriteString("\t\t\t\treturn e\n")
+ b.WriteString("\t\t\t}\n")
+ b.WriteString("\t\t\tvar param " + a.Name + "\n")
+ b.WriteString("\t\t\terr := json.Unmarshal(*errorRawParameters, &param)\n")
+ b.WriteString("\t\t\tif err != nil {\n")
+ b.WriteString("\t\t\t\treturn e\n")
+ b.WriteString("\t\t\t}\n")
+ b.WriteString("\t\t\treturn &param\n")
+ }
+ b.WriteString("\t\t}\n")
+ b.WriteString("\t}\n")
+ b.WriteString("\treturn err\n")
+ b.WriteString("}\n\n")
+
b.WriteString("// Generated client method calls\n\n")
for _, m := range midl.Methods {
@@ -175,9 +205,9 @@ func generateTemplate(description string) (string, []byte, error) {
} else {
b.WriteString("\treceive, err := c.Send(\"" + midl.Name + "." + m.Name + "\", nil, flags)\n")
}
- b.WriteString("if err != nil {\n" +
- "\treturn nil, err\n" +
- "}\n")
+ b.WriteString("\tif err != nil {\n" +
+ "\t\treturn nil, err\n" +
+ "\t}\n")
b.WriteString("\treturn func() (")
for _, field := range m.Out.Fields {
b.WriteString(field.Name + "_out_ ")
@@ -194,6 +224,7 @@ func generateTemplate(description string) (string, []byte, error) {
b.WriteString("\t\tflags, err = receive(nil)\n")
}
b.WriteString("\t\tif err != nil {\n" +
+ "\t\t\terr = Dispatch_Error(err)\n" +
"\t\t\treturn\n" +
"\t\t}\n")
for _, field := range m.Out.Fields {
@@ -242,10 +273,8 @@ func generateTemplate(description string) (string, []byte, error) {
writeType(&b, field.Type, false, 1)
}
b.WriteString(") error {\n")
+ b.WriteString("\tvar out " + e.Name + "\n")
if len(e.Type.Fields) > 0 {
- b.WriteString("\tvar out ")
- writeType(&b, e.Type, true, 1)
- b.WriteString("\n")
for _, field := range e.Type.Fields {
switch field.Type.Kind {
case idl.TypeStruct, idl.TypeArray, idl.TypeMap:
@@ -257,10 +286,8 @@ func generateTemplate(description string) (string, []byte, error) {
b.WriteString("\tout." + strings.Title(field.Name) + " = " + field.Name + "_\n")
}
}
- b.WriteString("\treturn c.ReplyError(\"" + midl.Name + "." + e.Name + "\", &out)\n")
- } else {
- b.WriteString("\treturn c.ReplyError(\"" + midl.Name + "." + e.Name + "\", nil)\n")
}
+ b.WriteString("\treturn c.ReplyError(\"" + midl.Name + "." + e.Name + "\", &out)\n")
b.WriteString("}\n\n")
}
diff --git a/vendor/github.com/varlink/go/cmd/varlink/main.go b/vendor/github.com/varlink/go/cmd/varlink/main.go
index 1de4e1a45..6781dd956 100644
--- a/vendor/github.com/varlink/go/cmd/varlink/main.go
+++ b/vendor/github.com/varlink/go/cmd/varlink/main.go
@@ -12,7 +12,7 @@ import (
)
var bold = color.New(color.Bold)
-var errorBoldRed = bold.Sprint(color.New(color.FgRed).Sprint("Error:"))
+var errorBoldRed string
var bridge string
func ErrPrintf(format string, a ...interface{}) {
@@ -71,7 +71,7 @@ func varlink_call(args []string) {
os.Exit(2)
}
address = "bridge:" + bridge
- methodName = callFlags.Arg(0)
+ methodName = callFlags.Arg(0)
} else {
uri := callFlags.Arg(0)
if uri == "" {
@@ -126,20 +126,18 @@ func varlink_call(args []string) {
f.NullColor = color.New(color.FgMagenta)
if err != nil {
- ErrPrintf("Error calling '%s': %v\n", methodName, err)
- switch e := err.(type) {
- case *varlink.Error:
- println(e.Name)
+ if e, ok := err.(*varlink.Error); ok {
+ ErrPrintf("Call failed with error: %v\n", color.New(color.FgRed).Sprint(e.Name))
errorRawParameters := e.Parameters.(*json.RawMessage)
-
- if errorRawParameters == nil {
- break
+ if errorRawParameters != nil {
+ var param map[string]interface{}
+ _ = json.Unmarshal(*errorRawParameters, &param)
+ c, _ := f.Marshal(param)
+ fmt.Fprintf(os.Stderr, "%v\n", string(c))
}
- var param map[string]interface{}
- _ = json.Unmarshal(*errorRawParameters, &param)
- c, _ := f.Marshal(param)
- ErrPrintf("%v\n", string(c))
+ os.Exit(2)
}
+ ErrPrintf("Error calling '%s': %v\n", methodName, err)
os.Exit(2)
}
c, _ := f.Marshal(retval)
@@ -173,7 +171,7 @@ func varlink_help(args []string) {
os.Exit(2)
}
address = "bridge:" + bridge
- interfaceName = helpFlags.Arg(0)
+ interfaceName = helpFlags.Arg(0)
} else {
uri := helpFlags.Arg(0)
if uri == "" && bridge == "" {
@@ -282,6 +280,8 @@ func main() {
color.NoColor = true // disables colorized output
}
+ errorBoldRed = bold.Sprint(color.New(color.FgRed).Sprint("Error:"))
+
switch flag.Arg(0) {
case "info":
varlink_info(flag.Args()[1:])