From a3151ce5aa1c59a2cb25729009b41e7b61875530 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Mon, 23 Aug 2021 19:11:24 +0200 Subject: Extract print body --- client/go/src/cmd/document.go | 1 + client/go/src/cmd/query.go | 10 +--------- client/go/src/utils/http.go | 1 - client/go/src/utils/print.go | 13 +++++++++++++ 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/client/go/src/cmd/document.go b/client/go/src/cmd/document.go index 4e54e3fcb33..f5f94138fb1 100644 --- a/client/go/src/cmd/document.go +++ b/client/go/src/cmd/document.go @@ -58,6 +58,7 @@ func get(documentId string) { } func put(documentId string, jsonFile string) { + // TODO: Support document id in JSON, see https://docs.vespa.ai/en/reference/document-json-format.html url, _ := url.Parse(getTarget(documentContext).document + "/document/v1/" + documentId) header := http.Header{} diff --git a/client/go/src/cmd/query.go b/client/go/src/cmd/query.go index bf678b19f4d..6921cd38f89 100644 --- a/client/go/src/cmd/query.go +++ b/client/go/src/cmd/query.go @@ -5,7 +5,6 @@ package cmd import ( - "bufio" "errors" "github.com/spf13/cobra" "github.com/vespa-engine/vespa/utils" @@ -51,14 +50,7 @@ func query(arguments []string) { defer response.Body.Close() if (response.StatusCode == 200) { - // TODO: Pretty-print body - scanner := bufio.NewScanner(response.Body) - for ;scanner.Scan(); { - utils.Print(scanner.Text()) - } - if err := scanner.Err(); err != nil { - utils.Error(err.Error()) - } + utils.PrintReader(response.Body) } else if response.StatusCode % 100 == 4 { utils.Error("Invalid query (status ", response.Status, ")") utils.Detail() diff --git a/client/go/src/utils/http.go b/client/go/src/utils/http.go index 977669a4da2..159ffb8d11a 100644 --- a/client/go/src/utils/http.go +++ b/client/go/src/utils/http.go @@ -53,4 +53,3 @@ func HttpDo(request *http.Request, timeout time.Duration, description string) *h } return response } - diff --git a/client/go/src/utils/print.go b/client/go/src/utils/print.go index f13a2c45cd0..f3a57c4ba2f 100644 --- a/client/go/src/utils/print.go +++ b/client/go/src/utils/print.go @@ -5,6 +5,7 @@ package utils import ( + "bufio" "fmt" "io" "os" @@ -37,6 +38,18 @@ func Detail(messages ...string) { print("\033[33m", messages) } +// Prints all the text of the given reader +func PrintReader(reader io.ReadCloser) { + // TODO: Pretty-print body + scanner := bufio.NewScanner(reader) + for ;scanner.Scan(); { + Print(scanner.Text()) + } + if err := scanner.Err(); err != nil { + Error(err.Error()) + } +} + func print(prefix string, messages []string) { fmt.Fprint(Out, prefix) for i := 0; i < len(messages); i++ { -- cgit v1.2.3 From 9b3678fa29b3730efe5a1b659dace40e25eb03ea Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Mon, 23 Aug 2021 20:36:54 +0200 Subject: Output error messages and test --- client/go/src/cmd/command_tester.go | 2 ++ client/go/src/cmd/deploy.go | 10 +++++----- client/go/src/cmd/deploy_test.go | 26 ++++++++++++++++++++++++-- client/go/src/cmd/document.go | 13 ++++++------- client/go/src/cmd/document_test.go | 27 +++++++++++++++++++++++++++ client/go/src/cmd/query.go | 10 +++++----- client/go/src/cmd/query_test.go | 26 ++++++++++++++++++++++++++ client/go/src/cmd/status.go | 2 +- client/go/src/cmd/status_test.go | 2 +- 9 files changed, 97 insertions(+), 21 deletions(-) diff --git a/client/go/src/cmd/command_tester.go b/client/go/src/cmd/command_tester.go index d7899c51436..bd77e7cdcaa 100644 --- a/client/go/src/cmd/command_tester.go +++ b/client/go/src/cmd/command_tester.go @@ -11,6 +11,7 @@ import ( "io/ioutil" "net/http" "testing" + "strconv" "time" ) @@ -47,6 +48,7 @@ func (c *mockHttpClient) Do(request *http.Request, timeout time.Duration) (respo } c.lastRequest = request return &http.Response{ + Status: "Status " + strconv.Itoa(c.nextStatus), StatusCode: c.nextStatus, Body: ioutil.NopCloser(bytes.NewBufferString(c.nextBody)), Header: make(http.Header), diff --git a/client/go/src/cmd/deploy.go b/client/go/src/cmd/deploy.go index 9e6940179da..8ffa44b72dd 100644 --- a/client/go/src/cmd/deploy.go +++ b/client/go/src/cmd/deploy.go @@ -126,12 +126,12 @@ func deploy(prepare bool, application string) { return } else if response.StatusCode == 200 { utils.Success("Success") - } else if response.StatusCode % 100 == 4 { - utils.Error("Invalid application package") - // TODO: Output error in body + } else if response.StatusCode / 100 == 4 { + utils.Error("Invalid application package", "(" + response.Status + "):") + utils.PrintReader(response.Body) } else { - utils.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host) - utils.Detail("Response status:", response.Status) + utils.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") + utils.PrintReader(response.Body) } } diff --git a/client/go/src/cmd/deploy_test.go b/client/go/src/cmd/deploy_test.go index 99cfedebc8f..64ede50546c 100644 --- a/client/go/src/cmd/deploy_test.go +++ b/client/go/src/cmd/deploy_test.go @@ -6,6 +6,7 @@ package cmd import ( "github.com/stretchr/testify/assert" + "strconv" "testing" ) @@ -41,7 +42,14 @@ func TestDeployDirectory(t *testing.T) { assertDeployRequestMade("http://127.0.0.1:19071", client, t) } -// TODO: Test error replies (5xx and 4xx with error message) +func TestDeployApplicationPackageError(t *testing.T) { + assertApplicationPackageError(t, 401, "Application package error") +} + +func TestDeployError(t *testing.T) { + assertDeployServerError(t, 501, "Deploy service error") +} + // TODO: Test prepare and activate prepared func assertDeployRequestMade(target string, client *mockHttpClient, t *testing.T) { @@ -53,4 +61,18 @@ func assertDeployRequestMade(target string, client *mockHttpClient, t *testing.T buf := make([]byte, 7) // Just check the first few bytes body.Read(buf) assert.Equal(t, "PK\x03\x04\x14\x00\b", string(buf)) -} \ No newline at end of file +} + +func assertApplicationPackageError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mInvalid application package (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"deploy", "activate", "testdata/src/main/application"}, []string{})) +} + +func assertDeployServerError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mError from deploy service at 127.0.0.1:19071 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"deploy", "activate", "testdata/src/main/application"}, []string{})) +} diff --git a/client/go/src/cmd/document.go b/client/go/src/cmd/document.go index f5f94138fb1..8d4e238018f 100644 --- a/client/go/src/cmd/document.go +++ b/client/go/src/cmd/document.go @@ -77,19 +77,18 @@ func put(documentId string, jsonFile string) { Header: header, Body: ioutil.NopCloser(fileReader), } - serviceDescription := "Container (document/v1 API)" + serviceDescription := "Container (document API)" response := utils.HttpDo(request, time.Second * 60, serviceDescription) defer response.Body.Close() if (response == nil) { return } else if response.StatusCode == 200 { utils.Success("Success") // TODO: Change to something including document id - } else if response.StatusCode % 100 == 4 { - utils.Error("Invalid document") - utils.Detail(response.Status) - // TODO: Output error in body + } else if response.StatusCode / 100 == 4 { + utils.Error("Invalid document (" + response.Status + "):") + utils.PrintReader(response.Body) } else { - utils.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host) - utils.Detail("Response status:", response.Status) + utils.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") + utils.PrintReader(response.Body) } } \ No newline at end of file diff --git a/client/go/src/cmd/document_test.go b/client/go/src/cmd/document_test.go index 7e9af0ab921..a177aa87d82 100644 --- a/client/go/src/cmd/document_test.go +++ b/client/go/src/cmd/document_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/vespa-engine/vespa/utils" "io/ioutil" + "strconv" "testing" ) @@ -15,6 +16,14 @@ func TestDocumentPut(t *testing.T) { assertDocumentPut("mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json", t) } +func TestDocumentPutDocumentError(t *testing.T) { + assertDocumentError(t, 401, "Document error") +} + +func TestDocumentPutServerError(t *testing.T) { + assertDocumentServerError(t, 501, "Server error") +} + func assertDocumentPut(documentId string, jsonFile string, t *testing.T) { client := &mockHttpClient{} assert.Equal(t, @@ -28,3 +37,21 @@ func assertDocumentPut(documentId string, jsonFile string, t *testing.T) { fileContent, _ := ioutil.ReadFile(jsonFile) assert.Equal(t, string(fileContent), utils.ReaderToString(client.lastRequest.Body)) } + +func assertDocumentError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mInvalid document (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"document", + "mynamespace/music/docid/1", + "testdata/A-Head-Full-of-Dreams.json"}, []string{})) +} + +func assertDocumentServerError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mError from container (document api) at 127.0.0.1:8080 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"document", + "mynamespace/music/docid/1", + "testdata/A-Head-Full-of-Dreams.json"}, []string{})) +} \ No newline at end of file diff --git a/client/go/src/cmd/query.go b/client/go/src/cmd/query.go index 6921cd38f89..b4380cc81b9 100644 --- a/client/go/src/cmd/query.go +++ b/client/go/src/cmd/query.go @@ -51,12 +51,12 @@ func query(arguments []string) { if (response.StatusCode == 200) { utils.PrintReader(response.Body) - } else if response.StatusCode % 100 == 4 { - utils.Error("Invalid query (status ", response.Status, ")") - utils.Detail() + } else if response.StatusCode / 100 == 4 { + utils.Error("Invalid query (" + response.Status + "):") + utils.PrintReader(response.Body) } else { - utils.Error("Request failed") - utils.Detail(response.Status) + utils.Error("Error from container at", url.Host, "(" + response.Status + "):") + utils.PrintReader(response.Body) } } diff --git a/client/go/src/cmd/query_test.go b/client/go/src/cmd/query_test.go index e062e9c718a..ab48c482a7d 100644 --- a/client/go/src/cmd/query_test.go +++ b/client/go/src/cmd/query_test.go @@ -6,6 +6,7 @@ package cmd import ( "github.com/stretchr/testify/assert" + "strconv" "testing" ) @@ -27,6 +28,14 @@ func TestQueryWithExplicitYqlParameter(t *testing.T) { "yql=select from sources * where title contains 'foo'") } +func TestIllegalQuery(t *testing.T) { + assertQueryError(t, 401, "query error message") +} + +func TestServerError(t *testing.T) { + assertQueryServiceError(t, 501, "server error message") +} + func assertQuery(t *testing.T, expectedQuery string, query ...string) { client := &mockHttpClient{ nextBody: "query result", } assert.Equal(t, @@ -35,3 +44,20 @@ func assertQuery(t *testing.T, expectedQuery string, query ...string) { "query output") assert.Equal(t, getTarget(queryContext).query + "/search/" + expectedQuery, client.lastRequest.URL.String()) } + +func assertQueryError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mInvalid query (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"query"}, []string{"yql=select from sources * where title contains 'foo'"}), + "error output") +} + +func assertQueryServiceError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mError from container at 127.0.0.1:8080 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"query"}, []string{"yql=select from sources * where title contains 'foo'"}), + "error output") +} + diff --git a/client/go/src/cmd/status.go b/client/go/src/cmd/status.go index 809b63623ae..cb4df072c8d 100644 --- a/client/go/src/cmd/status.go +++ b/client/go/src/cmd/status.go @@ -52,7 +52,7 @@ func status(target string, description string) { if response.StatusCode != 200 { utils.Error(description, "at", target, "is not ready") - utils.Detail("Response status:", response.Status) + utils.Detail(response.Status) } else { utils.Success(description, "at", target, "is ready") } diff --git a/client/go/src/cmd/status_test.go b/client/go/src/cmd/status_test.go index 70fb33c27de..0910a6007b9 100644 --- a/client/go/src/cmd/status_test.go +++ b/client/go/src/cmd/status_test.go @@ -64,7 +64,7 @@ func assertContainerStatus(target string, args []string, t *testing.T) { func assertContainerError(target string, args []string, t *testing.T) { client := &mockHttpClient{ nextStatus: 500,} assert.Equal(t, - "\x1b[31mContainer at " + target + " is not ready\n\x1b[33mResponse status: \n", + "\x1b[31mContainer at " + target + " is not ready\n\x1b[33mStatus 500\n", executeCommand(t, client, []string{"status", "container"}, args), "vespa status container") } \ No newline at end of file -- cgit v1.2.3 From 184fe01e704228bbd93df8f4abf34d6c7d2e5fd5 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Mon, 23 Aug 2021 21:21:21 +0200 Subject: Handle no connection --- client/go/src/cmd/deploy.go | 6 ++++-- client/go/src/cmd/document.go | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/go/src/cmd/deploy.go b/client/go/src/cmd/deploy.go index 8ffa44b72dd..7d3475cd178 100644 --- a/client/go/src/cmd/deploy.go +++ b/client/go/src/cmd/deploy.go @@ -121,10 +121,12 @@ func deploy(prepare bool, application string) { } serviceDescription := "Deploy service" response := utils.HttpDo(request, time.Minute * 10, serviceDescription) - defer response.Body.Close() if (response == nil) { return - } else if response.StatusCode == 200 { + } + + defer response.Body.Close() + if response.StatusCode == 200 { utils.Success("Success") } else if response.StatusCode / 100 == 4 { utils.Error("Invalid application package", "(" + response.Status + "):") diff --git a/client/go/src/cmd/document.go b/client/go/src/cmd/document.go index 8d4e238018f..62ff1e0c06c 100644 --- a/client/go/src/cmd/document.go +++ b/client/go/src/cmd/document.go @@ -79,10 +79,12 @@ func put(documentId string, jsonFile string) { } serviceDescription := "Container (document API)" response := utils.HttpDo(request, time.Second * 60, serviceDescription) - defer response.Body.Close() if (response == nil) { return - } else if response.StatusCode == 200 { + } + + defer response.Body.Close() + if response.StatusCode == 200 { utils.Success("Success") // TODO: Change to something including document id } else if response.StatusCode / 100 == 4 { utils.Error("Invalid document (" + response.Status + "):") -- cgit v1.2.3 From 89dac5ccb4b9fd1f34c28338b2ed01e87a80c630 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Aug 2021 09:37:50 +0200 Subject: utils -> util --- client/go/src/cmd/command_tester.go | 6 ++-- client/go/src/cmd/config.go | 6 ++-- client/go/src/cmd/deploy.go | 30 +++++++++--------- client/go/src/cmd/document.go | 18 +++++------ client/go/src/cmd/document_test.go | 4 +-- client/go/src/cmd/init.go | 38 +++++++++++------------ client/go/src/cmd/init_test.go | 8 ++--- client/go/src/cmd/query.go | 14 ++++----- client/go/src/cmd/status.go | 10 +++--- client/go/src/cmd/target.go | 4 +-- client/go/src/util/http.go | 55 ++++++++++++++++++++++++++++++++ client/go/src/util/http_test.go | 46 +++++++++++++++++++++++++++ client/go/src/util/io.go | 31 +++++++++++++++++++ client/go/src/util/print.go | 62 +++++++++++++++++++++++++++++++++++++ client/go/src/utils/http.go | 55 -------------------------------- client/go/src/utils/http_test.go | 46 --------------------------- client/go/src/utils/io.go | 31 ------------------- client/go/src/utils/print.go | 62 ------------------------------------- 18 files changed, 263 insertions(+), 263 deletions(-) create mode 100644 client/go/src/util/http.go create mode 100644 client/go/src/util/http_test.go create mode 100644 client/go/src/util/io.go create mode 100644 client/go/src/util/print.go delete mode 100644 client/go/src/utils/http.go delete mode 100644 client/go/src/utils/http_test.go delete mode 100644 client/go/src/utils/io.go delete mode 100644 client/go/src/utils/print.go diff --git a/client/go/src/cmd/command_tester.go b/client/go/src/cmd/command_tester.go index bd77e7cdcaa..f1d4b52d0bb 100644 --- a/client/go/src/cmd/command_tester.go +++ b/client/go/src/cmd/command_tester.go @@ -6,7 +6,7 @@ package cmd import ( "bytes" - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" "github.com/stretchr/testify/assert" "io/ioutil" "net/http" @@ -16,14 +16,14 @@ import ( ) func executeCommand(t *testing.T, client *mockHttpClient, args []string, moreArgs []string) (standardout string) { - utils.ActiveHttpClient = client + util.ActiveHttpClient = client // Reset - persistent flags in Cobra persists over tests rootCmd.SetArgs([]string{"status", "-t", ""}) rootCmd.Execute() b := bytes.NewBufferString("") - utils.Out = b + util.Out = b rootCmd.SetArgs(append(args, moreArgs...)) rootCmd.Execute() out, err := ioutil.ReadAll(b) diff --git a/client/go/src/cmd/config.go b/client/go/src/cmd/config.go index 647d13939b1..2c10eaf8f02 100644 --- a/client/go/src/cmd/config.go +++ b/client/go/src/cmd/config.go @@ -7,7 +7,7 @@ package cmd import ( "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" "os" "path/filepath" ) @@ -52,12 +52,12 @@ func writeConfig() { _, statErr := os.Stat(configPath) if !os.IsExist(statErr) { if _, createErr := os.Create(configPath); createErr != nil { - utils.Error("Warning: Can not remember flag parameters: " + createErr.Error()) + util.Error("Warning: Can not remember flag parameters: " + createErr.Error()) } } writeErr := viper.WriteConfig() if writeErr != nil { - utils.Error("Could not write config:", writeErr.Error()) + util.Error("Could not write config:", writeErr.Error()) } } \ No newline at end of file diff --git a/client/go/src/cmd/deploy.go b/client/go/src/cmd/deploy.go index 7d3475cd178..bfd3837cd5a 100644 --- a/client/go/src/cmd/deploy.go +++ b/client/go/src/cmd/deploy.go @@ -8,7 +8,7 @@ import ( "archive/zip" "errors" "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" "io" "io/ioutil" "net/http" @@ -30,7 +30,7 @@ var deployCmd = &cobra.Command{ Short: "Deploys an application package", Long: `TODO: Use prepare or deploy activate`, Run: func(cmd *cobra.Command, args []string) { - utils.Error("Use either deploy prepare or deploy activate") + util.Error("Use either deploy prepare or deploy activate") }, } @@ -81,14 +81,14 @@ func deploy(prepare bool, application string) { if filepath.Ext(application) != ".zip" { tempZip, error := ioutil.TempFile("", "application.zip") if error != nil { - utils.Error("Could not create a temporary zip file for the application package") - utils.Detail(error.Error()) + util.Error("Could not create a temporary zip file for the application package") + util.Detail(error.Error()) return } error = zipDir(application, tempZip.Name()) if (error != nil) { - utils.Error(error.Error()) + util.Error(error.Error()) return } defer os.Remove(tempZip.Name()) @@ -97,8 +97,8 @@ func deploy(prepare bool, application string) { zipFileReader, zipFileError := os.Open(application) if zipFileError != nil { - utils.Error("Could not open application package at " + application) - utils.Detail(zipFileError.Error()) + util.Error("Could not open application package at " + application) + util.Detail(zipFileError.Error()) return } @@ -120,20 +120,20 @@ func deploy(prepare bool, application string) { Body: ioutil.NopCloser(zipFileReader), } serviceDescription := "Deploy service" - response := utils.HttpDo(request, time.Minute * 10, serviceDescription) + response := util.HttpDo(request, time.Minute * 10, serviceDescription) if (response == nil) { return } defer response.Body.Close() if response.StatusCode == 200 { - utils.Success("Success") + util.Success("Success") } else if response.StatusCode / 100 == 4 { - utils.Error("Invalid application package", "(" + response.Status + "):") - utils.PrintReader(response.Body) + util.Error("Invalid application package", "(" + response.Status + "):") + util.PrintReader(response.Body) } else { - utils.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") - utils.PrintReader(response.Body) + util.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") + util.PrintReader(response.Body) } } @@ -142,11 +142,11 @@ func zipDir(dir string, destination string) error { message := "Path must be relative, but '" + dir + "'" return errors.New(message) } - if ! utils.PathExists(dir) { + if ! util.PathExists(dir) { message := "'" + dir + "' should be an application package zip or dir, but does not exist" return errors.New(message) } - if ! utils.IsDirectory(dir) { + if ! util.IsDirectory(dir) { message := "'" + dir + "' should be an application package dir, but is a (non-zip) file" return errors.New(message) } diff --git a/client/go/src/cmd/document.go b/client/go/src/cmd/document.go index 62ff1e0c06c..f48a3965d01 100644 --- a/client/go/src/cmd/document.go +++ b/client/go/src/cmd/document.go @@ -6,7 +6,7 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" "io/ioutil" "net/http" "net/url" @@ -66,8 +66,8 @@ func put(documentId string, jsonFile string) { fileReader, fileError := os.Open(jsonFile) if fileError != nil { - utils.Error("Could not open file at " + jsonFile) - utils.Detail(fileError.Error()) + util.Error("Could not open file at " + jsonFile) + util.Detail(fileError.Error()) return } @@ -78,19 +78,19 @@ func put(documentId string, jsonFile string) { Body: ioutil.NopCloser(fileReader), } serviceDescription := "Container (document API)" - response := utils.HttpDo(request, time.Second * 60, serviceDescription) + response := util.HttpDo(request, time.Second * 60, serviceDescription) if (response == nil) { return } defer response.Body.Close() if response.StatusCode == 200 { - utils.Success("Success") // TODO: Change to something including document id + util.Success("Success") // TODO: Change to something including document id } else if response.StatusCode / 100 == 4 { - utils.Error("Invalid document (" + response.Status + "):") - utils.PrintReader(response.Body) + util.Error("Invalid document (" + response.Status + "):") + util.PrintReader(response.Body) } else { - utils.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") - utils.PrintReader(response.Body) + util.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") + util.PrintReader(response.Body) } } \ No newline at end of file diff --git a/client/go/src/cmd/document_test.go b/client/go/src/cmd/document_test.go index a177aa87d82..9d0ae6e505e 100644 --- a/client/go/src/cmd/document_test.go +++ b/client/go/src/cmd/document_test.go @@ -6,7 +6,7 @@ package cmd import ( "github.com/stretchr/testify/assert" - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" "io/ioutil" "strconv" "testing" @@ -35,7 +35,7 @@ func assertDocumentPut(documentId string, jsonFile string, t *testing.T) { assert.Equal(t, "POST", client.lastRequest.Method) fileContent, _ := ioutil.ReadFile(jsonFile) - assert.Equal(t, string(fileContent), utils.ReaderToString(client.lastRequest.Body)) + assert.Equal(t, string(fileContent), util.ReaderToString(client.lastRequest.Body)) } func assertDocumentError(t *testing.T, status int, errorMessage string) { diff --git a/client/go/src/cmd/init.go b/client/go/src/cmd/init.go index 7a5a7729246..64e8b342309 100644 --- a/client/go/src/cmd/init.go +++ b/client/go/src/cmd/init.go @@ -9,7 +9,7 @@ import ( "errors" "path/filepath" "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" "io" "io/ioutil" "net/http" @@ -54,15 +54,15 @@ func initApplication(name string, source string) { createErr := os.Mkdir(name, 0755) if createErr != nil { - utils.Error("Could not create directory '" + name + "'") - utils.Detail(createErr.Error()) + util.Error("Could not create directory '" + name + "'") + util.Detail(createErr.Error()) return } zipReader, zipOpenError := zip.OpenReader(zipFile.Name()) if zipOpenError != nil { - utils.Error("Could not open sample apps zip '" + zipFile.Name() + "'") - utils.Detail(zipOpenError.Error()) + util.Error("Could not open sample apps zip '" + zipFile.Name() + "'") + util.Detail(zipOpenError.Error()) } defer zipReader.Close() @@ -73,16 +73,16 @@ func initApplication(name string, source string) { found = true copyError := copy(f, name, zipEntryPrefix) if copyError != nil { - utils.Error("Could not copy zip entry '" + f.Name + "' to " + name) - utils.Detail(copyError.Error()) + util.Error("Could not copy zip entry '" + f.Name + "' to " + name) + util.Detail(copyError.Error()) return } } } if !found { - utils.Error("Could not find source application '" + source + "'") + util.Error("Could not find source application '" + source + "'") } else { - utils.Success("Created " + name) + util.Success("Created " + name) } } @@ -90,38 +90,38 @@ func getSampleAppsZip() *os.File { if existingSampleAppsZip != "" { existing, openExistingError := os.Open(existingSampleAppsZip) if openExistingError != nil { - utils.Error("Could not open existing sample apps zip file '" + existingSampleAppsZip + "'") - utils.Detail(openExistingError.Error()) + util.Error("Could not open existing sample apps zip file '" + existingSampleAppsZip + "'") + util.Detail(openExistingError.Error()) } return existing } // TODO: Cache it? - utils.Detail("Downloading sample apps ...") // TODO: Spawn thread to indicate progress + util.Detail("Downloading sample apps ...") // TODO: Spawn thread to indicate progress zipUrl, _ := url.Parse("https://github.com/vespa-engine/sample-apps/archive/refs/heads/master.zip") request := &http.Request{ URL: zipUrl, Method: "GET", } - response := utils.HttpDo(request, time.Minute * 60, "GitHub") + response := util.HttpDo(request, time.Minute * 60, "GitHub") defer response.Body.Close() if response.StatusCode != 200 { - utils.Error("Could not download sample apps from github") - utils.Detail(response.Status) + util.Error("Could not download sample apps from github") + util.Detail(response.Status) return nil } destination, tempFileError := ioutil.TempFile("", "prefix") if tempFileError != nil { - utils.Error("Could not create a temp file to hold sample apps") - utils.Detail(tempFileError.Error()) + util.Error("Could not create a temp file to hold sample apps") + util.Detail(tempFileError.Error()) } // destination, _ := os.Create("./" + name + "/sample-apps.zip") // defer destination.Close() _, err := io.Copy(destination, response.Body) if err != nil { - utils.Error("Could not download sample apps from GitHub") - utils.Detail(err.Error()) + util.Error("Could not download sample apps from GitHub") + util.Detail(err.Error()) return nil } return destination diff --git a/client/go/src/cmd/init_test.go b/client/go/src/cmd/init_test.go index f0f832293a7..3cb526ad0f1 100644 --- a/client/go/src/cmd/init_test.go +++ b/client/go/src/cmd/init_test.go @@ -5,7 +5,7 @@ package cmd import ( - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" "github.com/stretchr/testify/assert" "os" "testing" @@ -21,9 +21,9 @@ func assertCreated(app string, sampleAppName string, t *testing.T) { standardOut := executeCommand(t, &mockHttpClient{}, []string{"init", app, sampleAppName}, []string{}) defer os.RemoveAll(app) assert.Equal(t, "\x1b[32mCreated " + app + "\n", standardOut) - assert.True(t, utils.PathExists(filepath.Join(app, "README.md"))) - assert.True(t, utils.PathExists(filepath.Join(app, "src", "main", "application"))) - assert.True(t, utils.IsDirectory(filepath.Join(app, "src", "main", "application"))) + assert.True(t, util.PathExists(filepath.Join(app, "README.md"))) + assert.True(t, util.PathExists(filepath.Join(app, "src", "main", "application"))) + assert.True(t, util.IsDirectory(filepath.Join(app, "src", "main", "application"))) servicesStat, _ := os.Stat(filepath.Join(app, "src", "main", "application", "services.xml")) var servicesSize int64 diff --git a/client/go/src/cmd/query.go b/client/go/src/cmd/query.go index b4380cc81b9..58828dbb7cf 100644 --- a/client/go/src/cmd/query.go +++ b/client/go/src/cmd/query.go @@ -7,7 +7,7 @@ package cmd import ( "errors" "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" "strings" "net/http" "net/url" @@ -43,20 +43,20 @@ func query(arguments []string) { } url.RawQuery = urlQuery.Encode() - response := utils.HttpDo(&http.Request{URL: url,}, time.Second * 10, "Container") + response := util.HttpDo(&http.Request{URL: url,}, time.Second * 10, "Container") if (response == nil) { return } defer response.Body.Close() if (response.StatusCode == 200) { - utils.PrintReader(response.Body) + util.PrintReader(response.Body) } else if response.StatusCode / 100 == 4 { - utils.Error("Invalid query (" + response.Status + "):") - utils.PrintReader(response.Body) + util.Error("Invalid query (" + response.Status + "):") + util.PrintReader(response.Body) } else { - utils.Error("Error from container at", url.Host, "(" + response.Status + "):") - utils.PrintReader(response.Body) + util.Error("Error from container at", url.Host, "(" + response.Status + "):") + util.PrintReader(response.Body) } } diff --git a/client/go/src/cmd/status.go b/client/go/src/cmd/status.go index cb4df072c8d..a011678be09 100644 --- a/client/go/src/cmd/status.go +++ b/client/go/src/cmd/status.go @@ -6,7 +6,7 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" ) func init() { @@ -44,16 +44,16 @@ var statusConfigServerCmd = &cobra.Command{ func status(target string, description string) { path := "/ApplicationStatus" - response := utils.HttpGet(target, path, description) + response := util.HttpGet(target, path, description) if (response == nil) { return } defer response.Body.Close() if response.StatusCode != 200 { - utils.Error(description, "at", target, "is not ready") - utils.Detail(response.Status) + util.Error(description, "at", target, "is not ready") + util.Detail(response.Status) } else { - utils.Success(description, "at", target, "is ready") + util.Success(description, "at", target, "is ready") } } diff --git a/client/go/src/cmd/target.go b/client/go/src/cmd/target.go index 1d56c39540a..4c1ead7f74e 100644 --- a/client/go/src/cmd/target.go +++ b/client/go/src/cmd/target.go @@ -5,7 +5,7 @@ package cmd import ( - "github.com/vespa-engine/vespa/utils" + "github.com/vespa-engine/vespa/util" "strings" ) @@ -55,6 +55,6 @@ func getTarget(targetContext context) *target { return nil // TODO } - utils.Error("Unknown target argument '" + targetArgument + ": Use 'local', 'cloud' or an URL") + util.Error("Unknown target argument '" + targetArgument + ": Use 'local', 'cloud' or an URL") return nil } \ No newline at end of file diff --git a/client/go/src/util/http.go b/client/go/src/util/http.go new file mode 100644 index 00000000000..24e2416117c --- /dev/null +++ b/client/go/src/util/http.go @@ -0,0 +1,55 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// A HTTP wrapper which handles some errors and provides a way to replace the HTTP client by a mock. +// Author: bratseth + +package util + +import ( + "net/http" + "net/url" + "strings" + "time" +) + +// Set this to a mock HttpClient instead to unit test HTTP requests +var ActiveHttpClient = CreateClient(time.Second * 10) + +type HttpClient interface { + Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) +} + +type defaultHttpClient struct { + client *http.Client +} + +func (c *defaultHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { + if c.client.Timeout != timeout { // Create a new client with the right timeout + c.client = &http.Client{Timeout: timeout,} + } + return c.client.Do(request) +} + +func CreateClient(timeout time.Duration) HttpClient { + return &defaultHttpClient{ + client: &http.Client{Timeout: timeout,}, + } +} + +// Convenience function for doing a HTTP GET +func HttpGet(host string, path string, description string) *http.Response { + url, urlError := url.Parse(host + path) + if urlError != nil { + Error("Invalid target url '" + host + path + "'") + return nil + } + return HttpDo(&http.Request{URL: url,}, time.Second * 10, description) +} + +func HttpDo(request *http.Request, timeout time.Duration, description string) *http.Response { + response, error := ActiveHttpClient.Do(request, timeout) + if error != nil { + Error("Could not connect to", strings.ToLower(description), "at", request.URL.Host) + Detail(error.Error()) + } + return response +} diff --git a/client/go/src/util/http_test.go b/client/go/src/util/http_test.go new file mode 100644 index 00000000000..03b155488d9 --- /dev/null +++ b/client/go/src/util/http_test.go @@ -0,0 +1,46 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Basic testing of our HTTP client wrapper +// Author: bratseth + +package util + +import ( + "bytes" + "github.com/stretchr/testify/assert" + "io/ioutil" + "net/http" + "testing" + "time" +) + +type mockHttpClient struct {} + +func (c mockHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { + var status int + var body string + if request.URL.String() == "http://host/okpath" { + status = 200 + body = "OK body" + } else { + status = 500 + body = "Unexpected url body" + } + + return &http.Response{ + StatusCode: status, + Header: make(http.Header), + Body: ioutil.NopCloser(bytes.NewBufferString(body)), + }, + nil +} + +func TestHttpRequest(t *testing.T) { + ActiveHttpClient = mockHttpClient{} + + response := HttpGet("http://host", "/okpath", "description") + assert.Equal(t, 200, response.StatusCode) + + response = HttpGet("http://host", "/otherpath", "description") + assert.Equal(t, 500, response.StatusCode) +} + diff --git a/client/go/src/util/io.go b/client/go/src/util/io.go new file mode 100644 index 00000000000..217beb085d1 --- /dev/null +++ b/client/go/src/util/io.go @@ -0,0 +1,31 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// File utilities. +// Author: bratseth + +package util + +import ( + "errors" + "io" + "os" + "strings" +) + +// Returns true if the given path exists +func PathExists(path string) bool { + _, err := os.Stat(path) + return ! errors.Is(err, os.ErrNotExist) +} + +// Returns true is the given path points to an existing directory +func IsDirectory(path string) bool { + info, err := os.Stat(path) + return ! errors.Is(err, os.ErrNotExist) && info.IsDir() +} + +// Returns the content of a reader as a string +func ReaderToString(reader io.ReadCloser) string { + buffer := new(strings.Builder) + io.Copy(buffer, reader) + return buffer.String() +} \ No newline at end of file diff --git a/client/go/src/util/print.go b/client/go/src/util/print.go new file mode 100644 index 00000000000..76912094f6e --- /dev/null +++ b/client/go/src/util/print.go @@ -0,0 +1,62 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Print functions for color-coded text. +// Author: bratseth + +package util + +import ( + "bufio" + "fmt" + "io" + "os" +) + +// Set this to have output written somewhere else than os.Stdout +var Out io.Writer + +func init() { + Out = os.Stdout +} + +// Prints in default color +func Print(messages ...string) { + print("", messages) +} + +// Prints in a color appropriate for errors +func Error(messages ...string) { + print("\033[31m", messages) +} + +// Prints in a color appropriate for success messages +func Success(messages ...string) { + print("\033[32m", messages) +} + +// Prints in a color appropriate for detail messages +func Detail(messages ...string) { + print("\033[33m", messages) +} + +// Prints all the text of the given reader +func PrintReader(reader io.ReadCloser) { + // TODO: Pretty-print body + scanner := bufio.NewScanner(reader) + for ;scanner.Scan(); { + Print(scanner.Text()) + } + if err := scanner.Err(); err != nil { + Error(err.Error()) + } +} + +func print(prefix string, messages []string) { + fmt.Fprint(Out, prefix) + for i := 0; i < len(messages); i++ { + fmt.Fprint(Out, messages[i]) + if (i < len(messages) - 1) { + fmt.Fprint(Out, " ") + } + } + fmt.Fprintln(Out, "") +} diff --git a/client/go/src/utils/http.go b/client/go/src/utils/http.go deleted file mode 100644 index 159ffb8d11a..00000000000 --- a/client/go/src/utils/http.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// A HTTP wrapper which handles some errors and provides a way to replace the HTTP client by a mock. -// Author: bratseth - -package utils - -import ( - "net/http" - "net/url" - "strings" - "time" -) - -// Set this to a mock HttpClient instead to unit test HTTP requests -var ActiveHttpClient = CreateClient(time.Second * 10) - -type HttpClient interface { - Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) -} - -type defaultHttpClient struct { - client *http.Client -} - -func (c *defaultHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { - if c.client.Timeout != timeout { // Create a new client with the right timeout - c.client = &http.Client{Timeout: timeout,} - } - return c.client.Do(request) -} - -func CreateClient(timeout time.Duration) HttpClient { - return &defaultHttpClient{ - client: &http.Client{Timeout: timeout,}, - } -} - -// Convenience function for doing a HTTP GET -func HttpGet(host string, path string, description string) *http.Response { - url, urlError := url.Parse(host + path) - if urlError != nil { - Error("Invalid target url '" + host + path + "'") - return nil - } - return HttpDo(&http.Request{URL: url,}, time.Second * 10, description) -} - -func HttpDo(request *http.Request, timeout time.Duration, description string) *http.Response { - response, error := ActiveHttpClient.Do(request, timeout) - if error != nil { - Error("Could not connect to", strings.ToLower(description), "at", request.URL.Host) - Detail(error.Error()) - } - return response -} diff --git a/client/go/src/utils/http_test.go b/client/go/src/utils/http_test.go deleted file mode 100644 index 0383f5c9257..00000000000 --- a/client/go/src/utils/http_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Basic testing of our HTTP client wrapper -// Author: bratseth - -package utils - -import ( - "bytes" - "github.com/stretchr/testify/assert" - "io/ioutil" - "net/http" - "testing" - "time" -) - -type mockHttpClient struct {} - -func (c mockHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { - var status int - var body string - if request.URL.String() == "http://host/okpath" { - status = 200 - body = "OK body" - } else { - status = 500 - body = "Unexpected url body" - } - - return &http.Response{ - StatusCode: status, - Header: make(http.Header), - Body: ioutil.NopCloser(bytes.NewBufferString(body)), - }, - nil -} - -func TestHttpRequest(t *testing.T) { - ActiveHttpClient = mockHttpClient{} - - response := HttpGet("http://host", "/okpath", "description") - assert.Equal(t, 200, response.StatusCode) - - response = HttpGet("http://host", "/otherpath", "description") - assert.Equal(t, 500, response.StatusCode) -} - diff --git a/client/go/src/utils/io.go b/client/go/src/utils/io.go deleted file mode 100644 index 5ea4fbf7fa6..00000000000 --- a/client/go/src/utils/io.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// File utilities. -// Author: bratseth - -package utils - -import ( - "errors" - "io" - "os" - "strings" -) - -// Returns true if the given path exists -func PathExists(path string) bool { - _, err := os.Stat(path) - return ! errors.Is(err, os.ErrNotExist) -} - -// Returns true is the given path points to an existing directory -func IsDirectory(path string) bool { - info, err := os.Stat(path) - return ! errors.Is(err, os.ErrNotExist) && info.IsDir() -} - -// Returns the content of a reader as a string -func ReaderToString(reader io.ReadCloser) string { - buffer := new(strings.Builder) - io.Copy(buffer, reader) - return buffer.String() -} \ No newline at end of file diff --git a/client/go/src/utils/print.go b/client/go/src/utils/print.go deleted file mode 100644 index f3a57c4ba2f..00000000000 --- a/client/go/src/utils/print.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Print functions for color-coded text. -// Author: bratseth - -package utils - -import ( - "bufio" - "fmt" - "io" - "os" -) - -// Set this to have output written somewhere else than os.Stdout -var Out io.Writer - -func init() { - Out = os.Stdout -} - -// Prints in default color -func Print(messages ...string) { - print("", messages) -} - -// Prints in a color appropriate for errors -func Error(messages ...string) { - print("\033[31m", messages) -} - -// Prints in a color appropriate for success messages -func Success(messages ...string) { - print("\033[32m", messages) -} - -// Prints in a color appropriate for detail messages -func Detail(messages ...string) { - print("\033[33m", messages) -} - -// Prints all the text of the given reader -func PrintReader(reader io.ReadCloser) { - // TODO: Pretty-print body - scanner := bufio.NewScanner(reader) - for ;scanner.Scan(); { - Print(scanner.Text()) - } - if err := scanner.Err(); err != nil { - Error(err.Error()) - } -} - -func print(prefix string, messages []string) { - fmt.Fprint(Out, prefix) - for i := 0; i < len(messages); i++ { - fmt.Fprint(Out, messages[i]) - if (i < len(messages) - 1) { - fmt.Fprint(Out, " ") - } - } - fmt.Fprintln(Out, "") -} -- cgit v1.2.3 From 4478aeeb245a208c8e4a4c4c9d217136de03f609 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Aug 2021 09:50:31 +0200 Subject: Move modules to root --- client/go/build.sh | 13 +- client/go/cmd/command_tester.go | 57 ++++ client/go/cmd/config.go | 63 +++++ client/go/cmd/deploy.go | 191 +++++++++++++ client/go/cmd/deploy_test.go | 78 ++++++ client/go/cmd/document.go | 96 +++++++ client/go/cmd/document_test.go | 57 ++++ client/go/cmd/init.go | 157 +++++++++++ client/go/cmd/init_test.go | 32 +++ client/go/cmd/query.go | 70 +++++ client/go/cmd/query_test.go | 63 +++++ client/go/cmd/root.go | 34 +++ client/go/cmd/status.go | 59 ++++ client/go/cmd/status_test.go | 70 +++++ client/go/cmd/target.go | 60 +++++ client/go/cmd/testdata/A-Head-Full-of-Dreams.json | 14 + client/go/cmd/testdata/application.zip | Bin 0 -> 2305 bytes client/go/cmd/testdata/sample-apps-master.zip | Bin 0 -> 4253469 bytes .../go/cmd/testdata/src/main/application/hosts.xml | 8 + .../src/main/application/schemas/msmarco.sd | 299 +++++++++++++++++++++ .../cmd/testdata/src/main/application/services.xml | 61 +++++ client/go/src/cmd/command_tester.go | 57 ---- client/go/src/cmd/config.go | 63 ----- client/go/src/cmd/deploy.go | 191 ------------- client/go/src/cmd/deploy_test.go | 78 ------ client/go/src/cmd/document.go | 96 ------- client/go/src/cmd/document_test.go | 57 ---- client/go/src/cmd/init.go | 157 ----------- client/go/src/cmd/init_test.go | 32 --- client/go/src/cmd/query.go | 70 ----- client/go/src/cmd/query_test.go | 63 ----- client/go/src/cmd/root.go | 34 --- client/go/src/cmd/status.go | 59 ---- client/go/src/cmd/status_test.go | 70 ----- client/go/src/cmd/target.go | 60 ----- .../go/src/cmd/testdata/A-Head-Full-of-Dreams.json | 14 - client/go/src/cmd/testdata/application.zip | Bin 2305 -> 0 bytes client/go/src/cmd/testdata/sample-apps-master.zip | Bin 4253469 -> 0 bytes .../cmd/testdata/src/main/application/hosts.xml | 8 - .../src/main/application/schemas/msmarco.sd | 299 --------------------- .../cmd/testdata/src/main/application/services.xml | 61 ----- client/go/src/go.mod | 9 - client/go/src/main.go | 13 - client/go/src/util/http.go | 55 ---- client/go/src/util/http_test.go | 46 ---- client/go/src/util/io.go | 31 --- client/go/src/util/print.go | 62 ----- client/go/util/http.go | 55 ++++ client/go/util/http_test.go | 46 ++++ client/go/util/io.go | 31 +++ client/go/util/print.go | 62 +++++ 51 files changed, 1673 insertions(+), 1688 deletions(-) create mode 100644 client/go/cmd/command_tester.go create mode 100644 client/go/cmd/config.go create mode 100644 client/go/cmd/deploy.go create mode 100644 client/go/cmd/deploy_test.go create mode 100644 client/go/cmd/document.go create mode 100644 client/go/cmd/document_test.go create mode 100644 client/go/cmd/init.go create mode 100644 client/go/cmd/init_test.go create mode 100644 client/go/cmd/query.go create mode 100644 client/go/cmd/query_test.go create mode 100644 client/go/cmd/root.go create mode 100644 client/go/cmd/status.go create mode 100644 client/go/cmd/status_test.go create mode 100644 client/go/cmd/target.go create mode 100644 client/go/cmd/testdata/A-Head-Full-of-Dreams.json create mode 100644 client/go/cmd/testdata/application.zip create mode 100644 client/go/cmd/testdata/sample-apps-master.zip create mode 100644 client/go/cmd/testdata/src/main/application/hosts.xml create mode 100644 client/go/cmd/testdata/src/main/application/schemas/msmarco.sd create mode 100644 client/go/cmd/testdata/src/main/application/services.xml delete mode 100644 client/go/src/cmd/command_tester.go delete mode 100644 client/go/src/cmd/config.go delete mode 100644 client/go/src/cmd/deploy.go delete mode 100644 client/go/src/cmd/deploy_test.go delete mode 100644 client/go/src/cmd/document.go delete mode 100644 client/go/src/cmd/document_test.go delete mode 100644 client/go/src/cmd/init.go delete mode 100644 client/go/src/cmd/init_test.go delete mode 100644 client/go/src/cmd/query.go delete mode 100644 client/go/src/cmd/query_test.go delete mode 100644 client/go/src/cmd/root.go delete mode 100644 client/go/src/cmd/status.go delete mode 100644 client/go/src/cmd/status_test.go delete mode 100644 client/go/src/cmd/target.go delete mode 100644 client/go/src/cmd/testdata/A-Head-Full-of-Dreams.json delete mode 100644 client/go/src/cmd/testdata/application.zip delete mode 100644 client/go/src/cmd/testdata/sample-apps-master.zip delete mode 100644 client/go/src/cmd/testdata/src/main/application/hosts.xml delete mode 100644 client/go/src/cmd/testdata/src/main/application/schemas/msmarco.sd delete mode 100644 client/go/src/cmd/testdata/src/main/application/services.xml delete mode 100644 client/go/src/go.mod delete mode 100644 client/go/src/main.go delete mode 100644 client/go/src/util/http.go delete mode 100644 client/go/src/util/http_test.go delete mode 100644 client/go/src/util/io.go delete mode 100644 client/go/src/util/print.go create mode 100644 client/go/util/http.go create mode 100644 client/go/util/http_test.go create mode 100644 client/go/util/io.go create mode 100644 client/go/util/print.go diff --git a/client/go/build.sh b/client/go/build.sh index 9edc5df4002..08d8f1d8983 100755 --- a/client/go/build.sh +++ b/client/go/build.sh @@ -1,7 +1,14 @@ # Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. # Execute from this directory to build the command-line client to bin/vespa -export GOPATH=`pwd` -cd "$GOPATH/src/" -go test ./... +cd util +go test +cd .. + +cd cmd +go test +cd .. + +export GOBIN=`pwd`/bin go install + diff --git a/client/go/cmd/command_tester.go b/client/go/cmd/command_tester.go new file mode 100644 index 00000000000..f1d4b52d0bb --- /dev/null +++ b/client/go/cmd/command_tester.go @@ -0,0 +1,57 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// A helper for testing commands +// Author: bratseth + +package cmd + +import ( + "bytes" + "github.com/vespa-engine/vespa/util" + "github.com/stretchr/testify/assert" + "io/ioutil" + "net/http" + "testing" + "strconv" + "time" +) + +func executeCommand(t *testing.T, client *mockHttpClient, args []string, moreArgs []string) (standardout string) { + util.ActiveHttpClient = client + + // Reset - persistent flags in Cobra persists over tests + rootCmd.SetArgs([]string{"status", "-t", ""}) + rootCmd.Execute() + + b := bytes.NewBufferString("") + util.Out = b + rootCmd.SetArgs(append(args, moreArgs...)) + rootCmd.Execute() + out, err := ioutil.ReadAll(b) + assert.Empty(t, err, "No error") + return string(out) +} + +type mockHttpClient struct { + // The HTTP status code that will be returned from the next invocation. Default: 200 + nextStatus int + + // The response body code that will be returned from the next invocation. Default: "" + nextBody string + + // A recording of the last HTTP request made through this + lastRequest *http.Request +} + +func (c *mockHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { + if c.nextStatus == 0 { + c.nextStatus = 200 + } + c.lastRequest = request + return &http.Response{ + Status: "Status " + strconv.Itoa(c.nextStatus), + StatusCode: c.nextStatus, + Body: ioutil.NopCloser(bytes.NewBufferString(c.nextBody)), + Header: make(http.Header), + }, + nil +} diff --git a/client/go/cmd/config.go b/client/go/cmd/config.go new file mode 100644 index 00000000000..2c10eaf8f02 --- /dev/null +++ b/client/go/cmd/config.go @@ -0,0 +1,63 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// vespa config command +// author: bratseth + +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/spf13/viper" + "github.com/vespa-engine/vespa/util" + "os" + "path/filepath" +) + +func init() { + rootCmd.AddCommand(configCmd) +} + +var configCmd = &cobra.Command{ + Use: "config", + Short: "Configure the Vespa command", + Long: `TODO`, + Run: func(cmd *cobra.Command, args []string) { + }, +} + +func readConfig() { + home, err := os.UserHomeDir() + configName := ".vespa" + configType := "yaml" + + cobra.CheckErr(err) + viper.AddConfigPath(home) + viper.SetConfigType(configType) + viper.SetConfigName(configName) + viper.AutomaticEnv() + + viper.ReadInConfig(); +} + +// WIP: Not used yet +func writeConfig() { + //viper.BindPFlag("container-target", rootCmd.PersistentFlags().Lookup("container-target")) + //viper.SetDefault("container-target", "http://127.0.0.1:8080") + + home, _ := os.UserHomeDir() + configName := ".vespa" + configType := "yaml" + + // Viper bug: WriteConfig() will not create the file if missing + configPath := filepath.Join(home, configName + "." + configType) + _, statErr := os.Stat(configPath) + if !os.IsExist(statErr) { + if _, createErr := os.Create(configPath); createErr != nil { + util.Error("Warning: Can not remember flag parameters: " + createErr.Error()) + } + } + + writeErr := viper.WriteConfig() + if writeErr != nil { + util.Error("Could not write config:", writeErr.Error()) + } +} \ No newline at end of file diff --git a/client/go/cmd/deploy.go b/client/go/cmd/deploy.go new file mode 100644 index 00000000000..bfd3837cd5a --- /dev/null +++ b/client/go/cmd/deploy.go @@ -0,0 +1,191 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// vespa deploy command +// Author: bratseth + +package cmd + +import ( + "archive/zip" + "errors" + "github.com/spf13/cobra" + "github.com/vespa-engine/vespa/util" + "io" + "io/ioutil" + "net/http" + "net/url" + "os" + "path/filepath" + "strings" + "time" +) + +func init() { + rootCmd.AddCommand(deployCmd) + deployCmd.AddCommand(deployPrepareCmd) + deployCmd.AddCommand(deployActivateCmd) +} + +var deployCmd = &cobra.Command{ + Use: "deploy", + Short: "Deploys an application package", + Long: `TODO: Use prepare or deploy activate`, + Run: func(cmd *cobra.Command, args []string) { + util.Error("Use either deploy prepare or deploy activate") + }, +} + +var deployPrepareCmd = &cobra.Command{ + Use: "prepare", + Short: "Prepares an application for activation", + Long: `TODO: prepare application-package-dir OR application.zip`, + Args: func(cmd *cobra.Command, args []string) error { + if len(args) > 1 { + return errors.New("Expected an application package as the only argument") + } + return nil + }, + Run: func(cmd *cobra.Command, args []string) { + if len(args) == 0 { + deploy(true, "src/main/application") + } else { + deploy(true, args[0]) + } + }, +} + +var deployActivateCmd = &cobra.Command{ + Use: "activate", + Short: "Activates an application package. If no package argument, the previously prepared package is activated.", + Long: `TODO: activate [application-package-dir OR application.zip]`, + Args: func(cmd *cobra.Command, args []string) error { + if len(args) > 1 { + return errors.New("Expected an application package as the only argument") + } + return nil + }, + Run: func(cmd *cobra.Command, args []string) { + if len(args) == 0 { + deploy(false, "") + } else { + deploy(false, args[0]) + } + }, +} + +func deploy(prepare bool, application string) { + // TODO: Support no application (activate) + // TODO: Support application home as argument instead of src/main and + // - if target exists, use target/application.zip + // - else if src/main/application exists, use that + // - else if current dir has services.xml use that + if filepath.Ext(application) != ".zip" { + tempZip, error := ioutil.TempFile("", "application.zip") + if error != nil { + util.Error("Could not create a temporary zip file for the application package") + util.Detail(error.Error()) + return + } + + error = zipDir(application, tempZip.Name()) + if (error != nil) { + util.Error(error.Error()) + return + } + defer os.Remove(tempZip.Name()) + application = tempZip.Name() + } + + zipFileReader, zipFileError := os.Open(application) + if zipFileError != nil { + util.Error("Could not open application package at " + application) + util.Detail(zipFileError.Error()) + return + } + + var deployUrl *url.URL + if prepare { + deployUrl, _ = url.Parse(getTarget(deployContext).deploy + "/application/v2/tenant/default/prepare") + } else if application == "" { + deployUrl, _ = url.Parse(getTarget(deployContext).deploy + "/application/v2/tenant/default/activate") + } else { + deployUrl, _ = url.Parse(getTarget(deployContext).deploy + "/application/v2/tenant/default/prepareandactivate") + } + + header := http.Header{} + header.Add("Content-Type", "application/zip") + request := &http.Request{ + URL: deployUrl, + Method: "POST", + Header: header, + Body: ioutil.NopCloser(zipFileReader), + } + serviceDescription := "Deploy service" + response := util.HttpDo(request, time.Minute * 10, serviceDescription) + if (response == nil) { + return + } + + defer response.Body.Close() + if response.StatusCode == 200 { + util.Success("Success") + } else if response.StatusCode / 100 == 4 { + util.Error("Invalid application package", "(" + response.Status + "):") + util.PrintReader(response.Body) + } else { + util.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") + util.PrintReader(response.Body) + } +} + +func zipDir(dir string, destination string) error { + if filepath.IsAbs(dir) { + message := "Path must be relative, but '" + dir + "'" + return errors.New(message) + } + if ! util.PathExists(dir) { + message := "'" + dir + "' should be an application package zip or dir, but does not exist" + return errors.New(message) + } + if ! util.IsDirectory(dir) { + message := "'" + dir + "' should be an application package dir, but is a (non-zip) file" + return errors.New(message) + } + + file, err := os.Create(destination) + if err != nil { + message := "Could not create a temporary zip file for the application package: " + err.Error() + return errors.New(message) + } + defer file.Close() + + w := zip.NewWriter(file) + defer w.Close() + + walker := func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if info.IsDir() { + return nil + } + file, err := os.Open(path) + if err != nil { + return err + } + defer file.Close() + + zippath := strings.TrimPrefix(path, dir) + zipfile, err := w.Create(zippath) + if err != nil { + return err + } + + _, err = io.Copy(zipfile, file) + if err != nil { + return err + } + return nil + } + return filepath.Walk(dir, walker) +} + diff --git a/client/go/cmd/deploy_test.go b/client/go/cmd/deploy_test.go new file mode 100644 index 00000000000..64ede50546c --- /dev/null +++ b/client/go/cmd/deploy_test.go @@ -0,0 +1,78 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// deploy command tests +// Author: bratseth + +package cmd + +import ( + "github.com/stretchr/testify/assert" + "strconv" + "testing" +) + +func TestDeployZip(t *testing.T) { + client := &mockHttpClient{} + assert.Equal(t, + "\x1b[32mSuccess\n", + executeCommand(t, client, []string{"deploy", "activate", "testdata/application.zip"}, []string{})) + assertDeployRequestMade("http://127.0.0.1:19071", client, t) +} + +func TestDeployZipWithURLTargetArgument(t *testing.T) { + client := &mockHttpClient{} + assert.Equal(t, + "\x1b[32mSuccess\n", + executeCommand(t, client, []string{"deploy", "activate", "testdata/application.zip", "-t", "http://target:19071"}, []string{})) + assertDeployRequestMade("http://target:19071", client, t) +} + +func TestDeployZipWitLocalTargetArgument(t *testing.T) { + client := &mockHttpClient{} + assert.Equal(t, + "\x1b[32mSuccess\n", + executeCommand(t, client, []string{"deploy", "activate", "testdata/application.zip", "-t", "local"}, []string{})) + assertDeployRequestMade("http://127.0.0.1:19071", client, t) +} + +func TestDeployDirectory(t *testing.T) { + client := &mockHttpClient{} + assert.Equal(t, + "\x1b[32mSuccess\n", + executeCommand(t, client, []string{"deploy", "activate", "testdata/src/main/application"}, []string{})) + assertDeployRequestMade("http://127.0.0.1:19071", client, t) +} + +func TestDeployApplicationPackageError(t *testing.T) { + assertApplicationPackageError(t, 401, "Application package error") +} + +func TestDeployError(t *testing.T) { + assertDeployServerError(t, 501, "Deploy service error") +} + +// TODO: Test prepare and activate prepared + +func assertDeployRequestMade(target string, client *mockHttpClient, t *testing.T) { + assert.Equal(t, target + "/application/v2/tenant/default/prepareandactivate", client.lastRequest.URL.String()) + assert.Equal(t, "application/zip", client.lastRequest.Header.Get("Content-Type")) + assert.Equal(t, "POST", client.lastRequest.Method) + var body = client.lastRequest.Body + assert.NotNil(t, body) + buf := make([]byte, 7) // Just check the first few bytes + body.Read(buf) + assert.Equal(t, "PK\x03\x04\x14\x00\b", string(buf)) +} + +func assertApplicationPackageError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mInvalid application package (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"deploy", "activate", "testdata/src/main/application"}, []string{})) +} + +func assertDeployServerError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mError from deploy service at 127.0.0.1:19071 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"deploy", "activate", "testdata/src/main/application"}, []string{})) +} diff --git a/client/go/cmd/document.go b/client/go/cmd/document.go new file mode 100644 index 00000000000..f48a3965d01 --- /dev/null +++ b/client/go/cmd/document.go @@ -0,0 +1,96 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// vespa document command +// author: bratseth + +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/vespa-engine/vespa/util" + "io/ioutil" + "net/http" + "net/url" + "os" + "strings" + "time" +) + +func init() { + rootCmd.AddCommand(documentCmd) + statusCmd.AddCommand(documentPutCmd) + statusCmd.AddCommand(documentGetCmd) +} + +var documentCmd = &cobra.Command{ + Use: "document", + Short: "Issue document operations (put by default)", + Long: `TODO: Example mynamespace/mydocumenttype/myid document.json`, + // TODO: Check args + Run: func(cmd *cobra.Command, args []string) { + put(args[0], args[1]) + }, +} + +var documentPutCmd = &cobra.Command{ + Use: "put mynamespace/mydocumenttype/myid mydocument.json", + Short: "Puts the document in the given file", + Long: `TODO`, + // TODO: This crashes with the above + // TODO: Extract document id from the content + // TODO: Check args + Run: func(cmd *cobra.Command, args []string) { + put(args[0], args[1]) + }, +} + +var documentGetCmd = &cobra.Command{ + Use: "get documentId", + Short: "Gets a document", + Long: `TODO`, + // TODO: Check args + Run: func(cmd *cobra.Command, args []string) { + get(args[0]) + }, +} + +func get(documentId string) { + // TODO +} + +func put(documentId string, jsonFile string) { + // TODO: Support document id in JSON, see https://docs.vespa.ai/en/reference/document-json-format.html + url, _ := url.Parse(getTarget(documentContext).document + "/document/v1/" + documentId) + + header := http.Header{} + header.Add("Content-Type", "application/json") + + fileReader, fileError := os.Open(jsonFile) + if fileError != nil { + util.Error("Could not open file at " + jsonFile) + util.Detail(fileError.Error()) + return + } + + request := &http.Request{ + URL: url, + Method: "POST", + Header: header, + Body: ioutil.NopCloser(fileReader), + } + serviceDescription := "Container (document API)" + response := util.HttpDo(request, time.Second * 60, serviceDescription) + if (response == nil) { + return + } + + defer response.Body.Close() + if response.StatusCode == 200 { + util.Success("Success") // TODO: Change to something including document id + } else if response.StatusCode / 100 == 4 { + util.Error("Invalid document (" + response.Status + "):") + util.PrintReader(response.Body) + } else { + util.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") + util.PrintReader(response.Body) + } +} \ No newline at end of file diff --git a/client/go/cmd/document_test.go b/client/go/cmd/document_test.go new file mode 100644 index 00000000000..9d0ae6e505e --- /dev/null +++ b/client/go/cmd/document_test.go @@ -0,0 +1,57 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// document command tests +// Author: bratseth + +package cmd + +import ( + "github.com/stretchr/testify/assert" + "github.com/vespa-engine/vespa/util" + "io/ioutil" + "strconv" + "testing" +) + +func TestDocumentPut(t *testing.T) { + assertDocumentPut("mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json", t) +} + +func TestDocumentPutDocumentError(t *testing.T) { + assertDocumentError(t, 401, "Document error") +} + +func TestDocumentPutServerError(t *testing.T) { + assertDocumentServerError(t, 501, "Server error") +} + +func assertDocumentPut(documentId string, jsonFile string, t *testing.T) { + client := &mockHttpClient{} + assert.Equal(t, + "\x1b[32mSuccess\n", + executeCommand(t, client, []string{"document", documentId, jsonFile}, []string{})) + target := getTarget(documentContext).document + assert.Equal(t, target + "/document/v1/" + documentId, client.lastRequest.URL.String()) + assert.Equal(t, "application/json", client.lastRequest.Header.Get("Content-Type")) + assert.Equal(t, "POST", client.lastRequest.Method) + + fileContent, _ := ioutil.ReadFile(jsonFile) + assert.Equal(t, string(fileContent), util.ReaderToString(client.lastRequest.Body)) +} + +func assertDocumentError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mInvalid document (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"document", + "mynamespace/music/docid/1", + "testdata/A-Head-Full-of-Dreams.json"}, []string{})) +} + +func assertDocumentServerError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mError from container (document api) at 127.0.0.1:8080 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"document", + "mynamespace/music/docid/1", + "testdata/A-Head-Full-of-Dreams.json"}, []string{})) +} \ No newline at end of file diff --git a/client/go/cmd/init.go b/client/go/cmd/init.go new file mode 100644 index 00000000000..64e8b342309 --- /dev/null +++ b/client/go/cmd/init.go @@ -0,0 +1,157 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// vespa init command +// author: bratseth + +package cmd + +import ( + "archive/zip" + "errors" + "path/filepath" + "github.com/spf13/cobra" + "github.com/vespa-engine/vespa/util" + "io" + "io/ioutil" + "net/http" + "net/url" + "os" + "strings" + "time" +) + +// Set this to test without downloading this file from github +var existingSampleAppsZip string + +func init() { + existingSampleAppsZip = "" + rootCmd.AddCommand(initCmd) +} + +var initCmd = &cobra.Command{ + // TODO: "application" and "list" subcommands? + Use: "init", + Short: "Creates the files and directory structure for a new Vespa application", + Long: `TODO: vespa init applicationName source`, + Args: func(cmd *cobra.Command, args []string) error { + if len(args) != 2 { + return errors.New("vespa init requires a project name and source") + } + return nil + }, + Run: func(cmd *cobra.Command, args []string) { + initApplication(args[0], args[1]) + }, +} + +func initApplication(name string, source string) { + zipFile := getSampleAppsZip() + if zipFile == nil { + return + } + if existingSampleAppsZip == "" { // Indicates we created a temp file now + defer os.Remove(zipFile.Name()) + } + + createErr := os.Mkdir(name, 0755) + if createErr != nil { + util.Error("Could not create directory '" + name + "'") + util.Detail(createErr.Error()) + return + } + + zipReader, zipOpenError := zip.OpenReader(zipFile.Name()) + if zipOpenError != nil { + util.Error("Could not open sample apps zip '" + zipFile.Name() + "'") + util.Detail(zipOpenError.Error()) + } + defer zipReader.Close() + + found := false + for _, f := range zipReader.File { + zipEntryPrefix := "sample-apps-master/" + source + "/" + if strings.HasPrefix(f.Name, zipEntryPrefix) { + found = true + copyError := copy(f, name, zipEntryPrefix) + if copyError != nil { + util.Error("Could not copy zip entry '" + f.Name + "' to " + name) + util.Detail(copyError.Error()) + return + } + } + } + if !found { + util.Error("Could not find source application '" + source + "'") + } else { + util.Success("Created " + name) + } +} + +func getSampleAppsZip() *os.File { + if existingSampleAppsZip != "" { + existing, openExistingError := os.Open(existingSampleAppsZip) + if openExistingError != nil { + util.Error("Could not open existing sample apps zip file '" + existingSampleAppsZip + "'") + util.Detail(openExistingError.Error()) + } + return existing + } + + // TODO: Cache it? + util.Detail("Downloading sample apps ...") // TODO: Spawn thread to indicate progress + zipUrl, _ := url.Parse("https://github.com/vespa-engine/sample-apps/archive/refs/heads/master.zip") + request := &http.Request{ + URL: zipUrl, + Method: "GET", + } + response := util.HttpDo(request, time.Minute * 60, "GitHub") + defer response.Body.Close() + if response.StatusCode != 200 { + util.Error("Could not download sample apps from github") + util.Detail(response.Status) + return nil + } + + destination, tempFileError := ioutil.TempFile("", "prefix") + if tempFileError != nil { + util.Error("Could not create a temp file to hold sample apps") + util.Detail(tempFileError.Error()) + } + // destination, _ := os.Create("./" + name + "/sample-apps.zip") + // defer destination.Close() + _, err := io.Copy(destination, response.Body) + if err != nil { + util.Error("Could not download sample apps from GitHub") + util.Detail(err.Error()) + return nil + } + return destination +} + +func copy(f *zip.File, destinationDir string, zipEntryPrefix string) error { + destinationPath := filepath.Join(destinationDir, filepath.FromSlash(strings.TrimPrefix(f.Name, zipEntryPrefix))) + if strings.HasSuffix(f.Name, "/") { + if f.Name != zipEntryPrefix { // root is already created + createError := os.Mkdir(destinationPath, 0755) + if createError != nil { + return createError + } + } + } else { + zipEntry, zipEntryOpenError := f.Open() + if zipEntryOpenError != nil { + return zipEntryOpenError + } + defer zipEntry.Close() + + destination, createError := os.Create(destinationPath) + if createError != nil { + return createError + } + + _, copyError := io.Copy(destination, zipEntry) + if copyError != nil { + return copyError + } + } + return nil +} diff --git a/client/go/cmd/init_test.go b/client/go/cmd/init_test.go new file mode 100644 index 00000000000..3cb526ad0f1 --- /dev/null +++ b/client/go/cmd/init_test.go @@ -0,0 +1,32 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// init command tests +// Author: bratseth + +package cmd + +import ( + "github.com/vespa-engine/vespa/util" + "github.com/stretchr/testify/assert" + "os" + "testing" + "path/filepath" +) + +func TestInit(t *testing.T) { + assertCreated("mytestapp", "album-recommendation-selfhosted", t) +} + +func assertCreated(app string, sampleAppName string, t *testing.T) { + existingSampleAppsZip = "testdata/sample-apps-master.zip" + standardOut := executeCommand(t, &mockHttpClient{}, []string{"init", app, sampleAppName}, []string{}) + defer os.RemoveAll(app) + assert.Equal(t, "\x1b[32mCreated " + app + "\n", standardOut) + assert.True(t, util.PathExists(filepath.Join(app, "README.md"))) + assert.True(t, util.PathExists(filepath.Join(app, "src", "main", "application"))) + assert.True(t, util.IsDirectory(filepath.Join(app, "src", "main", "application"))) + + servicesStat, _ := os.Stat(filepath.Join(app, "src", "main", "application", "services.xml")) + var servicesSize int64 + servicesSize = 2474 + assert.Equal(t, servicesSize, servicesStat.Size()) +} diff --git a/client/go/cmd/query.go b/client/go/cmd/query.go new file mode 100644 index 00000000000..58828dbb7cf --- /dev/null +++ b/client/go/cmd/query.go @@ -0,0 +1,70 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// vespa query command +// author: bratseth + +package cmd + +import ( + "errors" + "github.com/spf13/cobra" + "github.com/vespa-engine/vespa/util" + "strings" + "net/http" + "net/url" + "time" +) + +func init() { + rootCmd.AddCommand(queryCmd) +} + +var queryCmd = &cobra.Command{ + Use: "query", + Short: "Issue a query to Vespa", + Long: `TODO, example \"yql=select from sources * where title contains 'foo'\" hits=5`, + // TODO: Support referencing a query json file + Args: func(cmd *cobra.Command, args []string) error { + if len(args) < 1 { + return errors.New("vespa query requires at least one argument containing the query string") + } + return nil + }, + Run: func(cmd *cobra.Command, args []string) { + query(args) + }, +} + +func query(arguments []string) { + url, _ := url.Parse(getTarget(queryContext).query + "/search/") + urlQuery := url.Query() + for i := 0; i < len(arguments); i++ { + key, value := splitArg(arguments[i]) + urlQuery.Set(key, value) + } + url.RawQuery = urlQuery.Encode() + + response := util.HttpDo(&http.Request{URL: url,}, time.Second * 10, "Container") + if (response == nil) { + return + } + defer response.Body.Close() + + if (response.StatusCode == 200) { + util.PrintReader(response.Body) + } else if response.StatusCode / 100 == 4 { + util.Error("Invalid query (" + response.Status + "):") + util.PrintReader(response.Body) + } else { + util.Error("Error from container at", url.Host, "(" + response.Status + "):") + util.PrintReader(response.Body) + } +} + +func splitArg(argument string) (string, string) { + equalsIndex := strings.Index(argument, "=") + if equalsIndex < 1 { + return "yql", argument + } else { + return argument[0:equalsIndex], argument[equalsIndex + 1:len(argument)] + } +} diff --git a/client/go/cmd/query_test.go b/client/go/cmd/query_test.go new file mode 100644 index 00000000000..ab48c482a7d --- /dev/null +++ b/client/go/cmd/query_test.go @@ -0,0 +1,63 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// query command tests +// Author: bratseth + +package cmd + +import ( + "github.com/stretchr/testify/assert" + "strconv" + "testing" +) + +func TestQuery(t *testing.T) { + assertQuery(t, + "?yql=select+from+sources+%2A+where+title+contains+%27foo%27", + "select from sources * where title contains 'foo'") +} + +func TestQueryWithMultipleParameters(t *testing.T) { + assertQuery(t, + "?hits=5&yql=select+from+sources+%2A+where+title+contains+%27foo%27", + "select from sources * where title contains 'foo'", "hits=5") +} + +func TestQueryWithExplicitYqlParameter(t *testing.T) { + assertQuery(t, + "?yql=select+from+sources+%2A+where+title+contains+%27foo%27", + "yql=select from sources * where title contains 'foo'") +} + +func TestIllegalQuery(t *testing.T) { + assertQueryError(t, 401, "query error message") +} + +func TestServerError(t *testing.T) { + assertQueryServiceError(t, 501, "server error message") +} + +func assertQuery(t *testing.T, expectedQuery string, query ...string) { + client := &mockHttpClient{ nextBody: "query result", } + assert.Equal(t, + "query result\n", + executeCommand(t, client, []string{"query"}, query), + "query output") + assert.Equal(t, getTarget(queryContext).query + "/search/" + expectedQuery, client.lastRequest.URL.String()) +} + +func assertQueryError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mInvalid query (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"query"}, []string{"yql=select from sources * where title contains 'foo'"}), + "error output") +} + +func assertQueryServiceError(t *testing.T, status int, errorMessage string) { + client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } + assert.Equal(t, + "\x1b[31mError from container at 127.0.0.1:8080 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", + executeCommand(t, client, []string{"query"}, []string{"yql=select from sources * where title contains 'foo'"}), + "error output") +} + diff --git a/client/go/cmd/root.go b/client/go/cmd/root.go new file mode 100644 index 00000000000..8f33cb47c43 --- /dev/null +++ b/client/go/cmd/root.go @@ -0,0 +1,34 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Root Cobra command: vespa +// author: bratseth + +package cmd + +import ( + "github.com/spf13/cobra" +) + +var ( + // flags + // TODO: add timeout flag + // TODO: add flag to show http request made + targetArgument string + + rootCmd = &cobra.Command{ + Use: "vespa", + Short: "A command-line tool for working with Vespa instances", + Long: `TO +DO`, + } +) + +func init() { + cobra.OnInitialize(readConfig) + rootCmd.PersistentFlags().StringVarP(&targetArgument, "target", "t", "local", "The name or URL of the recipient of this command") +} + +// Execute executes the root command. +func Execute() error { + err := rootCmd.Execute() + return err +} diff --git a/client/go/cmd/status.go b/client/go/cmd/status.go new file mode 100644 index 00000000000..a011678be09 --- /dev/null +++ b/client/go/cmd/status.go @@ -0,0 +1,59 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// vespa status command +// author: bratseth + +package cmd + +import ( + "github.com/spf13/cobra" + "github.com/vespa-engine/vespa/util" +) + +func init() { + rootCmd.AddCommand(statusCmd) + statusCmd.AddCommand(statusContainerCmd) + statusCmd.AddCommand(statusConfigServerCmd) +} + +var statusCmd = &cobra.Command{ + Use: "status", + Short: "Verifies that a vespa target is ready to use (container by default)", + Long: `TODO`, + Run: func(cmd *cobra.Command, args []string) { + status(getTarget(queryContext).query, "Container") + }, +} + +var statusContainerCmd = &cobra.Command{ + Use: "container", + Short: "Verifies that your Vespa container endpoint is ready [Default]", + Long: `TODO`, + Run: func(cmd *cobra.Command, args []string) { + status(getTarget(queryContext).query, "Container") + }, +} + +var statusConfigServerCmd = &cobra.Command{ + Use: "config-server", + Short: "Verifies that your Vespa config server endpoint is ready", + Long: `TODO`, + Run: func(cmd *cobra.Command, args []string) { + status(getTarget(deployContext).deploy, "Config server") + }, +} + +func status(target string, description string) { + path := "/ApplicationStatus" + response := util.HttpGet(target, path, description) + if (response == nil) { + return + } + defer response.Body.Close() + + if response.StatusCode != 200 { + util.Error(description, "at", target, "is not ready") + util.Detail(response.Status) + } else { + util.Success(description, "at", target, "is ready") + } +} diff --git a/client/go/cmd/status_test.go b/client/go/cmd/status_test.go new file mode 100644 index 00000000000..0910a6007b9 --- /dev/null +++ b/client/go/cmd/status_test.go @@ -0,0 +1,70 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// status command tests +// Author: bratseth + +package cmd + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestStatusConfigServerCommand(t *testing.T) { + assertConfigServerStatus("http://127.0.0.1:19071", []string{}, t) +} + +func TestStatusConfigServerCommandWithURLTarget(t *testing.T) { + assertConfigServerStatus("http://mydeploytarget", []string{"-t", "http://mydeploytarget"}, t) +} + +func TestStatusConfigServerCommandWithLocalTarget(t *testing.T) { + assertConfigServerStatus("http://127.0.0.1:19071", []string{"-t", "local"}, t) +} + +func TestStatusContainerCommand(t *testing.T) { + assertContainerStatus("http://127.0.0.1:8080", []string{}, t) +} + +func TestStatusContainerCommandWithUrlTarget(t *testing.T) { + assertContainerStatus("http://mycontainertarget", []string{"-t", "http://mycontainertarget"}, t) +} + +func TestStatusContainerCommandWithLocalTarget(t *testing.T) { + assertContainerStatus("http://127.0.0.1:8080", []string{"-t", "local"}, t) +} + +func TestStatusErrorResponse(t *testing.T) { + assertContainerError("http://127.0.0.1:8080", []string{}, t) +} + +func assertConfigServerStatus(target string, args []string, t *testing.T) { + client := &mockHttpClient{} + assert.Equal(t, + "\x1b[32mConfig server at " + target + " is ready\n", + executeCommand(t, client, []string{"status", "config-server"}, args), + "vespa status config-server") + assert.Equal(t, target + "/ApplicationStatus", client.lastRequest.URL.String()) +} + +func assertContainerStatus(target string, args []string, t *testing.T) { + client := &mockHttpClient{} + assert.Equal(t, + "\x1b[32mContainer at " + target + " is ready\n", + executeCommand(t, client, []string{"status", "container"}, args), + "vespa status container") + assert.Equal(t, target + "/ApplicationStatus", client.lastRequest.URL.String()) + + assert.Equal(t, + "\x1b[32mContainer at " + target + " is ready\n", + executeCommand(t, client, []string{"status"}, args), + "vespa status (the default)") + assert.Equal(t, target + "/ApplicationStatus", client.lastRequest.URL.String()) +} + +func assertContainerError(target string, args []string, t *testing.T) { + client := &mockHttpClient{ nextStatus: 500,} + assert.Equal(t, + "\x1b[31mContainer at " + target + " is not ready\n\x1b[33mStatus 500\n", + executeCommand(t, client, []string{"status", "container"}, args), + "vespa status container") +} \ No newline at end of file diff --git a/client/go/cmd/target.go b/client/go/cmd/target.go new file mode 100644 index 00000000000..4c1ead7f74e --- /dev/null +++ b/client/go/cmd/target.go @@ -0,0 +1,60 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Models a target for Vespa commands +// author: bratseth + +package cmd + +import ( + "github.com/vespa-engine/vespa/util" + "strings" +) + +type target struct { + deploy string + query string + document string +} + +type context int32 +const ( + deployContext context = 0 + queryContext context = 1 + documentContext context = 2 +) + +func getTarget(targetContext context) *target { + if strings.HasPrefix(targetArgument, "http") { + // TODO: Add default ports if missing + switch targetContext { + case deployContext: + return &target{ + deploy: targetArgument, + } + case queryContext: + return &target{ + query: targetArgument, + } + case documentContext: + return &target{ + document: targetArgument, + } + } + } + + // Otherwise, target is a name + + if targetArgument == "" || targetArgument == "local" { + return &target{ + deploy: "http://127.0.0.1:19071", + query: "http://127.0.0.1:8080", + document: "http://127.0.0.1:8080", + } + } + + if targetArgument == "cloud" { + return nil // TODO + } + + util.Error("Unknown target argument '" + targetArgument + ": Use 'local', 'cloud' or an URL") + return nil +} \ No newline at end of file diff --git a/client/go/cmd/testdata/A-Head-Full-of-Dreams.json b/client/go/cmd/testdata/A-Head-Full-of-Dreams.json new file mode 100644 index 00000000000..b68872a961e --- /dev/null +++ b/client/go/cmd/testdata/A-Head-Full-of-Dreams.json @@ -0,0 +1,14 @@ +{ + "fields": { + "album": "A Head Full of Dreams", + "artist": "Coldplay", + "year": 2015, + "category_scores": { + "cells": [ + { "address" : { "cat" : "pop" }, "value": 1 }, + { "address" : { "cat" : "rock" }, "value": 0.2 }, + { "address" : { "cat" : "jazz" }, "value": 0 } + ] + } + } +} diff --git a/client/go/cmd/testdata/application.zip b/client/go/cmd/testdata/application.zip new file mode 100644 index 00000000000..b017db6472d Binary files /dev/null and b/client/go/cmd/testdata/application.zip differ diff --git a/client/go/cmd/testdata/sample-apps-master.zip b/client/go/cmd/testdata/sample-apps-master.zip new file mode 100644 index 00000000000..6ad49361072 Binary files /dev/null and b/client/go/cmd/testdata/sample-apps-master.zip differ diff --git a/client/go/cmd/testdata/src/main/application/hosts.xml b/client/go/cmd/testdata/src/main/application/hosts.xml new file mode 100644 index 00000000000..5dd3ed0dded --- /dev/null +++ b/client/go/cmd/testdata/src/main/application/hosts.xml @@ -0,0 +1,8 @@ + + + + + node1 + + + diff --git a/client/go/cmd/testdata/src/main/application/schemas/msmarco.sd b/client/go/cmd/testdata/src/main/application/schemas/msmarco.sd new file mode 100644 index 00000000000..183e1a6421f --- /dev/null +++ b/client/go/cmd/testdata/src/main/application/schemas/msmarco.sd @@ -0,0 +1,299 @@ +# Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +schema msmarco { + document msmarco { + + field id type string { + indexing: summary | attribute + } + + field title type string { + indexing: index | summary + index: enable-bm25 + stemming: best + } + + field url type string { + indexing: index | summary + } + + field body type string { + indexing: index | summary + index: enable-bm25 + summary: dynamic + stemming: best + } + + field title_word2vec type tensor(x[500]) { + indexing: attribute + } + + field body_word2vec type tensor(x[500]) { + indexing: attribute + } + + field title_gse type tensor(x[512]) { + indexing: attribute + } + + field body_gse type tensor(x[512]) { + indexing: attribute + } + + field title_bert type tensor(x[768]) { + indexing: attribute + } + + field body_bert type tensor(x[768]) { + indexing: attribute + } + + } + + document-summary minimal { + summary id type string {} + } + + fieldset default { + fields: title, body + } + + rank-profile default { + first-phase { + expression: nativeRank(title, body) + } + } + + rank-profile bm25 inherits default { + first-phase { + expression: bm25(title) + bm25(body) + } + } + + rank-profile word2vec_title_body_all inherits default { + function dot_product_title() { + expression: sum(query(tensor)*attribute(title_word2vec)) + } + function dot_product_body() { + expression: sum(query(tensor)*attribute(body_word2vec)) + } + first-phase { + expression: dot_product_title() + dot_product_body() + } + ignore-default-rank-features + rank-features { + rankingExpression(dot_product_title) + rankingExpression(dot_product_body) + } + } + + rank-profile gse_title_body_all inherits default { + function dot_product_title() { + expression: sum(query(tensor_gse)*attribute(title_gse)) + } + function dot_product_body() { + expression: sum(query(tensor_gse)*attribute(body_gse)) + } + first-phase { + expression: dot_product_title() + dot_product_body() + } + ignore-default-rank-features + rank-features { + rankingExpression(dot_product_title) + rankingExpression(dot_product_body) + } + } + + rank-profile bert_title_body_all inherits default { + function dot_product_title() { + expression: sum(query(tensor_bert)*attribute(title_bert)) + } + function dot_product_body() { + expression: sum(query(tensor_bert)*attribute(body_bert)) + } + first-phase { + expression: dot_product_title() + dot_product_body() + } + ignore-default-rank-features + rank-features { + rankingExpression(dot_product_title) + rankingExpression(dot_product_body) + } + } + + rank-profile bm25_word2vec_title_body_all inherits default { + function dot_product_title() { + expression: sum(query(tensor)*attribute(title_word2vec)) + } + function dot_product_body() { + expression: sum(query(tensor)*attribute(body_word2vec)) + } + first-phase { + expression: bm25(title) + bm25(body) + dot_product_title() + dot_product_body() + } + ignore-default-rank-features + rank-features { + bm25(title) + bm25(body) + rankingExpression(dot_product_title) + rankingExpression(dot_product_body) + } + } + + rank-profile bm25_gse_title_body_all inherits default { + function dot_product_title() { + expression: sum(query(tensor_gse)*attribute(title_gse)) + } + function dot_product_body() { + expression: sum(query(tensor_gse)*attribute(body_gse)) + } + first-phase { + expression: bm25(title) + bm25(body) + dot_product_title() + dot_product_body() + } + ignore-default-rank-features + rank-features { + bm25(title) + bm25(body) + rankingExpression(dot_product_title) + rankingExpression(dot_product_body) + } + } + + rank-profile bm25_bert_title_body_all inherits default { + function dot_product_title() { + expression: sum(query(tensor_bert)*attribute(title_bert)) + } + function dot_product_body() { + expression: sum(query(tensor_bert)*attribute(body_bert)) + } + first-phase { + expression: bm25(title) + bm25(body) + dot_product_title() + dot_product_body() + } + ignore-default-rank-features + rank-features { + bm25(title) + bm25(body) + rankingExpression(dot_product_title) + rankingExpression(dot_product_body) + } + } + + rank-profile listwise_bm25_bert_title_body_all inherits default { + function dot_product_title() { + expression: sum(query(tensor_bert)*attribute(title_bert)) + } + function dot_product_body() { + expression: sum(query(tensor_bert)*attribute(body_bert)) + } + first-phase { + expression: 0.9005951 * bm25(title) + 2.2043643 * bm25(body) + 0.13506432 * dot_product_title() + 0.5840874 * dot_product_body() + } + ignore-default-rank-features + rank-features { + bm25(title) + bm25(body) + rankingExpression(dot_product_title) + rankingExpression(dot_product_body) + } + } + + rank-profile listwise_linear_bm25_gse_title_body_and inherits default { + function dot_product_title() { + expression: sum(query(tensor_gse)*attribute(title_gse)) + } + function dot_product_body() { + expression: sum(query(tensor_gse)*attribute(body_gse)) + } + first-phase { + expression: 0.12408562 * bm25(title) + 0.36673144 * bm25(body) + 6.2273498 * dot_product_title() + 5.671119 * dot_product_body() + } + ignore-default-rank-features + rank-features { + bm25(title) + bm25(body) + rankingExpression(dot_product_title) + rankingExpression(dot_product_body) + } + } + + rank-profile listwise_linear_bm25_gse_title_body_or inherits default { + function dot_product_title() { + expression: sum(query(tensor_gse)*attribute(title_gse)) + } + function dot_product_body() { + expression: sum(query(tensor_gse)*attribute(body_gse)) + } + first-phase { + expression: 0.7150663 * bm25(title) + 0.9480147 * bm25(body) + 1.560068 * dot_product_title() + 1.5062317 * dot_product_body() + } + ignore-default-rank-features + rank-features { + bm25(title) + bm25(body) + rankingExpression(dot_product_title) + rankingExpression(dot_product_body) + } + } + + rank-profile pointwise_linear_bm25 inherits default { + first-phase { + expression: 0.22499913 * bm25(title) + 0.07596389 * bm25(body) + } + } + + rank-profile listwise_linear_bm25 inherits default { + first-phase { + expression: 0.13446581 * bm25(title) + 0.5716889 * bm25(body) + } + } + + rank-profile collect_rank_features_embeddings inherits default { + function dot_product_title_word2vec() { + expression: sum(query(tensor)*attribute(title_word2vec)) + } + function dot_product_body_word2vec() { + expression: sum(query(tensor)*attribute(body_word2vec)) + } + function dot_product_title_gse() { + expression: sum(query(tensor_gse)*attribute(title_gse)) + } + function dot_product_body_gse() { + expression: sum(query(tensor_gse)*attribute(body_gse)) + } + function dot_product_title_bert() { + expression: sum(query(tensor_bert)*attribute(title_bert)) + } + function dot_product_body_bert() { + expression: sum(query(tensor_bert)*attribute(body_bert)) + } + first-phase { + expression: random + } + ignore-default-rank-features + rank-features { + bm25(title) + bm25(body) + nativeRank(title) + nativeRank(body) + rankingExpression(dot_product_title_word2vec) + rankingExpression(dot_product_body_word2vec) + rankingExpression(dot_product_title_gse) + rankingExpression(dot_product_body_gse) + rankingExpression(dot_product_title_bert) + rankingExpression(dot_product_body_bert) + } + } + + rank-profile collect_rank_features inherits default { + first-phase { + expression: random + } + ignore-default-rank-features + rank-features { + bm25(title) + bm25(body) + nativeRank(title) + nativeRank(body) + } + } +} diff --git a/client/go/cmd/testdata/src/main/application/services.xml b/client/go/cmd/testdata/src/main/application/services.xml new file mode 100644 index 00000000000..766434798f0 --- /dev/null +++ b/client/go/cmd/testdata/src/main/application/services.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + <strong> + </strong> + + ... + + + + + + + + + + http://*/site/* + http://*/site + + localhost + 8080 + + + + + + + + + + + + + + 2 + 1000 + 500 + 300 + + + 2 + + + + + + + + + + diff --git a/client/go/src/cmd/command_tester.go b/client/go/src/cmd/command_tester.go deleted file mode 100644 index f1d4b52d0bb..00000000000 --- a/client/go/src/cmd/command_tester.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// A helper for testing commands -// Author: bratseth - -package cmd - -import ( - "bytes" - "github.com/vespa-engine/vespa/util" - "github.com/stretchr/testify/assert" - "io/ioutil" - "net/http" - "testing" - "strconv" - "time" -) - -func executeCommand(t *testing.T, client *mockHttpClient, args []string, moreArgs []string) (standardout string) { - util.ActiveHttpClient = client - - // Reset - persistent flags in Cobra persists over tests - rootCmd.SetArgs([]string{"status", "-t", ""}) - rootCmd.Execute() - - b := bytes.NewBufferString("") - util.Out = b - rootCmd.SetArgs(append(args, moreArgs...)) - rootCmd.Execute() - out, err := ioutil.ReadAll(b) - assert.Empty(t, err, "No error") - return string(out) -} - -type mockHttpClient struct { - // The HTTP status code that will be returned from the next invocation. Default: 200 - nextStatus int - - // The response body code that will be returned from the next invocation. Default: "" - nextBody string - - // A recording of the last HTTP request made through this - lastRequest *http.Request -} - -func (c *mockHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { - if c.nextStatus == 0 { - c.nextStatus = 200 - } - c.lastRequest = request - return &http.Response{ - Status: "Status " + strconv.Itoa(c.nextStatus), - StatusCode: c.nextStatus, - Body: ioutil.NopCloser(bytes.NewBufferString(c.nextBody)), - Header: make(http.Header), - }, - nil -} diff --git a/client/go/src/cmd/config.go b/client/go/src/cmd/config.go deleted file mode 100644 index 2c10eaf8f02..00000000000 --- a/client/go/src/cmd/config.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// vespa config command -// author: bratseth - -package cmd - -import ( - "github.com/spf13/cobra" - "github.com/spf13/viper" - "github.com/vespa-engine/vespa/util" - "os" - "path/filepath" -) - -func init() { - rootCmd.AddCommand(configCmd) -} - -var configCmd = &cobra.Command{ - Use: "config", - Short: "Configure the Vespa command", - Long: `TODO`, - Run: func(cmd *cobra.Command, args []string) { - }, -} - -func readConfig() { - home, err := os.UserHomeDir() - configName := ".vespa" - configType := "yaml" - - cobra.CheckErr(err) - viper.AddConfigPath(home) - viper.SetConfigType(configType) - viper.SetConfigName(configName) - viper.AutomaticEnv() - - viper.ReadInConfig(); -} - -// WIP: Not used yet -func writeConfig() { - //viper.BindPFlag("container-target", rootCmd.PersistentFlags().Lookup("container-target")) - //viper.SetDefault("container-target", "http://127.0.0.1:8080") - - home, _ := os.UserHomeDir() - configName := ".vespa" - configType := "yaml" - - // Viper bug: WriteConfig() will not create the file if missing - configPath := filepath.Join(home, configName + "." + configType) - _, statErr := os.Stat(configPath) - if !os.IsExist(statErr) { - if _, createErr := os.Create(configPath); createErr != nil { - util.Error("Warning: Can not remember flag parameters: " + createErr.Error()) - } - } - - writeErr := viper.WriteConfig() - if writeErr != nil { - util.Error("Could not write config:", writeErr.Error()) - } -} \ No newline at end of file diff --git a/client/go/src/cmd/deploy.go b/client/go/src/cmd/deploy.go deleted file mode 100644 index bfd3837cd5a..00000000000 --- a/client/go/src/cmd/deploy.go +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// vespa deploy command -// Author: bratseth - -package cmd - -import ( - "archive/zip" - "errors" - "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/util" - "io" - "io/ioutil" - "net/http" - "net/url" - "os" - "path/filepath" - "strings" - "time" -) - -func init() { - rootCmd.AddCommand(deployCmd) - deployCmd.AddCommand(deployPrepareCmd) - deployCmd.AddCommand(deployActivateCmd) -} - -var deployCmd = &cobra.Command{ - Use: "deploy", - Short: "Deploys an application package", - Long: `TODO: Use prepare or deploy activate`, - Run: func(cmd *cobra.Command, args []string) { - util.Error("Use either deploy prepare or deploy activate") - }, -} - -var deployPrepareCmd = &cobra.Command{ - Use: "prepare", - Short: "Prepares an application for activation", - Long: `TODO: prepare application-package-dir OR application.zip`, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) > 1 { - return errors.New("Expected an application package as the only argument") - } - return nil - }, - Run: func(cmd *cobra.Command, args []string) { - if len(args) == 0 { - deploy(true, "src/main/application") - } else { - deploy(true, args[0]) - } - }, -} - -var deployActivateCmd = &cobra.Command{ - Use: "activate", - Short: "Activates an application package. If no package argument, the previously prepared package is activated.", - Long: `TODO: activate [application-package-dir OR application.zip]`, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) > 1 { - return errors.New("Expected an application package as the only argument") - } - return nil - }, - Run: func(cmd *cobra.Command, args []string) { - if len(args) == 0 { - deploy(false, "") - } else { - deploy(false, args[0]) - } - }, -} - -func deploy(prepare bool, application string) { - // TODO: Support no application (activate) - // TODO: Support application home as argument instead of src/main and - // - if target exists, use target/application.zip - // - else if src/main/application exists, use that - // - else if current dir has services.xml use that - if filepath.Ext(application) != ".zip" { - tempZip, error := ioutil.TempFile("", "application.zip") - if error != nil { - util.Error("Could not create a temporary zip file for the application package") - util.Detail(error.Error()) - return - } - - error = zipDir(application, tempZip.Name()) - if (error != nil) { - util.Error(error.Error()) - return - } - defer os.Remove(tempZip.Name()) - application = tempZip.Name() - } - - zipFileReader, zipFileError := os.Open(application) - if zipFileError != nil { - util.Error("Could not open application package at " + application) - util.Detail(zipFileError.Error()) - return - } - - var deployUrl *url.URL - if prepare { - deployUrl, _ = url.Parse(getTarget(deployContext).deploy + "/application/v2/tenant/default/prepare") - } else if application == "" { - deployUrl, _ = url.Parse(getTarget(deployContext).deploy + "/application/v2/tenant/default/activate") - } else { - deployUrl, _ = url.Parse(getTarget(deployContext).deploy + "/application/v2/tenant/default/prepareandactivate") - } - - header := http.Header{} - header.Add("Content-Type", "application/zip") - request := &http.Request{ - URL: deployUrl, - Method: "POST", - Header: header, - Body: ioutil.NopCloser(zipFileReader), - } - serviceDescription := "Deploy service" - response := util.HttpDo(request, time.Minute * 10, serviceDescription) - if (response == nil) { - return - } - - defer response.Body.Close() - if response.StatusCode == 200 { - util.Success("Success") - } else if response.StatusCode / 100 == 4 { - util.Error("Invalid application package", "(" + response.Status + "):") - util.PrintReader(response.Body) - } else { - util.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") - util.PrintReader(response.Body) - } -} - -func zipDir(dir string, destination string) error { - if filepath.IsAbs(dir) { - message := "Path must be relative, but '" + dir + "'" - return errors.New(message) - } - if ! util.PathExists(dir) { - message := "'" + dir + "' should be an application package zip or dir, but does not exist" - return errors.New(message) - } - if ! util.IsDirectory(dir) { - message := "'" + dir + "' should be an application package dir, but is a (non-zip) file" - return errors.New(message) - } - - file, err := os.Create(destination) - if err != nil { - message := "Could not create a temporary zip file for the application package: " + err.Error() - return errors.New(message) - } - defer file.Close() - - w := zip.NewWriter(file) - defer w.Close() - - walker := func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - if info.IsDir() { - return nil - } - file, err := os.Open(path) - if err != nil { - return err - } - defer file.Close() - - zippath := strings.TrimPrefix(path, dir) - zipfile, err := w.Create(zippath) - if err != nil { - return err - } - - _, err = io.Copy(zipfile, file) - if err != nil { - return err - } - return nil - } - return filepath.Walk(dir, walker) -} - diff --git a/client/go/src/cmd/deploy_test.go b/client/go/src/cmd/deploy_test.go deleted file mode 100644 index 64ede50546c..00000000000 --- a/client/go/src/cmd/deploy_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// deploy command tests -// Author: bratseth - -package cmd - -import ( - "github.com/stretchr/testify/assert" - "strconv" - "testing" -) - -func TestDeployZip(t *testing.T) { - client := &mockHttpClient{} - assert.Equal(t, - "\x1b[32mSuccess\n", - executeCommand(t, client, []string{"deploy", "activate", "testdata/application.zip"}, []string{})) - assertDeployRequestMade("http://127.0.0.1:19071", client, t) -} - -func TestDeployZipWithURLTargetArgument(t *testing.T) { - client := &mockHttpClient{} - assert.Equal(t, - "\x1b[32mSuccess\n", - executeCommand(t, client, []string{"deploy", "activate", "testdata/application.zip", "-t", "http://target:19071"}, []string{})) - assertDeployRequestMade("http://target:19071", client, t) -} - -func TestDeployZipWitLocalTargetArgument(t *testing.T) { - client := &mockHttpClient{} - assert.Equal(t, - "\x1b[32mSuccess\n", - executeCommand(t, client, []string{"deploy", "activate", "testdata/application.zip", "-t", "local"}, []string{})) - assertDeployRequestMade("http://127.0.0.1:19071", client, t) -} - -func TestDeployDirectory(t *testing.T) { - client := &mockHttpClient{} - assert.Equal(t, - "\x1b[32mSuccess\n", - executeCommand(t, client, []string{"deploy", "activate", "testdata/src/main/application"}, []string{})) - assertDeployRequestMade("http://127.0.0.1:19071", client, t) -} - -func TestDeployApplicationPackageError(t *testing.T) { - assertApplicationPackageError(t, 401, "Application package error") -} - -func TestDeployError(t *testing.T) { - assertDeployServerError(t, 501, "Deploy service error") -} - -// TODO: Test prepare and activate prepared - -func assertDeployRequestMade(target string, client *mockHttpClient, t *testing.T) { - assert.Equal(t, target + "/application/v2/tenant/default/prepareandactivate", client.lastRequest.URL.String()) - assert.Equal(t, "application/zip", client.lastRequest.Header.Get("Content-Type")) - assert.Equal(t, "POST", client.lastRequest.Method) - var body = client.lastRequest.Body - assert.NotNil(t, body) - buf := make([]byte, 7) // Just check the first few bytes - body.Read(buf) - assert.Equal(t, "PK\x03\x04\x14\x00\b", string(buf)) -} - -func assertApplicationPackageError(t *testing.T, status int, errorMessage string) { - client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } - assert.Equal(t, - "\x1b[31mInvalid application package (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", - executeCommand(t, client, []string{"deploy", "activate", "testdata/src/main/application"}, []string{})) -} - -func assertDeployServerError(t *testing.T, status int, errorMessage string) { - client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } - assert.Equal(t, - "\x1b[31mError from deploy service at 127.0.0.1:19071 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", - executeCommand(t, client, []string{"deploy", "activate", "testdata/src/main/application"}, []string{})) -} diff --git a/client/go/src/cmd/document.go b/client/go/src/cmd/document.go deleted file mode 100644 index f48a3965d01..00000000000 --- a/client/go/src/cmd/document.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// vespa document command -// author: bratseth - -package cmd - -import ( - "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/util" - "io/ioutil" - "net/http" - "net/url" - "os" - "strings" - "time" -) - -func init() { - rootCmd.AddCommand(documentCmd) - statusCmd.AddCommand(documentPutCmd) - statusCmd.AddCommand(documentGetCmd) -} - -var documentCmd = &cobra.Command{ - Use: "document", - Short: "Issue document operations (put by default)", - Long: `TODO: Example mynamespace/mydocumenttype/myid document.json`, - // TODO: Check args - Run: func(cmd *cobra.Command, args []string) { - put(args[0], args[1]) - }, -} - -var documentPutCmd = &cobra.Command{ - Use: "put mynamespace/mydocumenttype/myid mydocument.json", - Short: "Puts the document in the given file", - Long: `TODO`, - // TODO: This crashes with the above - // TODO: Extract document id from the content - // TODO: Check args - Run: func(cmd *cobra.Command, args []string) { - put(args[0], args[1]) - }, -} - -var documentGetCmd = &cobra.Command{ - Use: "get documentId", - Short: "Gets a document", - Long: `TODO`, - // TODO: Check args - Run: func(cmd *cobra.Command, args []string) { - get(args[0]) - }, -} - -func get(documentId string) { - // TODO -} - -func put(documentId string, jsonFile string) { - // TODO: Support document id in JSON, see https://docs.vespa.ai/en/reference/document-json-format.html - url, _ := url.Parse(getTarget(documentContext).document + "/document/v1/" + documentId) - - header := http.Header{} - header.Add("Content-Type", "application/json") - - fileReader, fileError := os.Open(jsonFile) - if fileError != nil { - util.Error("Could not open file at " + jsonFile) - util.Detail(fileError.Error()) - return - } - - request := &http.Request{ - URL: url, - Method: "POST", - Header: header, - Body: ioutil.NopCloser(fileReader), - } - serviceDescription := "Container (document API)" - response := util.HttpDo(request, time.Second * 60, serviceDescription) - if (response == nil) { - return - } - - defer response.Body.Close() - if response.StatusCode == 200 { - util.Success("Success") // TODO: Change to something including document id - } else if response.StatusCode / 100 == 4 { - util.Error("Invalid document (" + response.Status + "):") - util.PrintReader(response.Body) - } else { - util.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") - util.PrintReader(response.Body) - } -} \ No newline at end of file diff --git a/client/go/src/cmd/document_test.go b/client/go/src/cmd/document_test.go deleted file mode 100644 index 9d0ae6e505e..00000000000 --- a/client/go/src/cmd/document_test.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// document command tests -// Author: bratseth - -package cmd - -import ( - "github.com/stretchr/testify/assert" - "github.com/vespa-engine/vespa/util" - "io/ioutil" - "strconv" - "testing" -) - -func TestDocumentPut(t *testing.T) { - assertDocumentPut("mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json", t) -} - -func TestDocumentPutDocumentError(t *testing.T) { - assertDocumentError(t, 401, "Document error") -} - -func TestDocumentPutServerError(t *testing.T) { - assertDocumentServerError(t, 501, "Server error") -} - -func assertDocumentPut(documentId string, jsonFile string, t *testing.T) { - client := &mockHttpClient{} - assert.Equal(t, - "\x1b[32mSuccess\n", - executeCommand(t, client, []string{"document", documentId, jsonFile}, []string{})) - target := getTarget(documentContext).document - assert.Equal(t, target + "/document/v1/" + documentId, client.lastRequest.URL.String()) - assert.Equal(t, "application/json", client.lastRequest.Header.Get("Content-Type")) - assert.Equal(t, "POST", client.lastRequest.Method) - - fileContent, _ := ioutil.ReadFile(jsonFile) - assert.Equal(t, string(fileContent), util.ReaderToString(client.lastRequest.Body)) -} - -func assertDocumentError(t *testing.T, status int, errorMessage string) { - client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } - assert.Equal(t, - "\x1b[31mInvalid document (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", - executeCommand(t, client, []string{"document", - "mynamespace/music/docid/1", - "testdata/A-Head-Full-of-Dreams.json"}, []string{})) -} - -func assertDocumentServerError(t *testing.T, status int, errorMessage string) { - client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } - assert.Equal(t, - "\x1b[31mError from container (document api) at 127.0.0.1:8080 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", - executeCommand(t, client, []string{"document", - "mynamespace/music/docid/1", - "testdata/A-Head-Full-of-Dreams.json"}, []string{})) -} \ No newline at end of file diff --git a/client/go/src/cmd/init.go b/client/go/src/cmd/init.go deleted file mode 100644 index 64e8b342309..00000000000 --- a/client/go/src/cmd/init.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// vespa init command -// author: bratseth - -package cmd - -import ( - "archive/zip" - "errors" - "path/filepath" - "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/util" - "io" - "io/ioutil" - "net/http" - "net/url" - "os" - "strings" - "time" -) - -// Set this to test without downloading this file from github -var existingSampleAppsZip string - -func init() { - existingSampleAppsZip = "" - rootCmd.AddCommand(initCmd) -} - -var initCmd = &cobra.Command{ - // TODO: "application" and "list" subcommands? - Use: "init", - Short: "Creates the files and directory structure for a new Vespa application", - Long: `TODO: vespa init applicationName source`, - Args: func(cmd *cobra.Command, args []string) error { - if len(args) != 2 { - return errors.New("vespa init requires a project name and source") - } - return nil - }, - Run: func(cmd *cobra.Command, args []string) { - initApplication(args[0], args[1]) - }, -} - -func initApplication(name string, source string) { - zipFile := getSampleAppsZip() - if zipFile == nil { - return - } - if existingSampleAppsZip == "" { // Indicates we created a temp file now - defer os.Remove(zipFile.Name()) - } - - createErr := os.Mkdir(name, 0755) - if createErr != nil { - util.Error("Could not create directory '" + name + "'") - util.Detail(createErr.Error()) - return - } - - zipReader, zipOpenError := zip.OpenReader(zipFile.Name()) - if zipOpenError != nil { - util.Error("Could not open sample apps zip '" + zipFile.Name() + "'") - util.Detail(zipOpenError.Error()) - } - defer zipReader.Close() - - found := false - for _, f := range zipReader.File { - zipEntryPrefix := "sample-apps-master/" + source + "/" - if strings.HasPrefix(f.Name, zipEntryPrefix) { - found = true - copyError := copy(f, name, zipEntryPrefix) - if copyError != nil { - util.Error("Could not copy zip entry '" + f.Name + "' to " + name) - util.Detail(copyError.Error()) - return - } - } - } - if !found { - util.Error("Could not find source application '" + source + "'") - } else { - util.Success("Created " + name) - } -} - -func getSampleAppsZip() *os.File { - if existingSampleAppsZip != "" { - existing, openExistingError := os.Open(existingSampleAppsZip) - if openExistingError != nil { - util.Error("Could not open existing sample apps zip file '" + existingSampleAppsZip + "'") - util.Detail(openExistingError.Error()) - } - return existing - } - - // TODO: Cache it? - util.Detail("Downloading sample apps ...") // TODO: Spawn thread to indicate progress - zipUrl, _ := url.Parse("https://github.com/vespa-engine/sample-apps/archive/refs/heads/master.zip") - request := &http.Request{ - URL: zipUrl, - Method: "GET", - } - response := util.HttpDo(request, time.Minute * 60, "GitHub") - defer response.Body.Close() - if response.StatusCode != 200 { - util.Error("Could not download sample apps from github") - util.Detail(response.Status) - return nil - } - - destination, tempFileError := ioutil.TempFile("", "prefix") - if tempFileError != nil { - util.Error("Could not create a temp file to hold sample apps") - util.Detail(tempFileError.Error()) - } - // destination, _ := os.Create("./" + name + "/sample-apps.zip") - // defer destination.Close() - _, err := io.Copy(destination, response.Body) - if err != nil { - util.Error("Could not download sample apps from GitHub") - util.Detail(err.Error()) - return nil - } - return destination -} - -func copy(f *zip.File, destinationDir string, zipEntryPrefix string) error { - destinationPath := filepath.Join(destinationDir, filepath.FromSlash(strings.TrimPrefix(f.Name, zipEntryPrefix))) - if strings.HasSuffix(f.Name, "/") { - if f.Name != zipEntryPrefix { // root is already created - createError := os.Mkdir(destinationPath, 0755) - if createError != nil { - return createError - } - } - } else { - zipEntry, zipEntryOpenError := f.Open() - if zipEntryOpenError != nil { - return zipEntryOpenError - } - defer zipEntry.Close() - - destination, createError := os.Create(destinationPath) - if createError != nil { - return createError - } - - _, copyError := io.Copy(destination, zipEntry) - if copyError != nil { - return copyError - } - } - return nil -} diff --git a/client/go/src/cmd/init_test.go b/client/go/src/cmd/init_test.go deleted file mode 100644 index 3cb526ad0f1..00000000000 --- a/client/go/src/cmd/init_test.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// init command tests -// Author: bratseth - -package cmd - -import ( - "github.com/vespa-engine/vespa/util" - "github.com/stretchr/testify/assert" - "os" - "testing" - "path/filepath" -) - -func TestInit(t *testing.T) { - assertCreated("mytestapp", "album-recommendation-selfhosted", t) -} - -func assertCreated(app string, sampleAppName string, t *testing.T) { - existingSampleAppsZip = "testdata/sample-apps-master.zip" - standardOut := executeCommand(t, &mockHttpClient{}, []string{"init", app, sampleAppName}, []string{}) - defer os.RemoveAll(app) - assert.Equal(t, "\x1b[32mCreated " + app + "\n", standardOut) - assert.True(t, util.PathExists(filepath.Join(app, "README.md"))) - assert.True(t, util.PathExists(filepath.Join(app, "src", "main", "application"))) - assert.True(t, util.IsDirectory(filepath.Join(app, "src", "main", "application"))) - - servicesStat, _ := os.Stat(filepath.Join(app, "src", "main", "application", "services.xml")) - var servicesSize int64 - servicesSize = 2474 - assert.Equal(t, servicesSize, servicesStat.Size()) -} diff --git a/client/go/src/cmd/query.go b/client/go/src/cmd/query.go deleted file mode 100644 index 58828dbb7cf..00000000000 --- a/client/go/src/cmd/query.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// vespa query command -// author: bratseth - -package cmd - -import ( - "errors" - "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/util" - "strings" - "net/http" - "net/url" - "time" -) - -func init() { - rootCmd.AddCommand(queryCmd) -} - -var queryCmd = &cobra.Command{ - Use: "query", - Short: "Issue a query to Vespa", - Long: `TODO, example \"yql=select from sources * where title contains 'foo'\" hits=5`, - // TODO: Support referencing a query json file - Args: func(cmd *cobra.Command, args []string) error { - if len(args) < 1 { - return errors.New("vespa query requires at least one argument containing the query string") - } - return nil - }, - Run: func(cmd *cobra.Command, args []string) { - query(args) - }, -} - -func query(arguments []string) { - url, _ := url.Parse(getTarget(queryContext).query + "/search/") - urlQuery := url.Query() - for i := 0; i < len(arguments); i++ { - key, value := splitArg(arguments[i]) - urlQuery.Set(key, value) - } - url.RawQuery = urlQuery.Encode() - - response := util.HttpDo(&http.Request{URL: url,}, time.Second * 10, "Container") - if (response == nil) { - return - } - defer response.Body.Close() - - if (response.StatusCode == 200) { - util.PrintReader(response.Body) - } else if response.StatusCode / 100 == 4 { - util.Error("Invalid query (" + response.Status + "):") - util.PrintReader(response.Body) - } else { - util.Error("Error from container at", url.Host, "(" + response.Status + "):") - util.PrintReader(response.Body) - } -} - -func splitArg(argument string) (string, string) { - equalsIndex := strings.Index(argument, "=") - if equalsIndex < 1 { - return "yql", argument - } else { - return argument[0:equalsIndex], argument[equalsIndex + 1:len(argument)] - } -} diff --git a/client/go/src/cmd/query_test.go b/client/go/src/cmd/query_test.go deleted file mode 100644 index ab48c482a7d..00000000000 --- a/client/go/src/cmd/query_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// query command tests -// Author: bratseth - -package cmd - -import ( - "github.com/stretchr/testify/assert" - "strconv" - "testing" -) - -func TestQuery(t *testing.T) { - assertQuery(t, - "?yql=select+from+sources+%2A+where+title+contains+%27foo%27", - "select from sources * where title contains 'foo'") -} - -func TestQueryWithMultipleParameters(t *testing.T) { - assertQuery(t, - "?hits=5&yql=select+from+sources+%2A+where+title+contains+%27foo%27", - "select from sources * where title contains 'foo'", "hits=5") -} - -func TestQueryWithExplicitYqlParameter(t *testing.T) { - assertQuery(t, - "?yql=select+from+sources+%2A+where+title+contains+%27foo%27", - "yql=select from sources * where title contains 'foo'") -} - -func TestIllegalQuery(t *testing.T) { - assertQueryError(t, 401, "query error message") -} - -func TestServerError(t *testing.T) { - assertQueryServiceError(t, 501, "server error message") -} - -func assertQuery(t *testing.T, expectedQuery string, query ...string) { - client := &mockHttpClient{ nextBody: "query result", } - assert.Equal(t, - "query result\n", - executeCommand(t, client, []string{"query"}, query), - "query output") - assert.Equal(t, getTarget(queryContext).query + "/search/" + expectedQuery, client.lastRequest.URL.String()) -} - -func assertQueryError(t *testing.T, status int, errorMessage string) { - client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } - assert.Equal(t, - "\x1b[31mInvalid query (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", - executeCommand(t, client, []string{"query"}, []string{"yql=select from sources * where title contains 'foo'"}), - "error output") -} - -func assertQueryServiceError(t *testing.T, status int, errorMessage string) { - client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } - assert.Equal(t, - "\x1b[31mError from container at 127.0.0.1:8080 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", - executeCommand(t, client, []string{"query"}, []string{"yql=select from sources * where title contains 'foo'"}), - "error output") -} - diff --git a/client/go/src/cmd/root.go b/client/go/src/cmd/root.go deleted file mode 100644 index 8f33cb47c43..00000000000 --- a/client/go/src/cmd/root.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Root Cobra command: vespa -// author: bratseth - -package cmd - -import ( - "github.com/spf13/cobra" -) - -var ( - // flags - // TODO: add timeout flag - // TODO: add flag to show http request made - targetArgument string - - rootCmd = &cobra.Command{ - Use: "vespa", - Short: "A command-line tool for working with Vespa instances", - Long: `TO -DO`, - } -) - -func init() { - cobra.OnInitialize(readConfig) - rootCmd.PersistentFlags().StringVarP(&targetArgument, "target", "t", "local", "The name or URL of the recipient of this command") -} - -// Execute executes the root command. -func Execute() error { - err := rootCmd.Execute() - return err -} diff --git a/client/go/src/cmd/status.go b/client/go/src/cmd/status.go deleted file mode 100644 index a011678be09..00000000000 --- a/client/go/src/cmd/status.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// vespa status command -// author: bratseth - -package cmd - -import ( - "github.com/spf13/cobra" - "github.com/vespa-engine/vespa/util" -) - -func init() { - rootCmd.AddCommand(statusCmd) - statusCmd.AddCommand(statusContainerCmd) - statusCmd.AddCommand(statusConfigServerCmd) -} - -var statusCmd = &cobra.Command{ - Use: "status", - Short: "Verifies that a vespa target is ready to use (container by default)", - Long: `TODO`, - Run: func(cmd *cobra.Command, args []string) { - status(getTarget(queryContext).query, "Container") - }, -} - -var statusContainerCmd = &cobra.Command{ - Use: "container", - Short: "Verifies that your Vespa container endpoint is ready [Default]", - Long: `TODO`, - Run: func(cmd *cobra.Command, args []string) { - status(getTarget(queryContext).query, "Container") - }, -} - -var statusConfigServerCmd = &cobra.Command{ - Use: "config-server", - Short: "Verifies that your Vespa config server endpoint is ready", - Long: `TODO`, - Run: func(cmd *cobra.Command, args []string) { - status(getTarget(deployContext).deploy, "Config server") - }, -} - -func status(target string, description string) { - path := "/ApplicationStatus" - response := util.HttpGet(target, path, description) - if (response == nil) { - return - } - defer response.Body.Close() - - if response.StatusCode != 200 { - util.Error(description, "at", target, "is not ready") - util.Detail(response.Status) - } else { - util.Success(description, "at", target, "is ready") - } -} diff --git a/client/go/src/cmd/status_test.go b/client/go/src/cmd/status_test.go deleted file mode 100644 index 0910a6007b9..00000000000 --- a/client/go/src/cmd/status_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// status command tests -// Author: bratseth - -package cmd - -import ( - "github.com/stretchr/testify/assert" - "testing" -) - -func TestStatusConfigServerCommand(t *testing.T) { - assertConfigServerStatus("http://127.0.0.1:19071", []string{}, t) -} - -func TestStatusConfigServerCommandWithURLTarget(t *testing.T) { - assertConfigServerStatus("http://mydeploytarget", []string{"-t", "http://mydeploytarget"}, t) -} - -func TestStatusConfigServerCommandWithLocalTarget(t *testing.T) { - assertConfigServerStatus("http://127.0.0.1:19071", []string{"-t", "local"}, t) -} - -func TestStatusContainerCommand(t *testing.T) { - assertContainerStatus("http://127.0.0.1:8080", []string{}, t) -} - -func TestStatusContainerCommandWithUrlTarget(t *testing.T) { - assertContainerStatus("http://mycontainertarget", []string{"-t", "http://mycontainertarget"}, t) -} - -func TestStatusContainerCommandWithLocalTarget(t *testing.T) { - assertContainerStatus("http://127.0.0.1:8080", []string{"-t", "local"}, t) -} - -func TestStatusErrorResponse(t *testing.T) { - assertContainerError("http://127.0.0.1:8080", []string{}, t) -} - -func assertConfigServerStatus(target string, args []string, t *testing.T) { - client := &mockHttpClient{} - assert.Equal(t, - "\x1b[32mConfig server at " + target + " is ready\n", - executeCommand(t, client, []string{"status", "config-server"}, args), - "vespa status config-server") - assert.Equal(t, target + "/ApplicationStatus", client.lastRequest.URL.String()) -} - -func assertContainerStatus(target string, args []string, t *testing.T) { - client := &mockHttpClient{} - assert.Equal(t, - "\x1b[32mContainer at " + target + " is ready\n", - executeCommand(t, client, []string{"status", "container"}, args), - "vespa status container") - assert.Equal(t, target + "/ApplicationStatus", client.lastRequest.URL.String()) - - assert.Equal(t, - "\x1b[32mContainer at " + target + " is ready\n", - executeCommand(t, client, []string{"status"}, args), - "vespa status (the default)") - assert.Equal(t, target + "/ApplicationStatus", client.lastRequest.URL.String()) -} - -func assertContainerError(target string, args []string, t *testing.T) { - client := &mockHttpClient{ nextStatus: 500,} - assert.Equal(t, - "\x1b[31mContainer at " + target + " is not ready\n\x1b[33mStatus 500\n", - executeCommand(t, client, []string{"status", "container"}, args), - "vespa status container") -} \ No newline at end of file diff --git a/client/go/src/cmd/target.go b/client/go/src/cmd/target.go deleted file mode 100644 index 4c1ead7f74e..00000000000 --- a/client/go/src/cmd/target.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Models a target for Vespa commands -// author: bratseth - -package cmd - -import ( - "github.com/vespa-engine/vespa/util" - "strings" -) - -type target struct { - deploy string - query string - document string -} - -type context int32 -const ( - deployContext context = 0 - queryContext context = 1 - documentContext context = 2 -) - -func getTarget(targetContext context) *target { - if strings.HasPrefix(targetArgument, "http") { - // TODO: Add default ports if missing - switch targetContext { - case deployContext: - return &target{ - deploy: targetArgument, - } - case queryContext: - return &target{ - query: targetArgument, - } - case documentContext: - return &target{ - document: targetArgument, - } - } - } - - // Otherwise, target is a name - - if targetArgument == "" || targetArgument == "local" { - return &target{ - deploy: "http://127.0.0.1:19071", - query: "http://127.0.0.1:8080", - document: "http://127.0.0.1:8080", - } - } - - if targetArgument == "cloud" { - return nil // TODO - } - - util.Error("Unknown target argument '" + targetArgument + ": Use 'local', 'cloud' or an URL") - return nil -} \ No newline at end of file diff --git a/client/go/src/cmd/testdata/A-Head-Full-of-Dreams.json b/client/go/src/cmd/testdata/A-Head-Full-of-Dreams.json deleted file mode 100644 index b68872a961e..00000000000 --- a/client/go/src/cmd/testdata/A-Head-Full-of-Dreams.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "fields": { - "album": "A Head Full of Dreams", - "artist": "Coldplay", - "year": 2015, - "category_scores": { - "cells": [ - { "address" : { "cat" : "pop" }, "value": 1 }, - { "address" : { "cat" : "rock" }, "value": 0.2 }, - { "address" : { "cat" : "jazz" }, "value": 0 } - ] - } - } -} diff --git a/client/go/src/cmd/testdata/application.zip b/client/go/src/cmd/testdata/application.zip deleted file mode 100644 index b017db6472d..00000000000 Binary files a/client/go/src/cmd/testdata/application.zip and /dev/null differ diff --git a/client/go/src/cmd/testdata/sample-apps-master.zip b/client/go/src/cmd/testdata/sample-apps-master.zip deleted file mode 100644 index 6ad49361072..00000000000 Binary files a/client/go/src/cmd/testdata/sample-apps-master.zip and /dev/null differ diff --git a/client/go/src/cmd/testdata/src/main/application/hosts.xml b/client/go/src/cmd/testdata/src/main/application/hosts.xml deleted file mode 100644 index 5dd3ed0dded..00000000000 --- a/client/go/src/cmd/testdata/src/main/application/hosts.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - node1 - - - diff --git a/client/go/src/cmd/testdata/src/main/application/schemas/msmarco.sd b/client/go/src/cmd/testdata/src/main/application/schemas/msmarco.sd deleted file mode 100644 index 183e1a6421f..00000000000 --- a/client/go/src/cmd/testdata/src/main/application/schemas/msmarco.sd +++ /dev/null @@ -1,299 +0,0 @@ -# Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -schema msmarco { - document msmarco { - - field id type string { - indexing: summary | attribute - } - - field title type string { - indexing: index | summary - index: enable-bm25 - stemming: best - } - - field url type string { - indexing: index | summary - } - - field body type string { - indexing: index | summary - index: enable-bm25 - summary: dynamic - stemming: best - } - - field title_word2vec type tensor(x[500]) { - indexing: attribute - } - - field body_word2vec type tensor(x[500]) { - indexing: attribute - } - - field title_gse type tensor(x[512]) { - indexing: attribute - } - - field body_gse type tensor(x[512]) { - indexing: attribute - } - - field title_bert type tensor(x[768]) { - indexing: attribute - } - - field body_bert type tensor(x[768]) { - indexing: attribute - } - - } - - document-summary minimal { - summary id type string {} - } - - fieldset default { - fields: title, body - } - - rank-profile default { - first-phase { - expression: nativeRank(title, body) - } - } - - rank-profile bm25 inherits default { - first-phase { - expression: bm25(title) + bm25(body) - } - } - - rank-profile word2vec_title_body_all inherits default { - function dot_product_title() { - expression: sum(query(tensor)*attribute(title_word2vec)) - } - function dot_product_body() { - expression: sum(query(tensor)*attribute(body_word2vec)) - } - first-phase { - expression: dot_product_title() + dot_product_body() - } - ignore-default-rank-features - rank-features { - rankingExpression(dot_product_title) - rankingExpression(dot_product_body) - } - } - - rank-profile gse_title_body_all inherits default { - function dot_product_title() { - expression: sum(query(tensor_gse)*attribute(title_gse)) - } - function dot_product_body() { - expression: sum(query(tensor_gse)*attribute(body_gse)) - } - first-phase { - expression: dot_product_title() + dot_product_body() - } - ignore-default-rank-features - rank-features { - rankingExpression(dot_product_title) - rankingExpression(dot_product_body) - } - } - - rank-profile bert_title_body_all inherits default { - function dot_product_title() { - expression: sum(query(tensor_bert)*attribute(title_bert)) - } - function dot_product_body() { - expression: sum(query(tensor_bert)*attribute(body_bert)) - } - first-phase { - expression: dot_product_title() + dot_product_body() - } - ignore-default-rank-features - rank-features { - rankingExpression(dot_product_title) - rankingExpression(dot_product_body) - } - } - - rank-profile bm25_word2vec_title_body_all inherits default { - function dot_product_title() { - expression: sum(query(tensor)*attribute(title_word2vec)) - } - function dot_product_body() { - expression: sum(query(tensor)*attribute(body_word2vec)) - } - first-phase { - expression: bm25(title) + bm25(body) + dot_product_title() + dot_product_body() - } - ignore-default-rank-features - rank-features { - bm25(title) - bm25(body) - rankingExpression(dot_product_title) - rankingExpression(dot_product_body) - } - } - - rank-profile bm25_gse_title_body_all inherits default { - function dot_product_title() { - expression: sum(query(tensor_gse)*attribute(title_gse)) - } - function dot_product_body() { - expression: sum(query(tensor_gse)*attribute(body_gse)) - } - first-phase { - expression: bm25(title) + bm25(body) + dot_product_title() + dot_product_body() - } - ignore-default-rank-features - rank-features { - bm25(title) - bm25(body) - rankingExpression(dot_product_title) - rankingExpression(dot_product_body) - } - } - - rank-profile bm25_bert_title_body_all inherits default { - function dot_product_title() { - expression: sum(query(tensor_bert)*attribute(title_bert)) - } - function dot_product_body() { - expression: sum(query(tensor_bert)*attribute(body_bert)) - } - first-phase { - expression: bm25(title) + bm25(body) + dot_product_title() + dot_product_body() - } - ignore-default-rank-features - rank-features { - bm25(title) - bm25(body) - rankingExpression(dot_product_title) - rankingExpression(dot_product_body) - } - } - - rank-profile listwise_bm25_bert_title_body_all inherits default { - function dot_product_title() { - expression: sum(query(tensor_bert)*attribute(title_bert)) - } - function dot_product_body() { - expression: sum(query(tensor_bert)*attribute(body_bert)) - } - first-phase { - expression: 0.9005951 * bm25(title) + 2.2043643 * bm25(body) + 0.13506432 * dot_product_title() + 0.5840874 * dot_product_body() - } - ignore-default-rank-features - rank-features { - bm25(title) - bm25(body) - rankingExpression(dot_product_title) - rankingExpression(dot_product_body) - } - } - - rank-profile listwise_linear_bm25_gse_title_body_and inherits default { - function dot_product_title() { - expression: sum(query(tensor_gse)*attribute(title_gse)) - } - function dot_product_body() { - expression: sum(query(tensor_gse)*attribute(body_gse)) - } - first-phase { - expression: 0.12408562 * bm25(title) + 0.36673144 * bm25(body) + 6.2273498 * dot_product_title() + 5.671119 * dot_product_body() - } - ignore-default-rank-features - rank-features { - bm25(title) - bm25(body) - rankingExpression(dot_product_title) - rankingExpression(dot_product_body) - } - } - - rank-profile listwise_linear_bm25_gse_title_body_or inherits default { - function dot_product_title() { - expression: sum(query(tensor_gse)*attribute(title_gse)) - } - function dot_product_body() { - expression: sum(query(tensor_gse)*attribute(body_gse)) - } - first-phase { - expression: 0.7150663 * bm25(title) + 0.9480147 * bm25(body) + 1.560068 * dot_product_title() + 1.5062317 * dot_product_body() - } - ignore-default-rank-features - rank-features { - bm25(title) - bm25(body) - rankingExpression(dot_product_title) - rankingExpression(dot_product_body) - } - } - - rank-profile pointwise_linear_bm25 inherits default { - first-phase { - expression: 0.22499913 * bm25(title) + 0.07596389 * bm25(body) - } - } - - rank-profile listwise_linear_bm25 inherits default { - first-phase { - expression: 0.13446581 * bm25(title) + 0.5716889 * bm25(body) - } - } - - rank-profile collect_rank_features_embeddings inherits default { - function dot_product_title_word2vec() { - expression: sum(query(tensor)*attribute(title_word2vec)) - } - function dot_product_body_word2vec() { - expression: sum(query(tensor)*attribute(body_word2vec)) - } - function dot_product_title_gse() { - expression: sum(query(tensor_gse)*attribute(title_gse)) - } - function dot_product_body_gse() { - expression: sum(query(tensor_gse)*attribute(body_gse)) - } - function dot_product_title_bert() { - expression: sum(query(tensor_bert)*attribute(title_bert)) - } - function dot_product_body_bert() { - expression: sum(query(tensor_bert)*attribute(body_bert)) - } - first-phase { - expression: random - } - ignore-default-rank-features - rank-features { - bm25(title) - bm25(body) - nativeRank(title) - nativeRank(body) - rankingExpression(dot_product_title_word2vec) - rankingExpression(dot_product_body_word2vec) - rankingExpression(dot_product_title_gse) - rankingExpression(dot_product_body_gse) - rankingExpression(dot_product_title_bert) - rankingExpression(dot_product_body_bert) - } - } - - rank-profile collect_rank_features inherits default { - first-phase { - expression: random - } - ignore-default-rank-features - rank-features { - bm25(title) - bm25(body) - nativeRank(title) - nativeRank(body) - } - } -} diff --git a/client/go/src/cmd/testdata/src/main/application/services.xml b/client/go/src/cmd/testdata/src/main/application/services.xml deleted file mode 100644 index 766434798f0..00000000000 --- a/client/go/src/cmd/testdata/src/main/application/services.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - <strong> - </strong> - - ... - - - - - - - - - - http://*/site/* - http://*/site - - localhost - 8080 - - - - - - - - - - - - - - 2 - 1000 - 500 - 300 - - - 2 - - - - - - - - - - diff --git a/client/go/src/go.mod b/client/go/src/go.mod deleted file mode 100644 index 40499f09e04..00000000000 --- a/client/go/src/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module github.com/vespa-engine/vespa - -go 1.16 - -require ( - github.com/spf13/cobra v1.2.1 - github.com/spf13/viper v1.8.1 - github.com/stretchr/testify v1.7.0 -) diff --git a/client/go/src/main.go b/client/go/src/main.go deleted file mode 100644 index 3803ee357b2..00000000000 --- a/client/go/src/main.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Cobra commands main file -// Author: bratseth - -package main - -import ( - "github.com/vespa-engine/vespa/cmd" -) - -func main() { - cmd.Execute() -} diff --git a/client/go/src/util/http.go b/client/go/src/util/http.go deleted file mode 100644 index 24e2416117c..00000000000 --- a/client/go/src/util/http.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// A HTTP wrapper which handles some errors and provides a way to replace the HTTP client by a mock. -// Author: bratseth - -package util - -import ( - "net/http" - "net/url" - "strings" - "time" -) - -// Set this to a mock HttpClient instead to unit test HTTP requests -var ActiveHttpClient = CreateClient(time.Second * 10) - -type HttpClient interface { - Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) -} - -type defaultHttpClient struct { - client *http.Client -} - -func (c *defaultHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { - if c.client.Timeout != timeout { // Create a new client with the right timeout - c.client = &http.Client{Timeout: timeout,} - } - return c.client.Do(request) -} - -func CreateClient(timeout time.Duration) HttpClient { - return &defaultHttpClient{ - client: &http.Client{Timeout: timeout,}, - } -} - -// Convenience function for doing a HTTP GET -func HttpGet(host string, path string, description string) *http.Response { - url, urlError := url.Parse(host + path) - if urlError != nil { - Error("Invalid target url '" + host + path + "'") - return nil - } - return HttpDo(&http.Request{URL: url,}, time.Second * 10, description) -} - -func HttpDo(request *http.Request, timeout time.Duration, description string) *http.Response { - response, error := ActiveHttpClient.Do(request, timeout) - if error != nil { - Error("Could not connect to", strings.ToLower(description), "at", request.URL.Host) - Detail(error.Error()) - } - return response -} diff --git a/client/go/src/util/http_test.go b/client/go/src/util/http_test.go deleted file mode 100644 index 03b155488d9..00000000000 --- a/client/go/src/util/http_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Basic testing of our HTTP client wrapper -// Author: bratseth - -package util - -import ( - "bytes" - "github.com/stretchr/testify/assert" - "io/ioutil" - "net/http" - "testing" - "time" -) - -type mockHttpClient struct {} - -func (c mockHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { - var status int - var body string - if request.URL.String() == "http://host/okpath" { - status = 200 - body = "OK body" - } else { - status = 500 - body = "Unexpected url body" - } - - return &http.Response{ - StatusCode: status, - Header: make(http.Header), - Body: ioutil.NopCloser(bytes.NewBufferString(body)), - }, - nil -} - -func TestHttpRequest(t *testing.T) { - ActiveHttpClient = mockHttpClient{} - - response := HttpGet("http://host", "/okpath", "description") - assert.Equal(t, 200, response.StatusCode) - - response = HttpGet("http://host", "/otherpath", "description") - assert.Equal(t, 500, response.StatusCode) -} - diff --git a/client/go/src/util/io.go b/client/go/src/util/io.go deleted file mode 100644 index 217beb085d1..00000000000 --- a/client/go/src/util/io.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// File utilities. -// Author: bratseth - -package util - -import ( - "errors" - "io" - "os" - "strings" -) - -// Returns true if the given path exists -func PathExists(path string) bool { - _, err := os.Stat(path) - return ! errors.Is(err, os.ErrNotExist) -} - -// Returns true is the given path points to an existing directory -func IsDirectory(path string) bool { - info, err := os.Stat(path) - return ! errors.Is(err, os.ErrNotExist) && info.IsDir() -} - -// Returns the content of a reader as a string -func ReaderToString(reader io.ReadCloser) string { - buffer := new(strings.Builder) - io.Copy(buffer, reader) - return buffer.String() -} \ No newline at end of file diff --git a/client/go/src/util/print.go b/client/go/src/util/print.go deleted file mode 100644 index 76912094f6e..00000000000 --- a/client/go/src/util/print.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -// Print functions for color-coded text. -// Author: bratseth - -package util - -import ( - "bufio" - "fmt" - "io" - "os" -) - -// Set this to have output written somewhere else than os.Stdout -var Out io.Writer - -func init() { - Out = os.Stdout -} - -// Prints in default color -func Print(messages ...string) { - print("", messages) -} - -// Prints in a color appropriate for errors -func Error(messages ...string) { - print("\033[31m", messages) -} - -// Prints in a color appropriate for success messages -func Success(messages ...string) { - print("\033[32m", messages) -} - -// Prints in a color appropriate for detail messages -func Detail(messages ...string) { - print("\033[33m", messages) -} - -// Prints all the text of the given reader -func PrintReader(reader io.ReadCloser) { - // TODO: Pretty-print body - scanner := bufio.NewScanner(reader) - for ;scanner.Scan(); { - Print(scanner.Text()) - } - if err := scanner.Err(); err != nil { - Error(err.Error()) - } -} - -func print(prefix string, messages []string) { - fmt.Fprint(Out, prefix) - for i := 0; i < len(messages); i++ { - fmt.Fprint(Out, messages[i]) - if (i < len(messages) - 1) { - fmt.Fprint(Out, " ") - } - } - fmt.Fprintln(Out, "") -} diff --git a/client/go/util/http.go b/client/go/util/http.go new file mode 100644 index 00000000000..24e2416117c --- /dev/null +++ b/client/go/util/http.go @@ -0,0 +1,55 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// A HTTP wrapper which handles some errors and provides a way to replace the HTTP client by a mock. +// Author: bratseth + +package util + +import ( + "net/http" + "net/url" + "strings" + "time" +) + +// Set this to a mock HttpClient instead to unit test HTTP requests +var ActiveHttpClient = CreateClient(time.Second * 10) + +type HttpClient interface { + Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) +} + +type defaultHttpClient struct { + client *http.Client +} + +func (c *defaultHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { + if c.client.Timeout != timeout { // Create a new client with the right timeout + c.client = &http.Client{Timeout: timeout,} + } + return c.client.Do(request) +} + +func CreateClient(timeout time.Duration) HttpClient { + return &defaultHttpClient{ + client: &http.Client{Timeout: timeout,}, + } +} + +// Convenience function for doing a HTTP GET +func HttpGet(host string, path string, description string) *http.Response { + url, urlError := url.Parse(host + path) + if urlError != nil { + Error("Invalid target url '" + host + path + "'") + return nil + } + return HttpDo(&http.Request{URL: url,}, time.Second * 10, description) +} + +func HttpDo(request *http.Request, timeout time.Duration, description string) *http.Response { + response, error := ActiveHttpClient.Do(request, timeout) + if error != nil { + Error("Could not connect to", strings.ToLower(description), "at", request.URL.Host) + Detail(error.Error()) + } + return response +} diff --git a/client/go/util/http_test.go b/client/go/util/http_test.go new file mode 100644 index 00000000000..03b155488d9 --- /dev/null +++ b/client/go/util/http_test.go @@ -0,0 +1,46 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Basic testing of our HTTP client wrapper +// Author: bratseth + +package util + +import ( + "bytes" + "github.com/stretchr/testify/assert" + "io/ioutil" + "net/http" + "testing" + "time" +) + +type mockHttpClient struct {} + +func (c mockHttpClient) Do(request *http.Request, timeout time.Duration) (response *http.Response, error error) { + var status int + var body string + if request.URL.String() == "http://host/okpath" { + status = 200 + body = "OK body" + } else { + status = 500 + body = "Unexpected url body" + } + + return &http.Response{ + StatusCode: status, + Header: make(http.Header), + Body: ioutil.NopCloser(bytes.NewBufferString(body)), + }, + nil +} + +func TestHttpRequest(t *testing.T) { + ActiveHttpClient = mockHttpClient{} + + response := HttpGet("http://host", "/okpath", "description") + assert.Equal(t, 200, response.StatusCode) + + response = HttpGet("http://host", "/otherpath", "description") + assert.Equal(t, 500, response.StatusCode) +} + diff --git a/client/go/util/io.go b/client/go/util/io.go new file mode 100644 index 00000000000..217beb085d1 --- /dev/null +++ b/client/go/util/io.go @@ -0,0 +1,31 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// File utilities. +// Author: bratseth + +package util + +import ( + "errors" + "io" + "os" + "strings" +) + +// Returns true if the given path exists +func PathExists(path string) bool { + _, err := os.Stat(path) + return ! errors.Is(err, os.ErrNotExist) +} + +// Returns true is the given path points to an existing directory +func IsDirectory(path string) bool { + info, err := os.Stat(path) + return ! errors.Is(err, os.ErrNotExist) && info.IsDir() +} + +// Returns the content of a reader as a string +func ReaderToString(reader io.ReadCloser) string { + buffer := new(strings.Builder) + io.Copy(buffer, reader) + return buffer.String() +} \ No newline at end of file diff --git a/client/go/util/print.go b/client/go/util/print.go new file mode 100644 index 00000000000..76912094f6e --- /dev/null +++ b/client/go/util/print.go @@ -0,0 +1,62 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Print functions for color-coded text. +// Author: bratseth + +package util + +import ( + "bufio" + "fmt" + "io" + "os" +) + +// Set this to have output written somewhere else than os.Stdout +var Out io.Writer + +func init() { + Out = os.Stdout +} + +// Prints in default color +func Print(messages ...string) { + print("", messages) +} + +// Prints in a color appropriate for errors +func Error(messages ...string) { + print("\033[31m", messages) +} + +// Prints in a color appropriate for success messages +func Success(messages ...string) { + print("\033[32m", messages) +} + +// Prints in a color appropriate for detail messages +func Detail(messages ...string) { + print("\033[33m", messages) +} + +// Prints all the text of the given reader +func PrintReader(reader io.ReadCloser) { + // TODO: Pretty-print body + scanner := bufio.NewScanner(reader) + for ;scanner.Scan(); { + Print(scanner.Text()) + } + if err := scanner.Err(); err != nil { + Error(err.Error()) + } +} + +func print(prefix string, messages []string) { + fmt.Fprint(Out, prefix) + for i := 0; i < len(messages); i++ { + fmt.Fprint(Out, messages[i]) + if (i < len(messages) - 1) { + fmt.Fprint(Out, " ") + } + } + fmt.Fprintln(Out, "") +} -- cgit v1.2.3 From 806f1ca17888171403c9688dcf9b999fed205344 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Aug 2021 09:53:26 +0200 Subject: Use reader --- client/go/util/print.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/go/util/print.go b/client/go/util/print.go index 76912094f6e..7734a2a1a9e 100644 --- a/client/go/util/print.go +++ b/client/go/util/print.go @@ -39,7 +39,7 @@ func Detail(messages ...string) { } // Prints all the text of the given reader -func PrintReader(reader io.ReadCloser) { +func PrintReader(reader io.Reader) { // TODO: Pretty-print body scanner := bufio.NewScanner(reader) for ;scanner.Scan(); { -- cgit v1.2.3 From 22551080edea429c0cdac1770fbd92f34d56edfe Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Aug 2021 10:56:50 +0200 Subject: Redirect output from flag reset command --- client/go/cmd/command_tester.go | 1 + 1 file changed, 1 insertion(+) diff --git a/client/go/cmd/command_tester.go b/client/go/cmd/command_tester.go index f1d4b52d0bb..40c3d04446e 100644 --- a/client/go/cmd/command_tester.go +++ b/client/go/cmd/command_tester.go @@ -19,6 +19,7 @@ func executeCommand(t *testing.T, client *mockHttpClient, args []string, moreArg util.ActiveHttpClient = client // Reset - persistent flags in Cobra persists over tests + util.Out = bytes.NewBufferString("") rootCmd.SetArgs([]string{"status", "-t", ""}) rootCmd.Execute() -- cgit v1.2.3 From 4cf24301465f021893aa9439c20e4834760930b1 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Aug 2021 11:13:58 +0200 Subject: Add back top-leve files --- client/go/go.mod | 9 +++++++++ client/go/main.go | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 client/go/go.mod create mode 100644 client/go/main.go diff --git a/client/go/go.mod b/client/go/go.mod new file mode 100644 index 00000000000..40499f09e04 --- /dev/null +++ b/client/go/go.mod @@ -0,0 +1,9 @@ +module github.com/vespa-engine/vespa + +go 1.16 + +require ( + github.com/spf13/cobra v1.2.1 + github.com/spf13/viper v1.8.1 + github.com/stretchr/testify v1.7.0 +) diff --git a/client/go/main.go b/client/go/main.go new file mode 100644 index 00000000000..3803ee357b2 --- /dev/null +++ b/client/go/main.go @@ -0,0 +1,13 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Cobra commands main file +// Author: bratseth + +package main + +import ( + "github.com/vespa-engine/vespa/cmd" +) + +func main() { + cmd.Execute() +} -- cgit v1.2.3 From 20ecdcec71d0443b5b5085c322dc9f48ad24c5a0 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Aug 2021 11:43:34 +0200 Subject: JSON prettyprint responses --- client/go/cmd/query_test.go | 15 +++++++++++++++ client/go/util/io.go | 12 ++++++++++-- client/go/util/print.go | 17 +++++++++-------- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/client/go/cmd/query_test.go b/client/go/cmd/query_test.go index ab48c482a7d..f55956bc1ce 100644 --- a/client/go/cmd/query_test.go +++ b/client/go/cmd/query_test.go @@ -16,6 +16,12 @@ func TestQuery(t *testing.T) { "select from sources * where title contains 'foo'") } +func TestQueryNonJsonResult(t *testing.T) { + assertQuery(t, + "?yql=select+from+sources+%2A+where+title+contains+%27foo%27", + "select from sources * where title contains 'foo'") +} + func TestQueryWithMultipleParameters(t *testing.T) { assertQuery(t, "?hits=5&yql=select+from+sources+%2A+where+title+contains+%27foo%27", @@ -37,6 +43,15 @@ func TestServerError(t *testing.T) { } func assertQuery(t *testing.T, expectedQuery string, query ...string) { + client := &mockHttpClient{ nextBody: "{\"query\":\"result\"}", } + assert.Equal(t, + "{\n \"query\": \"result\"\n}\n", + executeCommand(t, client, []string{"query"}, query), + "query output") + assert.Equal(t, getTarget(queryContext).query + "/search/" + expectedQuery, client.lastRequest.URL.String()) +} + +func assertQueryNonJsonResult(t *testing.T, expectedQuery string, query ...string) { client := &mockHttpClient{ nextBody: "query result", } assert.Equal(t, "query result\n", diff --git a/client/go/util/io.go b/client/go/util/io.go index 217beb085d1..d7b849ba9a4 100644 --- a/client/go/util/io.go +++ b/client/go/util/io.go @@ -5,6 +5,7 @@ package util import ( + "bytes" "errors" "io" "os" @@ -24,8 +25,15 @@ func IsDirectory(path string) bool { } // Returns the content of a reader as a string -func ReaderToString(reader io.ReadCloser) string { +func ReaderToString(reader io.Reader) string { buffer := new(strings.Builder) io.Copy(buffer, reader) return buffer.String() -} \ No newline at end of file +} + +// Returns the content of a reader as a byte array +func ReaderToBytes(reader io.Reader) []byte { + buffer := new(bytes.Buffer) + buffer.ReadFrom(reader) + return buffer.Bytes() +} diff --git a/client/go/util/print.go b/client/go/util/print.go index 7734a2a1a9e..91a223a3c3a 100644 --- a/client/go/util/print.go +++ b/client/go/util/print.go @@ -5,7 +5,8 @@ package util import ( - "bufio" + "bytes" + "encoding/json" "fmt" "io" "os" @@ -40,13 +41,13 @@ func Detail(messages ...string) { // Prints all the text of the given reader func PrintReader(reader io.Reader) { - // TODO: Pretty-print body - scanner := bufio.NewScanner(reader) - for ;scanner.Scan(); { - Print(scanner.Text()) - } - if err := scanner.Err(); err != nil { - Error(err.Error()) + bodyBytes := ReaderToBytes(reader) + var prettyJSON bytes.Buffer + parseError := json.Indent(&prettyJSON, bodyBytes, "", " ") + if parseError != nil { // Not JSON: Print plainly + Print(string(bodyBytes)) + } else { + Print(string(prettyJSON.Bytes())) } } -- cgit v1.2.3 From 582b666d2aaa51749555193637be7fa0a7a1dc24 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Aug 2021 13:45:32 +0200 Subject: document get -> post and allow id in document --- client/go/build.sh | 9 +---- client/go/cmd/document.go | 47 +++++++++++++++------- client/go/cmd/document_test.go | 20 +++++---- .../testdata/A-Head-Full-of-Dreams-With-Id.json | 15 +++++++ 4 files changed, 61 insertions(+), 30 deletions(-) create mode 100644 client/go/cmd/testdata/A-Head-Full-of-Dreams-With-Id.json diff --git a/client/go/build.sh b/client/go/build.sh index 08d8f1d8983..6d9416e8950 100755 --- a/client/go/build.sh +++ b/client/go/build.sh @@ -1,14 +1,7 @@ # Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. # Execute from this directory to build the command-line client to bin/vespa -cd util -go test -cd .. - -cd cmd -go test -cd .. - export GOBIN=`pwd`/bin +go test ./... go install diff --git a/client/go/cmd/document.go b/client/go/cmd/document.go index f48a3965d01..9f9d6a9752c 100644 --- a/client/go/cmd/document.go +++ b/client/go/cmd/document.go @@ -5,6 +5,8 @@ package cmd import ( + "bytes" + "encoding/json" "github.com/spf13/cobra" "github.com/vespa-engine/vespa/util" "io/ioutil" @@ -17,34 +19,37 @@ import ( func init() { rootCmd.AddCommand(documentCmd) - statusCmd.AddCommand(documentPutCmd) - statusCmd.AddCommand(documentGetCmd) + documentCmd.AddCommand(documentPostCmd) + documentCmd.AddCommand(documentGetCmd) } var documentCmd = &cobra.Command{ Use: "document", - Short: "Issue document operations (put by default)", + Short: "Issue document operations", Long: `TODO: Example mynamespace/mydocumenttype/myid document.json`, // TODO: Check args Run: func(cmd *cobra.Command, args []string) { - put(args[0], args[1]) + util.Error("Use either document post or document get") }, } -var documentPutCmd = &cobra.Command{ - Use: "put mynamespace/mydocumenttype/myid mydocument.json", - Short: "Puts the document in the given file", +var documentPostCmd = &cobra.Command{ + Use: "post", + Short: "Posts the document in the given file", Long: `TODO`, - // TODO: This crashes with the above // TODO: Extract document id from the content // TODO: Check args Run: func(cmd *cobra.Command, args []string) { - put(args[0], args[1]) + if len(args) == 10 { + post("", args[0]) + } else { + post(args[0], args[1]) + } }, } var documentGetCmd = &cobra.Command{ - Use: "get documentId", + Use: "get", Short: "Gets a document", Long: `TODO`, // TODO: Check args @@ -57,8 +62,7 @@ func get(documentId string) { // TODO } -func put(documentId string, jsonFile string) { - // TODO: Support document id in JSON, see https://docs.vespa.ai/en/reference/document-json-format.html +func post(documentId string, jsonFile string) { url, _ := url.Parse(getTarget(documentContext).document + "/document/v1/" + documentId) header := http.Header{} @@ -71,11 +75,26 @@ func put(documentId string, jsonFile string) { return } + documentData := util.ReaderToBytes(fileReader) + + if documentId == "" { + var doc map[string]interface{} + json.Unmarshal(documentData, &doc) + documentId = doc["id"].(string) + if documentId == "" { + documentId = doc["put"].(string) // document feeder format + } + if documentId == "" { + util.Error("No document id given neither as argument or an 'id' key in the json file") + return + } + } + request := &http.Request{ URL: url, Method: "POST", Header: header, - Body: ioutil.NopCloser(fileReader), + Body: ioutil.NopCloser(bytes.NewReader(documentData)), } serviceDescription := "Container (document API)" response := util.HttpDo(request, time.Second * 60, serviceDescription) @@ -93,4 +112,4 @@ func put(documentId string, jsonFile string) { util.Error("Error from", strings.ToLower(serviceDescription), "at", request.URL.Host, "(" + response.Status + "):") util.PrintReader(response.Body) } -} \ No newline at end of file +} diff --git a/client/go/cmd/document_test.go b/client/go/cmd/document_test.go index 9d0ae6e505e..410cfbb9bfd 100644 --- a/client/go/cmd/document_test.go +++ b/client/go/cmd/document_test.go @@ -12,23 +12,27 @@ import ( "testing" ) -func TestDocumentPut(t *testing.T) { - assertDocumentPut("mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json", t) +func TestDocumentPostWithIdArg(t *testing.T) { + assertDocumentPost("mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json", t) } -func TestDocumentPutDocumentError(t *testing.T) { +func TestDocumentPostWithIdInDocument(t *testing.T) { + assertDocumentPost("", "testdata/A-Head-Full-of-Dreams-With-Id.json", t) +} + +func TestDocumentPostDocumentError(t *testing.T) { assertDocumentError(t, 401, "Document error") } -func TestDocumentPutServerError(t *testing.T) { +func TestDocumentPostServerError(t *testing.T) { assertDocumentServerError(t, 501, "Server error") } -func assertDocumentPut(documentId string, jsonFile string, t *testing.T) { +func assertDocumentPost(documentId string, jsonFile string, t *testing.T) { client := &mockHttpClient{} assert.Equal(t, "\x1b[32mSuccess\n", - executeCommand(t, client, []string{"document", documentId, jsonFile}, []string{})) + executeCommand(t, client, []string{"document", "post", documentId, jsonFile}, []string{})) target := getTarget(documentContext).document assert.Equal(t, target + "/document/v1/" + documentId, client.lastRequest.URL.String()) assert.Equal(t, "application/json", client.lastRequest.Header.Get("Content-Type")) @@ -42,7 +46,7 @@ func assertDocumentError(t *testing.T, status int, errorMessage string) { client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } assert.Equal(t, "\x1b[31mInvalid document (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", - executeCommand(t, client, []string{"document", + executeCommand(t, client, []string{"document", "post", "mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json"}, []string{})) } @@ -51,7 +55,7 @@ func assertDocumentServerError(t *testing.T, status int, errorMessage string) { client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } assert.Equal(t, "\x1b[31mError from container (document api) at 127.0.0.1:8080 (Status " + strconv.Itoa(status) + "):\n" + errorMessage + "\n", - executeCommand(t, client, []string{"document", + executeCommand(t, client, []string{"document", "post", "mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json"}, []string{})) } \ No newline at end of file diff --git a/client/go/cmd/testdata/A-Head-Full-of-Dreams-With-Id.json b/client/go/cmd/testdata/A-Head-Full-of-Dreams-With-Id.json new file mode 100644 index 00000000000..fddbbf94916 --- /dev/null +++ b/client/go/cmd/testdata/A-Head-Full-of-Dreams-With-Id.json @@ -0,0 +1,15 @@ +{ + "id": "mynamespace/music/docid/1", + "fields": { + "album": "A Head Full of Dreams", + "artist": "Coldplay", + "year": 2015, + "category_scores": { + "cells": [ + { "address" : { "cat" : "pop" }, "value": 1 }, + { "address" : { "cat" : "rock" }, "value": 0.2 }, + { "address" : { "cat" : "jazz" }, "value": 0 } + ] + } + } +} -- cgit v1.2.3 From 150adadb23ba916ce62beead6b50d52aa43cd5c7 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Aug 2021 13:53:36 +0200 Subject: Check in go.sum --- client/go/.gitignore | 2 - client/go/go.sum | 591 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 591 insertions(+), 2 deletions(-) create mode 100644 client/go/go.sum diff --git a/client/go/.gitignore b/client/go/.gitignore index 2275a3bddb7..e660fd93d31 100644 --- a/client/go/.gitignore +++ b/client/go/.gitignore @@ -1,3 +1 @@ bin/ -pkg/ -*.sum diff --git a/client/go/go.sum b/client/go/go.sum new file mode 100644 index 00000000000..d6ff538bc63 --- /dev/null +++ b/client/go/go.sum @@ -0,0 +1,591 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= +cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= +cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= +github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= +github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= +github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw= +github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.8.1 h1:Kq1fyeebqsBfbjZj4EL7gj2IO0mMaiyjYUWcUsl2O44= +github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= +go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= +google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= +gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -- cgit v1.2.3 From c292201c97b583448212442725e56499ed30b100 Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Tue, 24 Aug 2021 19:51:42 +0200 Subject: Support document post short form --- client/go/cmd/document.go | 11 +++++------ client/go/cmd/document_test.go | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/client/go/cmd/document.go b/client/go/cmd/document.go index 9f9d6a9752c..f2d7b80289d 100644 --- a/client/go/cmd/document.go +++ b/client/go/cmd/document.go @@ -26,10 +26,10 @@ func init() { var documentCmd = &cobra.Command{ Use: "document", Short: "Issue document operations", - Long: `TODO: Example mynamespace/mydocumenttype/myid document.json`, + Long: `TODO: Example vespa document mynamespace/mydocumenttype/myid document.json`, // TODO: Check args Run: func(cmd *cobra.Command, args []string) { - util.Error("Use either document post or document get") + post("", args[0]) }, } @@ -37,10 +37,9 @@ var documentPostCmd = &cobra.Command{ Use: "post", Short: "Posts the document in the given file", Long: `TODO`, - // TODO: Extract document id from the content // TODO: Check args Run: func(cmd *cobra.Command, args []string) { - if len(args) == 10 { + if len(args) == 1 { post("", args[0]) } else { post(args[0], args[1]) @@ -63,8 +62,6 @@ func get(documentId string) { } func post(documentId string, jsonFile string) { - url, _ := url.Parse(getTarget(documentContext).document + "/document/v1/" + documentId) - header := http.Header{} header.Add("Content-Type", "application/json") @@ -90,6 +87,8 @@ func post(documentId string, jsonFile string) { } } + url, _ := url.Parse(getTarget(documentContext).document + "/document/v1/" + documentId) + request := &http.Request{ URL: url, Method: "POST", diff --git a/client/go/cmd/document_test.go b/client/go/cmd/document_test.go index 410cfbb9bfd..c3930247dcd 100644 --- a/client/go/cmd/document_test.go +++ b/client/go/cmd/document_test.go @@ -13,11 +13,18 @@ import ( ) func TestDocumentPostWithIdArg(t *testing.T) { - assertDocumentPost("mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json", t) + assertDocumentPost([]string{"document", "post", "mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json"}, + "mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams.json", t) } func TestDocumentPostWithIdInDocument(t *testing.T) { - assertDocumentPost("", "testdata/A-Head-Full-of-Dreams-With-Id.json", t) + assertDocumentPost([]string{"document", "post", "testdata/A-Head-Full-of-Dreams-With-Id.json"}, + "mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams-With-Id.json", t) +} + +func TestDocumentPostWithIdInDocumentShortForm(t *testing.T) { + assertDocumentPost([]string{"document", "testdata/A-Head-Full-of-Dreams-With-Id.json"}, + "mynamespace/music/docid/1", "testdata/A-Head-Full-of-Dreams-With-Id.json", t) } func TestDocumentPostDocumentError(t *testing.T) { @@ -28,11 +35,11 @@ func TestDocumentPostServerError(t *testing.T) { assertDocumentServerError(t, 501, "Server error") } -func assertDocumentPost(documentId string, jsonFile string, t *testing.T) { +func assertDocumentPost(arguments []string, documentId string, jsonFile string, t *testing.T) { client := &mockHttpClient{} assert.Equal(t, "\x1b[32mSuccess\n", - executeCommand(t, client, []string{"document", "post", documentId, jsonFile}, []string{})) + executeCommand(t, client, arguments, []string{})) target := getTarget(documentContext).document assert.Equal(t, target + "/document/v1/" + documentId, client.lastRequest.URL.String()) assert.Equal(t, "application/json", client.lastRequest.Header.Get("Content-Type")) @@ -42,6 +49,15 @@ func assertDocumentPost(documentId string, jsonFile string, t *testing.T) { assert.Equal(t, string(fileContent), util.ReaderToString(client.lastRequest.Body)) } +func assertDocumentPostShortForm(documentId string, jsonFile string, t *testing.T) { + client := &mockHttpClient{} + assert.Equal(t, + "\x1b[32mSuccess\n", + executeCommand(t, client, []string{"document", jsonFile}, []string{})) + target := getTarget(documentContext).document + assert.Equal(t, target + "/document/v1/" + documentId, client.lastRequest.URL.String()) +} + func assertDocumentError(t *testing.T, status int, errorMessage string) { client := &mockHttpClient{ nextStatus: status, nextBody: errorMessage, } assert.Equal(t, -- cgit v1.2.3