From bb3a8d844a18414dce5ba50a7ded036f72f67db0 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 3 May 2016 13:23:05 -0400 Subject: [PATCH] Update deps --- Godeps/Godeps.json | 56 +-- .../Azure/azure-sdk-for-go/storage/blob.go | 41 +- .../Azure/azure-sdk-for-go/storage/client.go | 108 ++++++ .../Azure/azure-sdk-for-go/storage/table.go | 129 +++++++ .../storage/table_entities.go | 351 ++++++++++++++++++ .../go-rootcerts/rootcerts_darwin_test.go | 17 - .../hashicorp/go-rootcerts/rootcerts_test.go | 52 --- .../test-fixtures/cafile/cacert.pem | 28 -- .../capath-with-symlinks/securetrust.pem | 1 - .../capath-with-symlinks/thawte.pem | 1 - .../test-fixtures/capath/securetrust.pem | 22 -- .../test-fixtures/capath/thawte.pem | 25 -- vendor/golang.org/x/crypto/ssh/handshake.go | 8 +- 13 files changed, 658 insertions(+), 181 deletions(-) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/storage/table.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go delete mode 100644 vendor/github.com/hashicorp/go-rootcerts/rootcerts_darwin_test.go delete mode 100644 vendor/github.com/hashicorp/go-rootcerts/rootcerts_test.go delete mode 100644 vendor/github.com/hashicorp/go-rootcerts/test-fixtures/cafile/cacert.pem delete mode 120000 vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath-with-symlinks/securetrust.pem delete mode 120000 vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath-with-symlinks/thawte.pem delete mode 100644 vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath/securetrust.pem delete mode 100644 vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath/thawte.pem diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index c70a31c8fe..a75bd96e48 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -8,8 +8,8 @@ "Deps": [ { "ImportPath": "github.com/Azure/azure-sdk-for-go/storage", - "Comment": "v2.1.1-beta", - "Rev": "a1883f7b98346e4908a6c25230c95a8a3026a10c" + "Comment": "v2.1.1-beta-4-gd4e45a6", + "Rev": "d4e45a63c9d269ddff72970df7c80d214aeddcf3" }, { "ImportPath": "github.com/armon/go-metrics", @@ -184,28 +184,28 @@ }, { "ImportPath": "github.com/coreos/etcd/client", - "Comment": "v2.3.0-644-gfee71b1", - "Rev": "fee71b18a3093223b41a592e19373f01a44e227f" + "Comment": "v2.3.0-651-gfd27f9c", + "Rev": "fd27f9cd288c7ccd03d2555663a2ed20178d4b5c" }, { "ImportPath": "github.com/coreos/etcd/pkg/pathutil", - "Comment": "v2.3.0-644-gfee71b1", - "Rev": "fee71b18a3093223b41a592e19373f01a44e227f" + "Comment": "v2.3.0-651-gfd27f9c", + "Rev": "fd27f9cd288c7ccd03d2555663a2ed20178d4b5c" }, { "ImportPath": "github.com/coreos/etcd/pkg/tlsutil", - "Comment": "v2.3.0-644-gfee71b1", - "Rev": "fee71b18a3093223b41a592e19373f01a44e227f" + "Comment": "v2.3.0-651-gfd27f9c", + "Rev": "fd27f9cd288c7ccd03d2555663a2ed20178d4b5c" }, { "ImportPath": "github.com/coreos/etcd/pkg/transport", - "Comment": "v2.3.0-644-gfee71b1", - "Rev": "fee71b18a3093223b41a592e19373f01a44e227f" + "Comment": "v2.3.0-651-gfd27f9c", + "Rev": "fd27f9cd288c7ccd03d2555663a2ed20178d4b5c" }, { "ImportPath": "github.com/coreos/etcd/pkg/types", - "Comment": "v2.3.0-644-gfee71b1", - "Rev": "fee71b18a3093223b41a592e19373f01a44e227f" + "Comment": "v2.3.0-651-gfd27f9c", + "Rev": "fd27f9cd288c7ccd03d2555663a2ed20178d4b5c" }, { "ImportPath": "github.com/denisenkom/go-mssqldb", @@ -419,59 +419,59 @@ }, { "ImportPath": "golang.org/x/crypto/bcrypt", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/blowfish", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/cast5", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/curve25519", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/md4", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/openpgp", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/openpgp/armor", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/openpgp/elgamal", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/openpgp/errors", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/openpgp/packet", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/openpgp/s2k", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/ssh", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/ssh/agent", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/crypto/ssh/terminal", - "Rev": "285fb2ed20d1dc450fc743a1b3ff7c36bef372b9" + "Rev": "2cb52d93744fdc9a51f5c87b36fe2208d424af5a" }, { "ImportPath": "golang.org/x/net/context", @@ -479,11 +479,11 @@ }, { "ImportPath": "golang.org/x/oauth2", - "Rev": "9ef2eddcc6774e42f998940fe1167216d36a7424" + "Rev": "f6a14f0423bcd7a0ae907ace2795e63ec5f9fe51" }, { "ImportPath": "golang.org/x/oauth2/internal", - "Rev": "9ef2eddcc6774e42f998940fe1167216d36a7424" + "Rev": "f6a14f0423bcd7a0ae907ace2795e63ec5f9fe51" }, { "ImportPath": "golang.org/x/sys/unix", diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go index 47e8091c3d..9e65ade4d0 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/blob.go @@ -55,7 +55,33 @@ type ContainerListResponse struct { type Blob struct { Name string `xml:"Name"` Properties BlobProperties `xml:"Properties"` - // TODO (ahmetalpbalkan) Metadata + Metadata BlobMetadata `xml:"Metadata"` +} + +// BlobMetadata contains various mtadata properties of the blob +type BlobMetadata map[string]string + +type blobMetadataEntries struct { + Entries []blobMetadataEntry `xml:",any"` +} +type blobMetadataEntry struct { + XMLName xml.Name + Value string `xml:",chardata"` +} + +// UnmarshalXML converts the xml:Metadata into Metadata map +func (bm *BlobMetadata) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { + var entries blobMetadataEntries + if err := d.DecodeElement(&entries, &start); err != nil { + return err + } + for _, entry := range entries.Entries { + if *bm == nil { + *bm = make(BlobMetadata) + } + (*bm)[strings.ToLower(entry.XMLName.Local)] = entry.Value + } + return nil } // BlobProperties contains various properties of a blob @@ -457,7 +483,7 @@ func (b BlobStorageClient) GetBlobURL(container, name string) string { // // See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx func (b BlobStorageClient) GetBlob(container, name string) (io.ReadCloser, error) { - resp, err := b.getBlobRange(container, name, "") + resp, err := b.getBlobRange(container, name, "", nil) if err != nil { return nil, err } @@ -472,8 +498,8 @@ func (b BlobStorageClient) GetBlob(container, name string) (io.ReadCloser, error // string must be in a format like "0-", "10-100" as defined in HTTP 1.1 spec. // // See https://msdn.microsoft.com/en-us/library/azure/dd179440.aspx -func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string) (io.ReadCloser, error) { - resp, err := b.getBlobRange(container, name, bytesRange) +func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string, extraHeaders map[string]string) (io.ReadCloser, error) { + resp, err := b.getBlobRange(container, name, bytesRange, extraHeaders) if err != nil { return nil, err } @@ -484,7 +510,7 @@ func (b BlobStorageClient) GetBlobRange(container, name, bytesRange string) (io. return resp.body, nil } -func (b BlobStorageClient) getBlobRange(container, name, bytesRange string) (*storageResponse, error) { +func (b BlobStorageClient) getBlobRange(container, name, bytesRange string, extraHeaders map[string]string) (*storageResponse, error) { verb := "GET" uri := b.client.getEndpoint(blobServiceName, pathForBlob(container, name), url.Values{}) @@ -492,6 +518,11 @@ func (b BlobStorageClient) getBlobRange(container, name, bytesRange string) (*st if bytesRange != "" { headers["Range"] = fmt.Sprintf("bytes=%s", bytesRange) } + + for k, v := range extraHeaders { + headers[k] = v + } + resp, err := b.client.exec(verb, uri, headers, nil) if err != nil { return nil, err diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go index 4a0dc5b343..41cdb25fe7 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/client.go @@ -4,6 +4,7 @@ package storage import ( "bytes" "encoding/base64" + "encoding/json" "encoding/xml" "errors" "fmt" @@ -54,6 +55,11 @@ type storageResponse struct { body io.ReadCloser } +type odataResponse struct { + storageResponse + odata odataErrorMessage +} + // AzureStorageServiceError contains fields of the error response from // Azure Storage Service REST API. See https://msdn.microsoft.com/en-us/library/azure/dd179382.aspx // Some fields might be specific to certain calls. @@ -68,6 +74,20 @@ type AzureStorageServiceError struct { RequestID string } +type odataErrorMessageMessage struct { + Lang string `json:"lang"` + Value string `json:"value"` +} + +type odataErrorMessageInternal struct { + Code string `json:"code"` + Message odataErrorMessageMessage `json:"message"` +} + +type odataErrorMessage struct { + Err odataErrorMessageInternal `json:"odata.error"` +} + // UnexpectedStatusCodeError is returned when a storage service responds with neither an error // nor with an HTTP status code indicating success. type UnexpectedStatusCodeError struct { @@ -166,6 +186,12 @@ func (c Client) GetQueueService() QueueServiceClient { return QueueServiceClient{c} } +// GetTableService returns a TableServiceClient which can operate on the table +// service of the storage account. +func (c Client) GetTableService() TableServiceClient { + return TableServiceClient{c} +} + // GetFileService returns a FileServiceClient which can operate on the file // service of the storage account. func (c Client) GetFileService() FileServiceClient { @@ -228,6 +254,22 @@ func (c Client) buildCanonicalizedHeader(headers map[string]string) string { return ch } +func (c Client) buildCanonicalizedResourceTable(uri string) (string, error) { + errMsg := "buildCanonicalizedResourceTable error: %s" + u, err := url.Parse(uri) + if err != nil { + return "", fmt.Errorf(errMsg, err.Error()) + } + + cr := "/" + c.accountName + + if len(u.Path) > 0 { + cr += u.Path + } + + return cr, nil +} + func (c Client) buildCanonicalizedResource(uri string) (string, error) { errMsg := "buildCanonicalizedResource error: %s" u, err := url.Parse(uri) @@ -236,6 +278,7 @@ func (c Client) buildCanonicalizedResource(uri string) (string, error) { } cr := "/" + c.accountName + if len(u.Path) > 0 { cr += u.Path } @@ -266,6 +309,7 @@ func (c Client) buildCanonicalizedResource(uri string) (string, error) { } } } + return cr, nil } @@ -364,6 +408,70 @@ func (c Client) exec(verb, url string, headers map[string]string, body io.Reader body: resp.Body}, nil } +func (c Client) execInternalJSON(verb, url string, headers map[string]string, body io.Reader) (*odataResponse, error) { + req, err := http.NewRequest(verb, url, body) + for k, v := range headers { + req.Header.Add(k, v) + } + + httpClient := c.HTTPClient + if httpClient == nil { + httpClient = http.DefaultClient + } + + resp, err := httpClient.Do(req) + if err != nil { + return nil, err + } + + respToRet := &odataResponse{} + respToRet.body = resp.Body + respToRet.statusCode = resp.StatusCode + respToRet.headers = resp.Header + + statusCode := resp.StatusCode + if statusCode >= 400 && statusCode <= 505 { + var respBody []byte + respBody, err = readResponseBody(resp) + if err != nil { + return nil, err + } + + if len(respBody) == 0 { + // no error in response body + err = fmt.Errorf("storage: service returned without a response body (%d)", resp.StatusCode) + return respToRet, err + } + // try unmarshal as odata.error json + err = json.Unmarshal(respBody, &respToRet.odata) + return respToRet, err + } + + return respToRet, nil +} + +func (c Client) createSharedKeyLite(url string, headers map[string]string) (string, error) { + can, err := c.buildCanonicalizedResourceTable(url) + + if err != nil { + return "", err + } + strToSign := headers["x-ms-date"] + "\n" + can + + hmac := c.computeHmac256(strToSign) + return fmt.Sprintf("SharedKeyLite %s:%s", c.accountName, hmac), nil +} + +func (c Client) execTable(verb, url string, headers map[string]string, body io.Reader) (*odataResponse, error) { + var err error + headers["Authorization"], err = c.createSharedKeyLite(url, headers) + if err != nil { + return nil, err + } + + return c.execInternalJSON(verb, url, headers, body) +} + func readResponseBody(resp *http.Response) ([]byte, error) { defer resp.Body.Close() out, err := ioutil.ReadAll(resp.Body) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go new file mode 100644 index 0000000000..39e9975035 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/table.go @@ -0,0 +1,129 @@ +package storage + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" + "net/url" +) + +// TableServiceClient contains operations for Microsoft Azure Table Storage +// Service. +type TableServiceClient struct { + client Client +} + +// AzureTable is the typedef of the Azure Table name +type AzureTable string + +const ( + tablesURIPath = "/Tables" +) + +type createTableRequest struct { + TableName string `json:"TableName"` +} + +func pathForTable(table AzureTable) string { return fmt.Sprintf("%s", table) } + +func (c *TableServiceClient) getStandardHeaders() map[string]string { + return map[string]string{ + "x-ms-version": "2015-02-21", + "x-ms-date": currentTimeRfc1123Formatted(), + "Accept": "application/json;odata=nometadata", + "Accept-Charset": "UTF-8", + "Content-Type": "application/json", + } +} + +// QueryTables returns the tables created in the +// *TableServiceClient storage account. +func (c *TableServiceClient) QueryTables() ([]AzureTable, error) { + uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) + + headers := c.getStandardHeaders() + headers["Content-Length"] = "0" + + resp, err := c.client.execTable("GET", uri, headers, nil) + if err != nil { + return nil, err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return nil, err + } + + buf := new(bytes.Buffer) + buf.ReadFrom(resp.body) + + var respArray queryTablesResponse + if err := json.Unmarshal(buf.Bytes(), &respArray); err != nil { + return nil, err + } + + s := make([]AzureTable, len(respArray.TableName)) + for i, elem := range respArray.TableName { + s[i] = AzureTable(elem.TableName) + } + + return s, nil +} + +// CreateTable creates the table given the specific +// name. This function fails if the name is not compliant +// with the specification or the tables already exists. +func (c *TableServiceClient) CreateTable(table AzureTable) error { + uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) + + headers := c.getStandardHeaders() + + req := createTableRequest{TableName: string(table)} + buf := new(bytes.Buffer) + + if err := json.NewEncoder(buf).Encode(req); err != nil { + return err + } + + headers["Content-Length"] = fmt.Sprintf("%d", buf.Len()) + + resp, err := c.client.execTable("POST", uri, headers, buf) + + if err != nil { + return err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusCreated}); err != nil { + return err + } + + return nil +} + +// DeleteTable deletes the table given the specific +// name. This function fails if the table is not present. +// Be advised: DeleteTable deletes all the entries +// that may be present. +func (c *TableServiceClient) DeleteTable(table AzureTable) error { + uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) + uri += fmt.Sprintf("('%s')", string(table)) + + headers := c.getStandardHeaders() + + headers["Content-Length"] = "0" + + resp, err := c.client.execTable("DELETE", uri, headers, nil) + + if err != nil { + return err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return err + + } + return nil +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go b/vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go new file mode 100644 index 0000000000..c81393e5f5 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/storage/table_entities.go @@ -0,0 +1,351 @@ +package storage + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "reflect" +) + +const ( + partitionKeyNode = "PartitionKey" + rowKeyNode = "RowKey" + tag = "table" + tagIgnore = "-" + continuationTokenPartitionKeyHeader = "X-Ms-Continuation-Nextpartitionkey" + continuationTokenRowHeader = "X-Ms-Continuation-Nextrowkey" + maxTopParameter = 1000 +) + +type queryTablesResponse struct { + TableName []struct { + TableName string `json:"TableName"` + } `json:"value"` +} + +const ( + tableOperationTypeInsert = iota + tableOperationTypeUpdate = iota + tableOperationTypeMerge = iota + tableOperationTypeInsertOrReplace = iota + tableOperationTypeInsertOrMerge = iota +) + +type tableOperation int + +// TableEntity interface specifies +// the functions needed to support +// marshaling and unmarshaling into +// Azure Tables. The struct must only contain +// simple types because Azure Tables do not +// support hierarchy. +type TableEntity interface { + PartitionKey() string + RowKey() string + SetPartitionKey(string) error + SetRowKey(string) error +} + +// ContinuationToken is an opaque (ie not useful to inspect) +// struct that Get... methods can return if there are more +// entries to be returned than the ones already +// returned. Just pass it to the same function to continue +// receiving the remaining entries. +type ContinuationToken struct { + NextPartitionKey string + NextRowKey string +} + +type getTableEntriesResponse struct { + Elements []map[string]interface{} `json:"value"` +} + +// QueryTableEntities queries the specified table and returns the unmarshaled +// entities of type retType. +// top parameter limits the returned entries up to top. Maximum top +// allowed by Azure API is 1000. In case there are more than top entries to be +// returned the function will return a non nil *ContinuationToken. You can call the +// same function again passing the received ContinuationToken as previousContToken +// parameter in order to get the following entries. The query parameter +// is the odata query. To retrieve all the entries pass the empty string. +// The function returns a pointer to a TableEntity slice, the *ContinuationToken +// if there are more entries to be returned and an error in case something went +// wrong. +// +// Example: +// entities, cToken, err = tSvc.QueryTableEntities("table", cToken, reflect.TypeOf(entity), 20, "") +func (c *TableServiceClient) QueryTableEntities(tableName AzureTable, previousContToken *ContinuationToken, retType reflect.Type, top int, query string) ([]TableEntity, *ContinuationToken, error) { + if top > maxTopParameter { + return nil, nil, fmt.Errorf("top accepts at maximum %d elements. Requested %d instead", maxTopParameter, top) + } + + uri := c.client.getEndpoint(tableServiceName, pathForTable(tableName), url.Values{}) + uri += fmt.Sprintf("?$top=%d", top) + if query != "" { + uri += fmt.Sprintf("&$filter=%s", url.QueryEscape(query)) + } + + if previousContToken != nil { + uri += fmt.Sprintf("&NextPartitionKey=%s&NextRowKey=%s", previousContToken.NextPartitionKey, previousContToken.NextRowKey) + } + + headers := c.getStandardHeaders() + + headers["Content-Length"] = "0" + + resp, err := c.client.execTable("GET", uri, headers, nil) + + contToken := extractContinuationTokenFromHeaders(resp.headers) + + if err != nil { + return nil, contToken, err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { + return nil, contToken, err + } + + retEntries, err := deserializeEntity(retType, resp.body) + if err != nil { + return nil, contToken, err + } + + return retEntries, contToken, nil +} + +// InsertEntity inserts an entity in the specified table. +// The function fails if there is an entity with the same +// PartitionKey and RowKey in the table. +func (c *TableServiceClient) InsertEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, false, "POST"); err != nil { + return checkRespCode(sc, []int{http.StatusCreated}) + } + + return err +} + +func (c *TableServiceClient) execTable(table AzureTable, entity TableEntity, specifyKeysInURL bool, method string) (int, error) { + uri := c.client.getEndpoint(tableServiceName, pathForTable(table), url.Values{}) + if specifyKeysInURL { + uri += fmt.Sprintf("(PartitionKey='%s',RowKey='%s')", url.QueryEscape(entity.PartitionKey()), url.QueryEscape(entity.RowKey())) + } + + headers := c.getStandardHeaders() + + var buf bytes.Buffer + + if err := injectPartitionAndRowKeys(entity, &buf); err != nil { + return 0, err + } + + headers["Content-Length"] = fmt.Sprintf("%d", buf.Len()) + + var err error + var resp *odataResponse + + resp, err = c.client.execTable(method, uri, headers, &buf) + + if err != nil { + return 0, err + } + + defer resp.body.Close() + + return resp.statusCode, nil +} + +// UpdateEntity updates the contents of an entity with the +// one passed as parameter. The function fails if there is no entity +// with the same PartitionKey and RowKey in the table. +func (c *TableServiceClient) UpdateEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, true, "PUT"); err != nil { + return checkRespCode(sc, []int{http.StatusNoContent}) + } + return err +} + +// MergeEntity merges the contents of an entity with the +// one passed as parameter. +// The function fails if there is no entity +// with the same PartitionKey and RowKey in the table. +func (c *TableServiceClient) MergeEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, true, "MERGE"); err != nil { + return checkRespCode(sc, []int{http.StatusNoContent}) + } + return err +} + +// DeleteEntityWithoutCheck deletes the entity matching by +// PartitionKey and RowKey. There is no check on IfMatch +// parameter so the entity is always deleted. +// The function fails if there is no entity +// with the same PartitionKey and RowKey in the table. +func (c *TableServiceClient) DeleteEntityWithoutCheck(table AzureTable, entity TableEntity) error { + return c.DeleteEntity(table, entity, "*") +} + +// DeleteEntity deletes the entity matching by +// PartitionKey, RowKey and ifMatch field. +// The function fails if there is no entity +// with the same PartitionKey and RowKey in the table or +// the ifMatch is different. +func (c *TableServiceClient) DeleteEntity(table AzureTable, entity TableEntity, ifMatch string) error { + uri := c.client.getEndpoint(tableServiceName, pathForTable(table), url.Values{}) + uri += fmt.Sprintf("(PartitionKey='%s',RowKey='%s')", url.QueryEscape(entity.PartitionKey()), url.QueryEscape(entity.RowKey())) + + headers := c.getStandardHeaders() + + headers["Content-Length"] = "0" + headers["If-Match"] = ifMatch + + resp, err := c.client.execTable("DELETE", uri, headers, nil) + + if err != nil { + return err + } + defer resp.body.Close() + + if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { + return err + } + + return nil +} + +// InsertOrReplaceEntity inserts an entity in the specified table +// or replaced the existing one. +func (c *TableServiceClient) InsertOrReplaceEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, true, "PUT"); err != nil { + return checkRespCode(sc, []int{http.StatusNoContent}) + } + return err +} + +// InsertOrMergeEntity inserts an entity in the specified table +// or merges the existing one. +func (c *TableServiceClient) InsertOrMergeEntity(table AzureTable, entity TableEntity) error { + var err error + + if sc, err := c.execTable(table, entity, true, "MERGE"); err != nil { + return checkRespCode(sc, []int{http.StatusNoContent}) + } + return err +} + +func injectPartitionAndRowKeys(entity TableEntity, buf *bytes.Buffer) error { + if err := json.NewEncoder(buf).Encode(entity); err != nil { + return err + } + + dec := make(map[string]interface{}) + if err := json.NewDecoder(buf).Decode(&dec); err != nil { + return err + } + + // Inject PartitionKey and RowKey + dec[partitionKeyNode] = entity.PartitionKey() + dec[rowKeyNode] = entity.RowKey() + + // Remove tagged fields + // The tag is defined in the const section + // This is useful to avoid storing the PartitionKey and RowKey twice. + numFields := reflect.ValueOf(entity).Elem().NumField() + for i := 0; i < numFields; i++ { + f := reflect.ValueOf(entity).Elem().Type().Field(i) + + if f.Tag.Get(tag) == tagIgnore { + // we must look for its JSON name in the dictionary + // as the user can rename it using a tag + jsonName := f.Name + if f.Tag.Get("json") != "" { + jsonName = f.Tag.Get("json") + } + delete(dec, jsonName) + } + } + + buf.Reset() + + if err := json.NewEncoder(buf).Encode(&dec); err != nil { + return err + } + + return nil +} + +func deserializeEntity(retType reflect.Type, reader io.Reader) ([]TableEntity, error) { + buf := new(bytes.Buffer) + + var ret getTableEntriesResponse + if err := json.NewDecoder(reader).Decode(&ret); err != nil { + return nil, err + } + + tEntries := make([]TableEntity, len(ret.Elements)) + + for i, entry := range ret.Elements { + + buf.Reset() + if err := json.NewEncoder(buf).Encode(entry); err != nil { + return nil, err + } + + dec := make(map[string]interface{}) + if err := json.NewDecoder(buf).Decode(&dec); err != nil { + return nil, err + } + + var pKey, rKey string + // strip pk and rk + for key, val := range dec { + switch key { + case partitionKeyNode: + pKey = val.(string) + case rowKeyNode: + rKey = val.(string) + } + } + + delete(dec, partitionKeyNode) + delete(dec, rowKeyNode) + + buf.Reset() + if err := json.NewEncoder(buf).Encode(dec); err != nil { + return nil, err + } + + // Create a empty retType instance + tEntries[i] = reflect.New(retType.Elem()).Interface().(TableEntity) + // Popolate it with the values + if err := json.NewDecoder(buf).Decode(&tEntries[i]); err != nil { + return nil, err + } + + // Reset PartitionKey and RowKey + tEntries[i].SetPartitionKey(pKey) + tEntries[i].SetRowKey(rKey) + } + + return tEntries, nil +} + +func extractContinuationTokenFromHeaders(h http.Header) *ContinuationToken { + ct := ContinuationToken{h.Get(continuationTokenPartitionKeyHeader), h.Get(continuationTokenRowHeader)} + + if ct.NextPartitionKey != "" && ct.NextRowKey != "" { + return &ct + } + return nil +} diff --git a/vendor/github.com/hashicorp/go-rootcerts/rootcerts_darwin_test.go b/vendor/github.com/hashicorp/go-rootcerts/rootcerts_darwin_test.go deleted file mode 100644 index 2129c156d1..0000000000 --- a/vendor/github.com/hashicorp/go-rootcerts/rootcerts_darwin_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package rootcerts - -import "testing" - -func TestSystemCAsOnDarwin(t *testing.T) { - _, err := LoadSystemCAs() - if err != nil { - t.Fatalf("Got error: %s", err) - } -} - -func TestCertKeychains(t *testing.T) { - keychains := certKeychains() - if len(keychains) != 3 { - t.Fatalf("Expected 3 keychains, got %#v", keychains) - } -} diff --git a/vendor/github.com/hashicorp/go-rootcerts/rootcerts_test.go b/vendor/github.com/hashicorp/go-rootcerts/rootcerts_test.go deleted file mode 100644 index 9634385882..0000000000 --- a/vendor/github.com/hashicorp/go-rootcerts/rootcerts_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package rootcerts - -import ( - "path/filepath" - "testing" -) - -const fixturesDir = "./test-fixtures" - -func TestConfigureTLSHandlesNil(t *testing.T) { - err := ConfigureTLS(nil, nil) - if err != nil { - t.Fatalf("err: %s", err) - } -} - -func TestLoadCACertsHandlesNil(t *testing.T) { - _, err := LoadCACerts(nil) - if err != nil { - t.Fatalf("err: %s", err) - } -} - -func TestLoadCACertsFromFile(t *testing.T) { - path := testFixture("cafile", "cacert.pem") - _, err := LoadCACerts(&Config{CAFile: path}) - if err != nil { - t.Fatalf("err: %s", err) - } -} - -func TestLoadCACertsFromDir(t *testing.T) { - path := testFixture("capath") - _, err := LoadCACerts(&Config{CAPath: path}) - if err != nil { - t.Fatalf("err: %s", err) - } -} - -func TestLoadCACertsFromDirWithSymlinks(t *testing.T) { - path := testFixture("capath-with-symlinks") - _, err := LoadCACerts(&Config{CAPath: path}) - if err != nil { - t.Fatalf("err: %s", err) - } -} - -func testFixture(n ...string) string { - parts := []string{fixturesDir} - parts = append(parts, n...) - return filepath.Join(parts...) -} diff --git a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/cafile/cacert.pem b/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/cafile/cacert.pem deleted file mode 100644 index 86d732f3dd..0000000000 --- a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/cafile/cacert.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIExDCCA6ygAwIBAgIJAJ7PV+3kJZqZMA0GCSqGSIb3DQEBBQUAMIGcMQswCQYD -VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xEjAQ -BgNVBAoTCUhhc2hpQ29ycD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FhJwYXVsQGhh -c2hpY29ycC5jb22CCQCez1ft5CWamTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEB -BQUAA4IBAQC4tFfxpB8xEk9ewb5CNhhac4oKwGths+oq45DjoNtlagDMmIs2bl18 -q45PIB7fuFkAz/YHcOL0UEOAiw4jbuROp9jacHxBV21lRLLmNlK1Llc3eNVvLJ38 -ud6/Skilv9XyC4JNk0P5KrghxR6SOGwRuYZNqF+tthf+Bp9wJvLyfqDuJfGBal7C -ezobMoh4tp8Dh1JeQlwvJcVt2k0UFJpa57MNr78c684Bq55ow+jd6wFG0XM0MMmy -u+QRgJEGfYuYDPFEO8C8IfRyrHuV7Ll9P6eyEEFCneznXY0yJc/Gn3ZcX7ANqJsc -ueMOWw/vUnonzxAFKW+I9U9ptyVSNMLY ------END CERTIFICATE----- diff --git a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath-with-symlinks/securetrust.pem b/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath-with-symlinks/securetrust.pem deleted file mode 120000 index dda0574d7f..0000000000 --- a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath-with-symlinks/securetrust.pem +++ /dev/null @@ -1 +0,0 @@ -../capath/securetrust.pem \ No newline at end of file diff --git a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath-with-symlinks/thawte.pem b/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath-with-symlinks/thawte.pem deleted file mode 120000 index 37ed4f01a4..0000000000 --- a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath-with-symlinks/thawte.pem +++ /dev/null @@ -1 +0,0 @@ -../capath/thawte.pem \ No newline at end of file diff --git a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath/securetrust.pem b/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath/securetrust.pem deleted file mode 100644 index 37400921e5..0000000000 --- a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath/securetrust.pem +++ /dev/null @@ -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ll/ -3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHfmbx8IVQr5Fiiu1cprp6poxkm -D5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZnMUFdAvnZyPS -CPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR -3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE= ------END CERTIFICATE----- diff --git a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath/thawte.pem b/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath/thawte.pem deleted file mode 100644 index 998460f1c2..0000000000 --- a/vendor/github.com/hashicorp/go-rootcerts/test-fixtures/capath/thawte.pem +++ /dev/null @@ -1,25 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCB -qTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMf -Q2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIw -MDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNV -BAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3MDAwMDAwWhcNMzYw -NzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5j -LjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYG -A1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl -IG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqG -SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCsoPD7gFnUnMekz52hWXMJEEUMDSxuaPFs -W0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ1CRfBsDMRJSUjQJib+ta -3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGcq/gcfomk -6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6 -Sk/KaAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94J -NqR32HuHUETVPm4pafs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBA -MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XP -r87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUFAAOCAQEAeRHAS7ORtvzw6WfU -DW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeEuzLlQRHAd9mz -YJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX -xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2 -/qxAeeWsEG89jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/ -LHbTY5xZ3Y+m4Q6gLkH3LpVHz7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7 -jVaMaA== ------END CERTIFICATE----- diff --git a/vendor/golang.org/x/crypto/ssh/handshake.go b/vendor/golang.org/x/crypto/ssh/handshake.go index 8854274f04..caf36f12f7 100644 --- a/vendor/golang.org/x/crypto/ssh/handshake.go +++ b/vendor/golang.org/x/crypto/ssh/handshake.go @@ -161,8 +161,12 @@ func (t *handshakeTransport) readOnePacket() ([]byte, error) { t.readSinceKex += uint64(len(p)) if debugHandshake { - msg, err := decode(p) - log.Printf("%s got %T %v (%v)", t.id(), msg, msg, err) + if p[0] == msgChannelData || p[0] == msgChannelExtendedData { + log.Printf("%s got data (packet %d bytes)", t.id(), len(p)) + } else { + msg, err := decode(p) + log.Printf("%s got %T %v (%v)", t.id(), msg, msg, err) + } } if p[0] != msgKexInit { return p, nil