summaryrefslogtreecommitdiff
path: root/vendor/github.com/varlink/go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/varlink/go')
-rw-r--r--vendor/github.com/varlink/go/.gitignore2
-rw-r--r--vendor/github.com/varlink/go/.travis.yml25
-rw-r--r--vendor/github.com/varlink/go/Makefile7
-rw-r--r--vendor/github.com/varlink/go/README.md7
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-certification/main.go619
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-certification/orgvarlinkcertification/generate.go3
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-certification/orgvarlinkcertification/org.varlink.certification.varlink89
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/generator_test.go90
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink-go-type-generator/main.go172
-rw-r--r--vendor/github.com/varlink/go/cmd/varlink/main.go295
-rw-r--r--vendor/github.com/varlink/go/golang-github-varlink-go.spec44
-rw-r--r--vendor/github.com/varlink/go/varlink/external_test.go211
-rw-r--r--vendor/github.com/varlink/go/varlink/idl/idl_test.go150
-rw-r--r--vendor/github.com/varlink/go/varlink/varlink_test.go258
14 files changed, 0 insertions, 1972 deletions
diff --git a/vendor/github.com/varlink/go/.gitignore b/vendor/github.com/varlink/go/.gitignore
deleted file mode 100644
index a43b0e2d3..000000000
--- a/vendor/github.com/varlink/go/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/cmd/varlink-go-certification/orgvarlinkcertification/orgvarlinkcertification.go
-/.idea
diff --git a/vendor/github.com/varlink/go/.travis.yml b/vendor/github.com/varlink/go/.travis.yml
deleted file mode 100644
index fa9963500..000000000
--- a/vendor/github.com/varlink/go/.travis.yml
+++ /dev/null
@@ -1,25 +0,0 @@
-language: go
-sudo: false
-go:
-- '1.10'
-- 1.11.x
-install:
-- go get golang.org/x/tools/cmd/cover
-- go get github.com/mattn/goveralls
-- go get github.com/TylerBrock/colorjson
-- go get github.com/fatih/color
-script:
-- go generate ./...
-- '"$HOME/gopath/bin/goveralls" -v -show -service=travis-ci -repotoken "$COVERALLS_TOKEN"'
-env:
- global:
- - secure: bjxOSgBfB+YooxNTkIDHAD+/X6g56qBWoYpB1JinuS5kmt3vSjfRSuXui71sGuha7jO2FOJja8HcpjOv3UP+qmmej9276o5VWrjS1AwnI95hSQQ4JHm293Z1QeojjRaxmoKrgn7i82Hn4qNdVLQA142s+SIdqOxtN6LDs7i0Yb4IuXoiMQHbd6kAAL95o9IUFPpYAdsXoQ6xnx+TXNiSwPPeh4m5CNKuTtmGTuMGaj8tXxttFKJhZcRzvOpDuh7luc9PSVnQgYmKE/3S9ehzGV8Lk4T8eC7587DY1GdYQKt1egJSE72L+PVnmoalWROaAGHZvYWsSAeNi1UIvcFwGbXBRpq7kz3DVfIULM8V67UAaF3dGYDN3Ae825mDjN5JDfml17AoEjMjI0LlBImZLX2EWIEN225JIREHdpG9seJkaN1ClcpvEIeYuThF2MiivP1EE8/w8S80yoO5nW76Py/th16OuaEiP9LdLsbXimObUPsS9Sr8qquf/PiVqRMMpVW88oOEG5HVn4Ra5B/xVC6nPEF88tE6p9+7RSz4rOWih8QmW+6SX6eo0BI9di4L779f/WfUrddN0JLIvEnRFZZ+pVF/oo+N2INNeIMsZBvG3FVo+Zxzo6SExXnSSpuf1bp140ZdinUMACq6BqK+9gj1C9vNRmqQJaEefrqutws=
-notifications:
- webhooks:
- urls:
- - https://webhooks.gitter.im/e/8cfd8d5fa3c31aa3d0c3
- on_success: change # options: [always|never|change] default: always
- on_failure: always # options: [always|never|change] default: always
- on_start: never # options: [always|never|change] default: always
-
-
diff --git a/vendor/github.com/varlink/go/Makefile b/vendor/github.com/varlink/go/Makefile
deleted file mode 100644
index 7538d0042..000000000
--- a/vendor/github.com/varlink/go/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all: cmd/varlink-go-certification/orgvarlinkcertification/orgvarlinkcertification.go
- go test ./...
-
-cmd/varlink-go-certification/orgvarlinkcertification/orgvarlinkcertification.go: cmd/varlink-go-certification/orgvarlinkcertification/org.varlink.certification.varlink
- go generate cmd/varlink-go-certification/orgvarlinkcertification/generate.go
-
-.PHONY: all
diff --git a/vendor/github.com/varlink/go/README.md b/vendor/github.com/varlink/go/README.md
deleted file mode 100644
index 926a82bdd..000000000
--- a/vendor/github.com/varlink/go/README.md
+++ /dev/null
@@ -1,7 +0,0 @@
-[![Build Status](https://travis-ci.org/varlink/go.svg?branch=master)](https://travis-ci.org/varlink/go)
-[![Go Report Card](https://goreportcard.com/badge/github.com/varlink/go)](https://goreportcard.com/report/github.com/varlink/go)
-[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](http://godoc.org/github.com/varlink/go/varlink)
-[![Coverage Status](https://coveralls.io/repos/github/varlink/go/badge.svg?branch=master)](https://coveralls.io/github/varlink/go?branch=master)
-[![Release](https://img.shields.io/github/release/golang-standards/project-layout.svg?style=flat-square)](https://github.com/varlink/go/varlink/releases/latest)
-
-# go/varlink
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-certification/main.go b/vendor/github.com/varlink/go/cmd/varlink-go-certification/main.go
deleted file mode 100644
index dfffb5d0d..000000000
--- a/vendor/github.com/varlink/go/cmd/varlink-go-certification/main.go
+++ /dev/null
@@ -1,619 +0,0 @@
-package main
-
-import (
- "crypto/rand"
- "encoding/json"
- "flag"
- "fmt"
- "github.com/varlink/go/cmd/varlink-go-certification/orgvarlinkcertification"
- "github.com/varlink/go/varlink"
- "io"
- "math"
- "os"
- "strconv"
- "sync"
- "time"
-)
-
-func run_client(address string) {
- c, err := varlink.NewConnection(address)
- if err != nil {
- fmt.Println("Failed to connect")
- return
- }
- defer c.Close()
-
- client_id, err := orgvarlinkcertification.Start().Call(c)
- if err != nil {
- fmt.Println("Start() failed")
- return
- }
- fmt.Printf("Start: '%v'\n", client_id)
-
- b1, err := orgvarlinkcertification.Test01().Call(c, client_id)
- if err != nil {
- fmt.Println("Test01() failed")
- return
- }
- fmt.Printf("Test01: '%v'\n", b1)
-
- i2, err := orgvarlinkcertification.Test02().Call(c, client_id, b1)
- if err != nil {
- fmt.Println("Test02() failed")
- return
- }
- fmt.Printf("Test02: '%v'\n", i2)
-
- f3, err := orgvarlinkcertification.Test03().Call(c, client_id, i2)
- if err != nil {
- fmt.Println("Test03() failed")
- return
- }
- fmt.Printf("Test03: '%v'\n", f3)
-
- s4, err := orgvarlinkcertification.Test04().Call(c, client_id, f3)
- if err != nil {
- fmt.Println("Test04() failed")
- return
- }
- fmt.Printf("Test04: '%v'\n", s4)
-
- b5, i5, f5, s5, err := orgvarlinkcertification.Test05().Call(c, client_id, s4)
- if err != nil {
- fmt.Println("Test05() failed")
- return
- }
- fmt.Printf("Test05: '%v'\n", b5)
-
- o6, err := orgvarlinkcertification.Test06().Call(c, client_id, b5, i5, f5, s5)
- if err != nil {
- fmt.Println("Test06() failed")
- return
- }
- fmt.Printf("Test06: '%v'\n", o6)
-
- m7, err := orgvarlinkcertification.Test07().Call(c, client_id, o6)
- if err != nil {
- fmt.Println("Test07() failed")
- return
- }
- fmt.Printf("Test07: '%v'\n", m7)
-
- m8, err := orgvarlinkcertification.Test08().Call(c, client_id, m7)
- if err != nil {
- fmt.Println("Test08() failed")
- return
- }
- fmt.Printf("Test08: '%v'\n", m8)
-
- t9, err := orgvarlinkcertification.Test09().Call(c, client_id, m8)
- if err != nil {
- fmt.Println("Test09() failed")
- return
- }
- fmt.Printf("Test09: '%v'\n", t9)
-
- receive10, err := orgvarlinkcertification.Test10().Send(c, varlink.More, client_id, t9)
- if err != nil {
- fmt.Println("Test10() failed")
- return
- }
-
- fmt.Println("Test10() Send:")
- var a10 []string
- for {
- s10, flags10, err := receive10()
- if err != nil {
- fmt.Println("Test10() receive failed")
- return
- }
- a10 = append(a10, s10)
- fmt.Printf(" Receive: '%v'\n", s10)
-
- if flags10&varlink.Continues == 0 {
- break
- }
- }
- fmt.Printf("Test10: '%v'\n", a10)
-
- _, err = orgvarlinkcertification.Test11().Send(c, varlink.Oneway, client_id, a10)
- if err != nil {
- fmt.Println("Test11() failed")
- return
- }
- fmt.Println("Test11: ''")
-
- end, err := orgvarlinkcertification.End().Call(c, client_id)
- if err != nil {
- fmt.Println("End() failed")
- return
- }
- fmt.Printf("End: '%v'\n", end)
-}
-
-// Service
-type client struct {
- id string
- time time.Time
-}
-
-type test struct {
- orgvarlinkcertification.VarlinkInterface
- mutex sync.Mutex
- clients map[string]*client
-}
-
-func (t *test) Client(id string) *client {
- t.mutex.Lock()
- defer t.mutex.Unlock()
-
- return t.clients[id]
-}
-
-func (t *test) NewClient() *client {
- id128 := make([]byte, 16)
- io.ReadFull(rand.Reader, id128)
- id128[8] = id128[8]&^0xc0 | 0x80
- id128[6] = id128[6]&^0xf0 | 0x40
- uuid := fmt.Sprintf("%x-%x-%x-%x-%x", id128[0:4], id128[4:6], id128[6:8], id128[8:10], id128[10:])
-
- t.mutex.Lock()
- defer t.mutex.Unlock()
-
- // Garbage-collect old clients
- for key, client := range t.clients {
- if time.Since(client.time).Minutes() > 1 {
- delete(t.clients, key)
- }
- }
-
- if len(t.clients) > 100 {
- return nil
- }
-
- c := client{
- id: uuid,
- time: time.Now(),
- }
- t.clients[uuid] = &c
-
- return &c
-}
-
-func (t *test) RemoveClient(id string) {
- t.mutex.Lock()
- defer t.mutex.Unlock()
-
- delete(t.clients, id)
-}
-
-func (t *test) Start(c orgvarlinkcertification.VarlinkCall) error {
- return c.ReplyStart(t.NewClient().id)
-}
-
-func (t *test) Test01(c orgvarlinkcertification.VarlinkCall, client_id_ string) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- return c.ReplyTest01(true)
-}
-
-func (t *test) Test02(c orgvarlinkcertification.VarlinkCall, client_id_ string, bool_ bool) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- if !bool_ {
- return c.ReplyCertificationError(nil, nil)
- }
-
- return c.ReplyTest02(1)
-}
-
-func (t *test) Test03(c orgvarlinkcertification.VarlinkCall, client_id_ string, int_ int64) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- if int_ != 1 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- return c.ReplyTest03(1.0)
-}
-
-func (t *test) Test04(c orgvarlinkcertification.VarlinkCall, client_id_ string, float_ float64) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- if float_ != 1.0 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- return c.ReplyTest04("ping")
-}
-func (t *test) Test05(c orgvarlinkcertification.VarlinkCall, client_id_ string, string_ string) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- if string_ != "ping" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- return c.ReplyTest05(false, 2, math.Pi, "a lot of string")
-}
-
-func (t *test) Test06(c orgvarlinkcertification.VarlinkCall, client_id_ string, bool_ bool, int_ int64, float_ float64, string_ string) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- if bool_ {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if int_ != 2 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if float_ != math.Pi {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if string_ != "a lot of string" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- s := struct {
- Bool bool
- Int int64
- Float float64
- String string
- }{
- Bool: false,
- Int: 2,
- Float: math.Pi,
- String: "a lot of string",
- }
- return c.ReplyTest06(s)
-}
-
-func (t *test) Test07(c orgvarlinkcertification.VarlinkCall, client_id_ string, struct_ struct {
- Bool bool
- Int int64
- Float float64
- String string
-}) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- if struct_.Bool {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if struct_.Int != 2 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if struct_.Float != math.Pi {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if struct_.String != "a lot of string" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- m := map[string]string{
- "bar": "Bar",
- "foo": "Foo",
- }
- return c.ReplyTest07(m)
-}
-
-func (t *test) Test08(c orgvarlinkcertification.VarlinkCall, client_id_ string, map_ map[string]string) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- if len(map_) != 2 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if map_["bar"] != "Bar" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if map_["foo"] != "Foo" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- m := map[string]struct{}{
- "one": {},
- "two": {},
- "three": {},
- }
- return c.ReplyTest08(m)
-}
-
-func (t *test) Test09(c orgvarlinkcertification.VarlinkCall, client_id_ string, set_ map[string]struct{}) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- if len(set_) != 3 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- _, ok := set_["one"]
- if !ok {
- return c.ReplyCertificationError(nil, nil)
- }
-
- _, ok = set_["two"]
- if !ok {
- return c.ReplyCertificationError(nil, nil)
- }
-
- _, ok = set_["three"]
- if !ok {
- return c.ReplyCertificationError(nil, nil)
- }
-
- m := orgvarlinkcertification.MyType{
- Object: json.RawMessage(`{"method": "org.varlink.certification.Test09", "parameters": {"map": {"foo": "Foo", "bar": "Bar"}}}`),
- Enum: "two",
- Struct: struct {
- First int64 `json:"first"`
- Second string `json:"second"`
- }{First: 1, Second: "2"},
- Array: []string{"one", "two", "three"},
- Dictionary: map[string]string{"foo": "Foo", "bar": "Bar"},
- Stringset: map[string]struct{}{"one": {}, "two": {}, "three": {}},
- Nullable: nil,
- Nullable_array_struct: nil,
- Interface: orgvarlinkcertification.Interface{
- Foo: &[]*map[string]string{
- nil,
- &map[string]string{"Foo": "foo", "Bar": "bar"},
- nil,
- &map[string]string{"one": "foo", "two": "bar"},
- },
- Anon: struct {
- Foo bool `json:"foo"`
- Bar bool `json:"bar"`
- }{Foo: true, Bar: false},
- },
- }
- return c.ReplyTest09(m)
-}
-
-func (t *test) Test10(c orgvarlinkcertification.VarlinkCall, client_id_ string, mytype_ orgvarlinkcertification.MyType) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- var o struct {
- Method string `json:"method"`
- Parameters struct {
- Map map[string]string `json:"map"`
- } `json:"parameters"`
- }
- err := json.Unmarshal(mytype_.Object, &o)
- if err != nil {
- return err
- }
-
- if o.Method != "org.varlink.certification.Test09" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if len(o.Parameters.Map) != 2 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if o.Parameters.Map["bar"] != "Bar" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if o.Parameters.Map["foo"] != "Foo" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if mytype_.Enum != "two" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if mytype_.Struct.First != 1 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if mytype_.Struct.Second != "2" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if len(mytype_.Array) != 3 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if mytype_.Array[0] != "one" && mytype_.Array[1] != "two" && mytype_.Array[2] != "three" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if len(mytype_.Dictionary) != 2 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if mytype_.Dictionary["bar"] != "Bar" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if mytype_.Dictionary["foo"] != "Foo" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if len(mytype_.Stringset) != 3 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- _, ok := mytype_.Stringset["one"]
- if !ok {
- return c.ReplyCertificationError(nil, nil)
- }
-
- _, ok = mytype_.Stringset["two"]
- if !ok {
- return c.ReplyCertificationError(nil, nil)
- }
-
- _, ok = mytype_.Stringset["three"]
- if !ok {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if mytype_.Nullable != nil {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if mytype_.Nullable_array_struct != nil {
- return c.ReplyCertificationError(nil, nil)
- }
-
- i := *mytype_.Interface.Foo
- if len(i) != 4 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if i[0] != nil {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if len(*i[1]) != 2 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if (*i[1])["Foo"] != "foo" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if (*i[1])["Bar"] != "bar" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if i[2] != nil {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if len(*i[3]) != 2 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if (*i[3])["one"] != "foo" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if (*i[3])["two"] != "bar" {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if !mytype_.Interface.Anon.Foo {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if mytype_.Interface.Anon.Bar {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if !c.WantsMore() {
- return c.ReplyCertificationError(nil, nil)
- }
-
- for i := 1; i <= 10; i++ {
- c.Continues = i < 10
- err := c.ReplyTest10("Reply number " + strconv.Itoa(i))
- if err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (t *test) Test11(c orgvarlinkcertification.VarlinkCall, client_id_ string, last_more_replies_ []string) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- if len(last_more_replies_) != 10 {
- return c.ReplyCertificationError(nil, nil)
- }
-
- if !c.IsOneway() {
- return c.ReplyCertificationError(nil, nil)
- }
-
- for i := 1; i <= 10; i++ {
- if last_more_replies_[i] != "Reply number "+strconv.Itoa(i) {
- return c.ReplyCertificationError(nil, nil)
- }
- }
-
- return c.ReplyTest11()
-}
-
-func (t *test) End(c orgvarlinkcertification.VarlinkCall, client_id_ string) error {
- if t.Client(client_id_) == nil {
- return c.ReplyClientIdError()
- }
-
- t.RemoveClient(client_id_)
- return c.ReplyEnd(true)
-}
-
-func run_server(address string) {
- t := test{
- clients: make(map[string]*client),
- }
-
- s, err := varlink.NewService(
- "Varlink",
- "Certification",
- "1",
- "https://github.com/varlink/go",
- )
- if err != nil {
- fmt.Println(err)
- os.Exit(1)
- }
-
- s.RegisterInterface(orgvarlinkcertification.VarlinkNew(&t))
- err = s.Listen(address, 0)
- if err != nil {
- fmt.Println(err)
- os.Exit(1)
- }
-}
-
-func main() {
- var address string
- var client bool
-
- flag.StringVar(&address, "varlink", "", "Varlink address")
- flag.BoolVar(&client, "client", false, "Run as client")
- flag.Parse()
-
- if address == "" {
- flag.Usage()
- os.Exit(1)
- }
-
- if client {
- run_client(address)
- return
- }
-
- run_server(address)
-}
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-certification/orgvarlinkcertification/generate.go b/vendor/github.com/varlink/go/cmd/varlink-go-certification/orgvarlinkcertification/generate.go
deleted file mode 100644
index e1ac7f090..000000000
--- a/vendor/github.com/varlink/go/cmd/varlink-go-certification/orgvarlinkcertification/generate.go
+++ /dev/null
@@ -1,3 +0,0 @@
-package orgvarlinkcertification
-
-//go:generate go run ../../varlink-go-interface-generator/main.go org.varlink.certification.varlink
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-certification/orgvarlinkcertification/org.varlink.certification.varlink b/vendor/github.com/varlink/go/cmd/varlink-go-certification/orgvarlinkcertification/org.varlink.certification.varlink
deleted file mode 100644
index 41b9967b5..000000000
--- a/vendor/github.com/varlink/go/cmd/varlink-go-certification/orgvarlinkcertification/org.varlink.certification.varlink
+++ /dev/null
@@ -1,89 +0,0 @@
-# Interface to test varlink implementations against.
-# First you write a varlink client calling:
-# Start, Test01, Test02, …, Test09, End
-# The return value of the previous call should be the argument of the next call.
-# Then you test this client against well known servers like python or rust from
-# https://github.com/varlink/
-#
-# Next you write a varlink server providing the same service as the well known ones.
-# Now run your client against it and run well known clients like python or rust
-# from https://github.com/varlink/ against your server. If all works out, then
-# your new language bindings should be varlink certified.
-interface org.varlink.certification
-
-type Interface (
- foo: ?[]?[string](foo, bar, baz),
- anon: (foo: bool, bar: bool)
-)
-
-type MyType (
- object: object,
- enum: (one, two, three),
- struct: (first: int, second: string),
- array: []string,
- dictionary: [string]string,
- stringset: [string](),
- nullable: ?string,
- nullable_array_struct: ?[](first: int, second: string),
- interface: Interface
-)
-
-method Start() -> (client_id: string)
-
-method Test01(client_id: string) -> (bool: bool)
-
-method Test02(client_id: string, bool: bool) -> (int: int)
-
-method Test03(client_id: string, int: int) -> (float: float)
-
-method Test04(client_id: string, float: float) -> (string: string)
-
-method Test05(client_id: string, string: string) -> (
- bool: bool,
- int: int,
- float: float,
- string: string
-)
-
-method Test06(
- client_id: string,
- bool: bool,
- int: int,
- float: float,
- string: string
-) -> (
- struct: (
- bool: bool,
- int: int,
- float: float,
- string: string
- )
-)
-
-method Test07(
- client_id: string,
- struct: (
- bool: bool,
- int: int,
- float: float,
- string: string
- )
-) -> (map: [string]string)
-
-method Test08(client_id: string, map: [string]string) -> (set: [string]())
-
-method Test09(client_id: string, set: [string]()) -> (mytype: MyType)
-
-# returns more than one reply with "continues"
-method Test10(client_id: string, mytype: MyType) -> (string: string)
-
-method Test11(
- client_id: string,
- last_more_replies: []string
-) -> ()
-
-method End(client_id: string) -> (all_ok: bool)
-
-error ClientIdError ()
-
-error CertificationError (wants: object, got: object)
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/generator_test.go b/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/generator_test.go
deleted file mode 100644
index 8e749f411..000000000
--- a/vendor/github.com/varlink/go/cmd/varlink-go-interface-generator/generator_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-package main
-
-import (
- "strings"
- "testing"
-)
-
-func expect(t *testing.T, expected string, returned string) {
- if strings.Compare(returned, expected) != 0 {
- t.Fatalf("Expected(%d): `%s`\nGot(%d): `%s`\n",
- len(expected), expected,
- len(returned), returned)
- }
-}
-
-func TestIDLParser(t *testing.T) {
- pkgname, b, err := generateTemplate(`
-# Interface to jump a spacecraft to another point in space. The
-# FTL Drive is the propulsion system to achieve faster-than-light
-# travel through space. A ship making a properly calculated
-# jump can arrive safely in planetary orbit, or alongside other
-# ships or spaceborne objects.
-interface org.example.ftl
-
-# The current state of the FTL drive and the amount of fuel
-# available to jump.
-type DriveCondition (
- state: (idle, spooling, busy),
- booster: bool,
- active_engines: [](id: int, state: bool),
- tylium_level: int
-)
-
-# Speed, trajectory and jump duration is calculated prior to
-# activating the FTL drive.
-type DriveConfiguration (
- speed: int,
- trajectory: int,
- duration: int
-)
-
-# The galactic coordinates use the Sun as the origin. Galactic
-# longitude is measured with primary direction from the Sun to
-# the center of the galaxy in the galactic plane, while the
-# galactic latitude measures the angle of the object above the
-# galactic plane.
-type Coordinate (
- longitude: float,
- latitude: float,
- distance: int
-)
-
-# Monitor the drive. The method will reply with an update whenever
-# the drive's state changes
-method Monitor() -> (condition: DriveCondition)
-
-# Calculate the drive's jump parameters from the current
-# position to the target position in the galaxy
-method CalculateConfiguration(
- current: Coordinate,
- target: Coordinate
-) -> (configuration: DriveConfiguration)
-
-# Jump to the calculated point in space
-method Jump(configuration: DriveConfiguration) -> ()
-
-# There is not enough tylium to jump with the given parameters
-error NotEnoughEnergy ()
-
-# The supplied parameters are outside the supported range
-error ParameterOutOfRange (field: string)
-
-# some more coverage
-method Foo(interface: string) -> (ret: (go: string, switch: bool, more: (t:bool, f:bool)))
-
-# some more coverage
-method TestMap(map: [string]string) -> (map: [string](i: int, val: string))
-method TestSet(set: [string]()) -> (set: [string]())
-method TestObject(object: object) -> (object: object)
- `)
-
- if err != nil {
- t.Fatalf("Error parsing %v", err)
- }
- expect(t, "orgexampleftl", pkgname)
- if len(b) <= 0 {
- t.Fatal("No generated go source")
- }
- // FIXME: compare b.String() against expected output
-}
diff --git a/vendor/github.com/varlink/go/cmd/varlink-go-type-generator/main.go b/vendor/github.com/varlink/go/cmd/varlink-go-type-generator/main.go
deleted file mode 100644
index 46414b7bf..000000000
--- a/vendor/github.com/varlink/go/cmd/varlink-go-type-generator/main.go
+++ /dev/null
@@ -1,172 +0,0 @@
-package main
-
-import (
- "fmt"
- "go/ast"
- "go/importer"
- "go/parser"
- "go/token"
- "go/types"
- "log"
- "os"
-)
-
-func IsBasicGoType(t types.Type, flag types.BasicInfo) bool {
- switch u := t.(type) {
- case *types.Basic:
- if u.Info()&flag != 0 {
- return true
- }
- return false
- case *types.Named:
- return IsBasicGoType(u.Underlying(), flag)
- }
- return false
-}
-
-func GoToVarlinkType(t types.Type) string {
- if IsBasicGoType(t, types.IsBoolean) {
- return "bool"
- }
-
- if IsBasicGoType(t, types.IsInteger) {
- return "int"
- }
-
- if IsBasicGoType(t, types.IsFloat) {
- return "float"
- }
-
- if IsBasicGoType(t, types.IsString) {
- return "string"
- }
-
- switch u := t.(type) {
- case *types.Basic:
- return fmt.Sprintf("<<<%s>>>", t.String())
-
- case *types.Named:
- return u.Obj().Name()
-
- case *types.Map:
- if IsBasicGoType(u.Key(), types.IsString) {
- return fmt.Sprintf("[string]%s", GoToVarlinkType(u.Elem()))
- } else {
- return fmt.Sprintf("<<<%s>>>", u.String())
- }
-
- case *types.Interface:
- if u.Empty() {
- return "()"
- }
- return fmt.Sprintf("<<<%s>>>", u.String())
-
- case *types.Pointer:
- return fmt.Sprintf("?%s", GoToVarlinkType(u.Elem()))
-
- case *types.Array:
- return fmt.Sprintf("[]%s", GoToVarlinkType(u.Elem()))
-
- case *types.Slice:
- return fmt.Sprintf("[]%s", GoToVarlinkType(u.Elem()))
-
- case *types.Struct:
- if u.NumFields() > 0 {
- s := ""
- for i := 0; i < u.NumFields(); i++ {
- if i > 0 {
- s += ",\n"
- }
- s += fmt.Sprintf("\t%s: %s",
- u.Field(i).Name(), GoToVarlinkType(u.Field(i).Type()))
- }
-
- return fmt.Sprintf("(\n%s\n)", s)
- }
- return "()"
-
- default:
- return fmt.Sprintf("<<<%T %s>>>", t, u)
- }
-}
-
-func PrintDefsUses(name string, fset *token.FileSet, files []*ast.File) error {
- conf := types.Config{
- Importer: importer.Default(),
- FakeImportC: true,
- }
-
- info := &types.Info{
- Defs: make(map[*ast.Ident]types.Object),
- }
-
- _, err := conf.Check(name, fset, files, info)
- if err != nil {
- return err // type error
- }
-
- seen := map[string]interface{}{}
-
- for id, obj := range info.Defs {
- if obj == nil {
- continue
- }
-
- if _, ok := seen[id.Name]; ok {
- continue
- }
-
- /*
- if !obj.Exported() || obj.Pkg().Name() != name {
- continue
- }
- */
- switch f := obj.Type().Underlying().(type) {
- case *types.Struct:
- if f.NumFields() > 0 {
- fmt.Printf("type %s %s\n\n", id.Name, GoToVarlinkType(f))
- }
- }
- seen[id.Name] = nil
- }
-
- return nil
-}
-
-func main() {
-
- path := os.Args[1]
- fs := token.NewFileSet()
-
- if stat, err := os.Stat(path); err == nil && stat.IsDir() {
- pkgs, err := parser.ParseDir(fs, path, nil, 0)
- if err != nil {
- fmt.Printf("parsing dir '%s': %s", path, err)
- }
- for name, pkg := range pkgs {
- log.Println("Found package:", name)
-
- fset := make([]*ast.File, len(pkg.Files), len(pkg.Files))
- idx := 0
- for _, value := range pkg.Files {
- fset[idx] = value
- idx++
- }
-
- if err := PrintDefsUses(name, fs, fset); err != nil {
- log.Print(err) // type error
- }
- }
- } else {
-
- fset, err := parser.ParseFile(fs, path, nil, 0)
-
- if err != nil {
- fmt.Printf("parsing file '%s': %s", path, err)
- }
- name := fset.Name.String()
- if err := PrintDefsUses(name, fs, []*ast.File{fset}); err != nil {
- log.Print(err) // type error
- }
- }
-}
diff --git a/vendor/github.com/varlink/go/cmd/varlink/main.go b/vendor/github.com/varlink/go/cmd/varlink/main.go
deleted file mode 100644
index 6781dd956..000000000
--- a/vendor/github.com/varlink/go/cmd/varlink/main.go
+++ /dev/null
@@ -1,295 +0,0 @@
-package main
-
-import (
- "encoding/json"
- "flag"
- "fmt"
- "github.com/TylerBrock/colorjson"
- "github.com/fatih/color"
- "github.com/varlink/go/varlink"
- "os"
- "strings"
-)
-
-var bold = color.New(color.Bold)
-var errorBoldRed string
-var bridge string
-
-func ErrPrintf(format string, a ...interface{}) {
- fmt.Fprintf(os.Stderr, "%s ", errorBoldRed)
- fmt.Fprintf(os.Stderr, format, a...)
-}
-
-func print_usage(set *flag.FlagSet, arg_help string) {
- if set == nil {
- fmt.Fprintf(os.Stderr, "Usage: %s [GLOBAL OPTIONS] COMMAND ...\n", os.Args[0])
- } else {
- fmt.Fprintf(os.Stderr, "Usage: %s [GLOBAL OPTIONS] %s [OPTIONS] %s\n", os.Args[0], set.Name(), arg_help)
- }
-
- fmt.Fprintln(os.Stderr, "\nGlobal Options:")
- flag.PrintDefaults()
-
- if set == nil {
- fmt.Fprintln(os.Stderr, "\nCommands:")
- fmt.Fprintln(os.Stderr, " info\tPrint information about a service")
- fmt.Fprintln(os.Stderr, " help\tPrint interface description or service information")
- fmt.Fprintln(os.Stderr, " call\tCall a method")
- } else {
- fmt.Fprintln(os.Stderr, "\nOptions:")
- set.PrintDefaults()
- }
- os.Exit(1)
-}
-
-func varlink_call(args []string) {
- var err error
- var oneway bool
-
- callFlags := flag.NewFlagSet("help", flag.ExitOnError)
- callFlags.BoolVar(&oneway, "-oneway", false, "Use bridge for connection")
- var help bool
- callFlags.BoolVar(&help, "help", false, "Prints help information")
- var usage = func() { print_usage(callFlags, "<[ADDRESS/]INTERFACE.METHOD> [ARGUMENTS]") }
- callFlags.Usage = usage
-
- _ = callFlags.Parse(args)
-
- if help {
- usage()
- }
-
- var con *varlink.Connection
- var address string
- var methodName string
-
- if len(bridge) != 0 {
- con, err = varlink.NewBridge(bridge)
-
- if err != nil {
- ErrPrintf("Cannot connect with bridge '%s': %v\n", bridge, err)
- os.Exit(2)
- }
- address = "bridge:" + bridge
- methodName = callFlags.Arg(0)
- } else {
- uri := callFlags.Arg(0)
- if uri == "" {
- usage()
- }
-
- li := strings.LastIndex(uri, "/")
-
- if li == -1 {
- ErrPrintf("Invalid address '%s'\n", uri)
- os.Exit(2)
- }
-
- address = uri[:li]
- methodName = uri[li+1:]
-
- con, err = varlink.NewConnection(address)
-
- if err != nil {
- ErrPrintf("Cannot connect to '%s': %v\n", address, err)
- os.Exit(2)
- }
- }
- var parameters string
- var params json.RawMessage
-
- parameters = callFlags.Arg(1)
- if parameters == "" {
- params = nil
- } else {
- json.Unmarshal([]byte(parameters), &params)
- }
-
- var flags uint64
- flags = 0
- if oneway {
- flags |= varlink.Oneway
- }
- recv, err := con.Send(methodName, params, flags)
-
- var retval map[string]interface{}
-
- // FIXME: Use cont
- _, err = recv(&retval)
-
- f := colorjson.NewFormatter()
- f.Indent = 2
- f.KeyColor = color.New(color.FgCyan)
- f.StringColor = color.New(color.FgMagenta)
- f.NumberColor = color.New(color.FgMagenta)
- f.BoolColor = color.New(color.FgMagenta)
- f.NullColor = color.New(color.FgMagenta)
-
- if err != nil {
- 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 {
- var param map[string]interface{}
- _ = json.Unmarshal(*errorRawParameters, &param)
- c, _ := f.Marshal(param)
- fmt.Fprintf(os.Stderr, "%v\n", string(c))
- }
- os.Exit(2)
- }
- ErrPrintf("Error calling '%s': %v\n", methodName, err)
- os.Exit(2)
- }
- c, _ := f.Marshal(retval)
- fmt.Println(string(c))
-}
-
-func varlink_help(args []string) {
- var err error
-
- helpFlags := flag.NewFlagSet("help", flag.ExitOnError)
- var help bool
- helpFlags.BoolVar(&help, "help", false, "Prints help information")
- var usage = func() { print_usage(helpFlags, "<[ADDRESS/]INTERFACE>") }
- helpFlags.Usage = usage
-
- _ = helpFlags.Parse(args)
-
- if help {
- usage()
- }
-
- var con *varlink.Connection
- var address string
- var interfaceName string
-
- if len(bridge) != 0 {
- con, err = varlink.NewBridge(bridge)
-
- if err != nil {
- ErrPrintf("Cannot connect with bridge '%s': %v\n", bridge, err)
- os.Exit(2)
- }
- address = "bridge:" + bridge
- interfaceName = helpFlags.Arg(0)
- } else {
- uri := helpFlags.Arg(0)
- if uri == "" && bridge == "" {
- ErrPrintf("No ADDRESS or activation or bridge\n\n")
- usage()
- }
-
- li := strings.LastIndex(uri, "/")
-
- if li == -1 {
- ErrPrintf("Invalid address '%s'\n", uri)
- os.Exit(2)
- }
-
- address = uri[:li]
-
- con, err = varlink.NewConnection(address)
-
- if err != nil {
- ErrPrintf("Cannot connect to '%s': %v\n", address, err)
- os.Exit(2)
- }
-
- interfaceName = uri[li+1:]
- }
- description, err := con.GetInterfaceDescription(interfaceName)
-
- if err != nil {
- ErrPrintf("Cannot get interface description for '%s': %v\n", interfaceName, err)
- os.Exit(2)
- }
-
- fmt.Println(description)
-}
-
-func varlink_info(args []string) {
- var err error
- infoFlags := flag.NewFlagSet("info", flag.ExitOnError)
- var help bool
- infoFlags.BoolVar(&help, "help", false, "Prints help information")
- var usage = func() { print_usage(infoFlags, "[ADDRESS]") }
- infoFlags.Usage = usage
-
- _ = infoFlags.Parse(args)
-
- if help {
- usage()
- }
-
- var con *varlink.Connection
- var address string
-
- if len(bridge) != 0 {
- con, err = varlink.NewBridge(bridge)
-
- if err != nil {
- ErrPrintf("Cannot connect with bridge '%s': %v\n", bridge, err)
- os.Exit(2)
- }
- address = "bridge:" + bridge
- } else {
- address = infoFlags.Arg(0)
-
- if address == "" && bridge == "" {
- ErrPrintf("No ADDRESS or activation or bridge\n\n")
- usage()
- }
-
- con, err = varlink.NewConnection(address)
-
- if err != nil {
- ErrPrintf("Cannot connect to '%s': %v\n", address, err)
- os.Exit(2)
- }
- }
-
- var vendor, product, version, url string
- var interfaces []string
-
- err = con.GetInfo(&vendor, &product, &version, &url, &interfaces)
-
- if err != nil {
- ErrPrintf("Cannot get info for '%s': %v\n", address, err)
- os.Exit(2)
- }
-
- fmt.Printf("%s %s\n", bold.Sprint("Vendor:"), vendor)
- fmt.Printf("%s %s\n", bold.Sprint("Product:"), product)
- fmt.Printf("%s %s\n", bold.Sprint("Version:"), version)
- fmt.Printf("%s %s\n", bold.Sprint("URL:"), url)
- fmt.Printf("%s\n %s\n\n", bold.Sprint("Interfaces:"), strings.Join(interfaces[:], "\n "))
-}
-
-func main() {
- var debug bool
- var colorMode string
-
- flag.CommandLine.Usage = func() { print_usage(nil, "") }
- flag.BoolVar(&debug, "debug", false, "Enable debug output")
- flag.StringVar(&bridge, "bridge", "", "Use bridge for connection")
- flag.StringVar(&colorMode, "color", "auto", "colorize output [default: auto] [possible values: on, off, auto]")
-
- flag.Parse()
-
- if colorMode != "on" && (os.Getenv("TERM") == "" || colorMode == "off") {
- 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:])
- case "help":
- varlink_help(flag.Args()[1:])
- case "call":
- varlink_call(flag.Args()[1:])
- default:
- print_usage(nil, "")
- }
-}
diff --git a/vendor/github.com/varlink/go/golang-github-varlink-go.spec b/vendor/github.com/varlink/go/golang-github-varlink-go.spec
deleted file mode 100644
index 85f5d1788..000000000
--- a/vendor/github.com/varlink/go/golang-github-varlink-go.spec
+++ /dev/null
@@ -1,44 +0,0 @@
-%global goipath github.com/varlink/go
-Version: 0
-%gometa
-
-Name: %{goname}
-Release: 1%{?dist}
-Summary: Go bindings for varlink
-License: ASL 2.0
-URL: %{gourl}
-Source0: %{gosource}
-
-%description
-Native Go bindings for the varlink protocol.
-
-%package devel
-Summary: %{summary}
-BuildArch: noarch
-
-%description devel
-%{summary}
-
-This package contains library source intended for
-building other packages which use import path with
-%{gobaseipath} prefix.
-
-%prep
-%forgesetup
-
-%build
-%gobuildroot
-
-%install
-gofiles=$(find . %{gofindfilter} -print)
-%goinstall $gofiles
-
-%check
-
-%files devel -f devel.file-list
-%license LICENSE
-%doc README.md
-
-%changelog
-* Tue Mar 20 2018 <info@varlink.org> 0-1
-- Version 0
diff --git a/vendor/github.com/varlink/go/varlink/external_test.go b/vendor/github.com/varlink/go/varlink/external_test.go
deleted file mode 100644
index d5e14b25f..000000000
--- a/vendor/github.com/varlink/go/varlink/external_test.go
+++ /dev/null
@@ -1,211 +0,0 @@
-package varlink_test
-
-// test with no internal access
-
-import (
- "github.com/varlink/go/varlink"
- "os"
- "runtime"
- "testing"
- "time"
-)
-
-type VarlinkInterface struct{}
-
-func (s *VarlinkInterface) VarlinkDispatch(call varlink.Call, methodname string) error {
- return call.ReplyMethodNotImplemented(methodname)
-}
-func (s *VarlinkInterface) VarlinkGetName() string {
- return `org.example.test`
-}
-
-func (s *VarlinkInterface) VarlinkGetDescription() string {
- return "#"
-}
-
-type VarlinkInterface2 struct{}
-
-func (s *VarlinkInterface2) VarlinkDispatch(call varlink.Call, methodname string) error {
- return call.ReplyMethodNotImplemented(methodname)
-}
-func (s *VarlinkInterface2) VarlinkGetName() string {
- return `org.example.test2`
-}
-
-func (s *VarlinkInterface2) VarlinkGetDescription() string {
- return "#"
-}
-
-func TestRegisterService(t *testing.T) {
- newTestInterface := new(VarlinkInterface)
- service, err := varlink.NewService(
- "Varlink",
- "Varlink Test",
- "1",
- "https://github.com/varlink/go/varlink",
- )
- if err != nil {
- t.Fatalf("NewService(): %v", err)
- }
-
- if err := service.RegisterInterface(newTestInterface); err != nil {
- t.Fatalf("Couldn't register service: %v", err)
- }
-
- if err := service.RegisterInterface(newTestInterface); err == nil {
- t.Fatal("Could register service twice")
- }
-
- defer func() { service.Shutdown() }()
-
- servererror := make(chan error)
-
- go func() {
- servererror <- service.Listen("unix:varlinkexternal_TestRegisterService", 0)
- }()
-
- time.Sleep(time.Second / 5)
-
- n := new(VarlinkInterface2)
-
- if err := service.RegisterInterface(n); err == nil {
- t.Fatal("Could register service while running")
- }
- time.Sleep(time.Second / 5)
- service.Shutdown()
-
- if err := <-servererror; err != nil {
- t.Fatalf("service.Listen(): %v", err)
- }
-}
-
-func TestUnix(t *testing.T) {
- newTestInterface := new(VarlinkInterface)
- service, err := varlink.NewService(
- "Varlink",
- "Varlink Test",
- "1",
- "https://github.com/varlink/go/varlink",
- )
-
- if err != nil {
- t.Fatalf("NewService(): %v", err)
- }
-
- if err := service.RegisterInterface(newTestInterface); err != nil {
- t.Fatalf("RegisterInterface(): %v", err)
- }
-
- servererror := make(chan error)
-
- go func() {
- servererror <- service.Listen("unix:varlinkexternal_TestUnix", 0)
- }()
-
- time.Sleep(time.Second / 5)
- service.Shutdown()
-
- if err := <-servererror; err != nil {
- t.Fatalf("service.Listen(): %v", err)
- }
-}
-
-func TestInvalidAddress(t *testing.T) {
- newTestInterface := new(VarlinkInterface)
- service, err := varlink.NewService(
- "Varlink",
- "Varlink Test",
- "1",
- "https://github.com/varlink/go/varlink",
- )
-
- if err != nil {
- t.Fatalf("NewService(): %v", err)
- }
-
- if err = service.RegisterInterface(newTestInterface); err != nil {
- t.Fatalf("RegisterInterface(): %v", err)
- }
-
- if err = service.Listen("foo", 0); err == nil {
- t.Fatalf("service.Listen() should error")
- }
-
- if err = service.Listen("", 0); err == nil {
- t.Fatalf("service.Listen() should error")
- }
-
- if err = service.Listen("unix", 0); err == nil {
- t.Fatalf("service.Listen() should error")
- }
-}
-
-func TestAnonUnix(t *testing.T) {
- if runtime.GOOS != "linux" {
- return
- }
-
- newTestInterface := new(VarlinkInterface)
- service, err := varlink.NewService(
- "Varlink",
- "Varlink Test",
- "1",
- "https://github.com/varlink/go/varlink",
- )
-
- if err != nil {
- t.Fatalf("NewService(): %v", err)
- }
-
- if err := service.RegisterInterface(newTestInterface); err != nil {
- t.Fatalf("RegisterInterface(): %v", err)
- }
-
- servererror := make(chan error)
-
- go func() {
- servererror <- service.Listen("unix:@varlinkexternal_TestAnonUnix", 0)
- }()
-
- time.Sleep(time.Second / 5)
- service.Shutdown()
-
- if err := <-servererror; err != nil {
- t.Fatalf("service.Listen(): %v", err)
- }
-}
-
-func TestListenFDSNotInt(t *testing.T) {
- newTestInterface := new(VarlinkInterface)
- service, err := varlink.NewService(
- "Varlink",
- "Varlink Test",
- "1",
- "https://github.com/varlink/go/varlink",
- )
-
- if err != nil {
- t.Fatalf("NewService(): %v", err)
- }
-
- if err := service.RegisterInterface(newTestInterface); err != nil {
- t.Fatalf("Couldn't register service: %v", err)
- }
- os.Setenv("LISTEN_FDS", "foo")
- os.Setenv("LISTEN_PID", string(os.Getpid()))
-
- servererror := make(chan error)
-
- go func() {
- servererror <- service.Listen("unix:varlinkexternal_TestListenFDSNotInt", 0)
- }()
-
- time.Sleep(time.Second / 5)
- service.Shutdown()
-
- err = <-servererror
-
- if err != nil {
- t.Fatalf("service.Run(): %v", err)
- }
-}
diff --git a/vendor/github.com/varlink/go/varlink/idl/idl_test.go b/vendor/github.com/varlink/go/varlink/idl/idl_test.go
deleted file mode 100644
index a3377bec0..000000000
--- a/vendor/github.com/varlink/go/varlink/idl/idl_test.go
+++ /dev/null
@@ -1,150 +0,0 @@
-package idl
-
-import (
- "fmt"
- "runtime"
- "testing"
-)
-
-/*
-func expect(t *testing.T, expected string, returned string) {
- if strings.Compare(returned, expected) != 0 {
- t.Fatalf("Expected(%d): `%s`\nGot(%d): `%s`\n",
- len(expected), expected,
- len(returned), returned)
- }
-}
-*/
-
-func testParse(t *testing.T, pass bool, description string) {
- _, _, line, _ := runtime.Caller(1)
-
- t.Run(fmt.Sprintf("Line-%d", line), func(t *testing.T) {
- midl, err := New(description)
- if pass {
- if err != nil {
- t.Fatalf("generateTemplate(`%s`): %v", description, err)
- }
- if len(midl.Name) <= 0 {
- t.Fatalf("generateTemplate(`%s`): returned no pkgname", description)
- }
- }
- if !pass && (err == nil) {
- t.Fatalf("generateTemplate(`%s`): did not fail", description)
- }
- })
-}
-
-func TestOneMethod(t *testing.T) {
- testParse(t, true, "interface foo.bar\nmethod Foo()->()")
-}
-
-func TestOneMethodNoType(t *testing.T) {
- testParse(t, false, "interface foo.bar\nmethod Foo()->(b:)")
-}
-
-func TestDomainNames(t *testing.T) {
- testParse(t, true, "interface org.varlink.service\nmethod F()->()")
- testParse(t, true, "interface com.example.0example\nmethod F()->()")
- testParse(t, true, "interface com.example.example-dash\nmethod F()->()")
- testParse(t, true, "interface xn--lgbbat1ad8j.example.algeria\nmethod F()->()")
- testParse(t, false, "interface com.-example.leadinghyphen\nmethod F()->()")
- testParse(t, false, "interface com.example-.danglinghyphen-\nmethod F()->()")
- testParse(t, false, "interface Com.example.uppercase-toplevel\nmethod F()->()")
- testParse(t, false, "interface Co9.example.number-toplevel\nmethod F()->()")
- testParse(t, false, "interface 1om.example.number-toplevel\nmethod F()->()")
- testParse(t, false, "interface com.Example\nmethod F()->()")
- var name string
- for i := 0; i < 255; i++ {
- name += "a"
- }
- testParse(t, false, "interface com.example.toolong"+name+"\nmethod F()->()")
- testParse(t, false, "interface xn--example.toolong"+name+"\nmethod F()->()")
-}
-
-func TestNoMethod(t *testing.T) {
- testParse(t, false, `
-interface org.varlink.service
- type Interface (name: string, types: []Type, methods: []Method)
- type Property (key: string, value: string)
-`)
-}
-
-func TestTypeNoArgs(t *testing.T) {
- testParse(t, true, "interface foo.bar\n type I ()\nmethod F()->()")
-}
-
-func TestTypeOneArg(t *testing.T) {
- testParse(t, true, "interface foo.bar\n type I (b:bool)\nmethod F()->()")
-}
-
-func TestBasicTypes(t *testing.T) {
- testParse(t, true, "interface foo.bar\n type I (b:bool)\nmethod F()->()")
- testParse(t, true, "interface foo.bar\n type I (b:string)\nmethod F()->()")
- testParse(t, true, "interface foo.bar\n type I (b:float)\nmethod F()->()")
- testParse(t, true, "interface foo.bar\n type I (b:int)\nmethod F()->()")
- testParse(t, true, "interface foo.bar\n type I (b:object)\nmethod F()->()")
-}
-
-func TestTypeOneArray(t *testing.T) {
- testParse(t, true, "interface foo.bar\n type I (b:[]bool)\nmethod F()->()")
- testParse(t, false, "interface foo.bar\n type I (b:bool[ ])\nmethod F()->()")
- testParse(t, false, "interface foo.bar\n type I (b:bool[1])\nmethod F()->()")
- testParse(t, false, "interface foo.bar\n type I (b:bool[ 1 ])\nmethod F()->()")
- testParse(t, false, "interface foo.bar\n type I (b:bool[ 1 1 ])\nmethod F()->()")
-}
-
-func TestFieldnames(t *testing.T) {
- testParse(t, false, "interface foo.bar\n type I (Test:[]bool)\nmethod F()->()")
- testParse(t, false, "interface foo.bar\n type I (_test:[]bool)\nmethod F()->()")
- testParse(t, false, "interface foo.bar\n type I (Äest:[]bool)\nmethod F()->()")
-}
-
-func TestNestedStructs(t *testing.T) {
- testParse(t, true, "interface foo.bar\n type I ( b: [](foo: bool, bar: bool, baz: int) )\nmethod F()->()")
-}
-
-func TestEnum(t *testing.T) {
- testParse(t, true, "interface foo.bar\n type I (b:(foo, bar, baz))\nmethod F()->()")
- testParse(t, false, "interface foo.bar\n type I (foo, bar, baz : bool)\nmethod F()->()")
-}
-
-func TestMap(t *testing.T) {
- testParse(t, true, "interface foo.bar\n type I (m: [string]string)\nmethod F()->()")
- testParse(t, true, "interface foo.bar\n type I (m: [string]int)\nmethod F()->()")
- testParse(t, true, "interface foo.bar\n type I (m: [string]())\nmethod F()->()")
- testParse(t, false, "interface foo.bar\n type I (m: [int]string)\nmethod F()->()")
-}
-
-func TestMaybe(t *testing.T) {
- testParse(t, true, "interface foo.bar\n type I (m: ?string)\nmethod F()->()")
- testParse(t, true, "interface foo.bar\n type I (m: ?[string]?int)\nmethod F()->()")
- testParse(t, true, "interface foo.bar\n type I (m: ?[]?int)\nmethod F()->()")
- testParse(t, false, "interface foo.bar\n type I (m: ??int)\nmethod F()->()")
-}
-
-func TestIncomplete(t *testing.T) {
- testParse(t, false, "interfacef foo.bar\nmethod F()->()")
- testParse(t, false, "interface foo.bar\nmethod F()->()\ntype I (b: bool")
- testParse(t, false, "interface foo.bar\nmethod F()->(")
- testParse(t, false, "interface foo.bar\nmethod F(")
- testParse(t, false, "interface foo.bar\nmethod ()->()")
- testParse(t, false, "interface foo.bar\nmethod F->()\n")
- testParse(t, false, "interface foo.bar\nmethod F()->\n")
- testParse(t, false, "interface foo.bar\nmethod F()>()\n")
- testParse(t, false, "interface foo.bar\nmethod F()->()\ntype (b: bool)")
- testParse(t, false, "interface foo.bar\nmethod F()->()\nerror (b: bool)")
- testParse(t, false, "interface foo.bar\nmethod F()->()\n dfghdrg")
-}
-
-func TestDuplicate(t *testing.T) {
- testParse(t, false, `
-interface foo.example
- type Device()
- type Device()
- type T()
- type T()
- method F() -> ()
- method F() -> ()
-`)
-}
diff --git a/vendor/github.com/varlink/go/varlink/varlink_test.go b/vendor/github.com/varlink/go/varlink/varlink_test.go
deleted file mode 100644
index 9e6d0a1f4..000000000
--- a/vendor/github.com/varlink/go/varlink/varlink_test.go
+++ /dev/null
@@ -1,258 +0,0 @@
-package varlink
-
-// tests with access to internals
-
-import (
- "bufio"
- "bytes"
- "fmt"
- "strings"
- "testing"
-)
-
-func expect(t *testing.T, expected string, returned string) {
- if strings.Compare(returned, expected) != 0 {
- t.Fatalf("Expected(%d): `%s`\nGot(%d): `%s`\n",
- len(expected), expected,
- len(returned), strings.Replace(returned, "\000", "`+\"\\000\"+`", -1))
- }
-}
-
-func TestService(t *testing.T) {
- service, _ := NewService(
- "Varlink",
- "Varlink Test",
- "1",
- "https://github.com/varlink/go/varlink",
- )
-
- t.Run("ZeroMessage", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- if err := service.HandleMessage(nil, r, w, []byte{0}); err == nil {
- t.Fatal("HandleMessage returned non-error")
- }
- })
-
- t.Run("InvalidJson", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"foo.GetInterfaceDescription" fdgdfg}`)
- if err := service.HandleMessage(nil, r, w, msg); err == nil {
- t.Fatal("HandleMessage returned no error on invalid json")
- }
- })
-
- t.Run("WrongInterface", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"foo.GetInterfaceDescription"}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatal("HandleMessage returned error on wrong interface")
- }
- expect(t, `{"parameters":{"interface":"foo"},"error":"org.varlink.service.InterfaceNotFound"}`+"\000",
- b.String())
- })
-
- t.Run("InvalidMethod", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"InvalidMethod"}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatal("HandleMessage returned error on invalid method")
- }
- expect(t, `{"parameters":{"parameter":"method"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
- b.String())
- })
-
- t.Run("WrongMethod", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"org.varlink.service.WrongMethod"}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatal("HandleMessage returned error on wrong method")
- }
- expect(t, `{"parameters":{"method":"WrongMethod"},"error":"org.varlink.service.MethodNotFound"}`+"\000",
- b.String())
- })
-
- t.Run("GetInterfaceDescriptionNullParameters", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters": null}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatalf("HandleMessage returned error: %v", err)
- }
- expect(t, `{"parameters":{"parameter":"parameters"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
- b.String())
- })
-
- t.Run("GetInterfaceDescriptionNoInterface", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters":{}}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatalf("HandleMessage returned error: %v", err)
- }
- expect(t, `{"parameters":{"parameter":"interface"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
- b.String())
- })
-
- t.Run("GetInterfaceDescriptionWrongInterface", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters":{"interface":"foo"}}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatalf("HandleMessage returned error: %v", err)
- }
- expect(t, `{"parameters":{"parameter":"interface"},"error":"org.varlink.service.InvalidParameter"}`+"\000",
- b.String())
- })
-
- t.Run("GetInterfaceDescription", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"org.varlink.service.GetInterfaceDescription","parameters":{"interface":"org.varlink.service"}}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatalf("HandleMessage returned error: %v", err)
- }
- expect(t, `{"parameters":{"description":"# The Varlink Service Interface is provided by every varlink service. It\n# describes the service and the interfaces it implements.\ninterface org.varlink.service\n\n# Get a list of all the interfaces a service provides and information\n# about the implementation.\nmethod GetInfo() -\u003e (\n vendor: string,\n product: string,\n version: string,\n url: string,\n interfaces: []string\n)\n\n# Get the description of an interface that is implemented by this service.\nmethod GetInterfaceDescription(interface: string) -\u003e (description: string)\n\n# The requested interface was not found.\nerror InterfaceNotFound (interface: string)\n\n# The requested method was not found\nerror MethodNotFound (method: string)\n\n# The interface defines the requested method, but the service does not\n# implement it.\nerror MethodNotImplemented (method: string)\n\n# One of the passed parameters is invalid.\nerror InvalidParameter (parameter: string)"}}`+"\000",
- b.String())
- })
-
- t.Run("GetInfo", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"org.varlink.service.GetInfo"}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatalf("HandleMessage returned error: %v", err)
- }
- expect(t, `{"parameters":{"vendor":"Varlink","product":"Varlink Test","version":"1","url":"https://github.com/varlink/go/varlink","interfaces":["org.varlink.service"]}}`+"\000",
- b.String())
- })
-}
-
-type VarlinkInterface struct{}
-
-func (s *VarlinkInterface) VarlinkDispatch(call Call, methodname string) error {
- switch methodname {
- case "Ping":
- if !call.WantsMore() {
- return fmt.Errorf("More flag not passed")
- }
- if call.IsOneway() {
- return fmt.Errorf("OneShot flag set")
- }
- call.Continues = true
- if err := call.Reply(nil); err != nil {
- return err
- }
- if err := call.Reply(nil); err != nil {
- return err
- }
- call.Continues = false
- if err := call.Reply(nil); err != nil {
- return err
- }
- return nil
-
- case "PingError":
- return call.ReplyError("org.example.test.PingError", nil)
- }
-
- call.Continues = true
- if err := call.Reply(nil); err == nil {
- return fmt.Errorf("call.Reply did not fail for Continues/More mismatch")
- }
- call.Continues = false
-
- if err := call.ReplyError("WrongName", nil); err == nil {
- return fmt.Errorf("call.ReplyError accepted invalid error name")
- }
-
- if err := call.ReplyError("org.varlink.service.MethodNotImplemented", nil); err == nil {
- return fmt.Errorf("call.ReplyError accepted org.varlink.service error")
- }
-
- return call.ReplyMethodNotImplemented(methodname)
-}
-func (s *VarlinkInterface) VarlinkGetName() string {
- return `org.example.test`
-}
-
-func (s *VarlinkInterface) VarlinkGetDescription() string {
- return "#"
-}
-
-func TestMoreService(t *testing.T) {
- newTestInterface := new(VarlinkInterface)
-
- service, _ := NewService(
- "Varlink",
- "Varlink Test",
- "1",
- "https://github.com/varlink/go/varlink",
- )
-
- if err := service.RegisterInterface(newTestInterface); err != nil {
- t.Fatalf("Couldn't register service: %v", err)
- }
-
- t.Run("MethodNotImplemented", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"org.example.test.Pingf"}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatalf("HandleMessage returned error: %v", err)
- }
- expect(t, `{"parameters":{"method":"Pingf"},"error":"org.varlink.service.MethodNotImplemented"}`+"\000",
- b.String())
- })
-
- t.Run("PingError", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"org.example.test.PingError", "more" : true}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatalf("HandleMessage returned error: %v", err)
- }
- expect(t, `{"error":"org.example.test.PingError"}`+"\000",
- b.String())
- })
- t.Run("MoreTest", func(t *testing.T) {
- var br bytes.Buffer
- r := bufio.NewReader(&br)
- var b bytes.Buffer
- w := bufio.NewWriter(&b)
- msg := []byte(`{"method":"org.example.test.Ping", "more" : true}`)
- if err := service.HandleMessage(nil, r, w, msg); err != nil {
- t.Fatalf("HandleMessage returned error: %v", err)
- }
- expect(t, `{"continues":true}`+"\000"+`{"continues":true}`+"\000"+`{}`+"\000",
- b.String())
- })
-}