mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-04 13:17:43 -06:00
6fe2703665
* Remove `make updatedeps` from Travis build. We'll follow up with more specific plans around dependency updating in subsequent PRs. * Update all `make` targets to set `GO15VENDOREXPERIMENT=1` and to filter out `/vendor/` from `./...` where appropriate. * Temporarily remove `vet` from the `make test` target until we can figure out how to get it to not vet `vendor/`. (Initial experimentation failed to yield the proper incantation.) Everything is pinned to current master, with the exception of: * Azure/azure-sdk-for-go which is pinned before the breaking change today * aws/aws-sdk-go which is pinned to the most recent tag The documentation still needs to be updated, which we can do in a follow up PR. The goal here is to unblock release.
72 lines
1.3 KiB
Go
72 lines
1.3 KiB
Go
package storage
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto/hmac"
|
|
"crypto/sha256"
|
|
"encoding/base64"
|
|
"encoding/xml"
|
|
"fmt"
|
|
"io"
|
|
"io/ioutil"
|
|
"net/http"
|
|
"net/url"
|
|
"time"
|
|
)
|
|
|
|
func (c Client) computeHmac256(message string) string {
|
|
h := hmac.New(sha256.New, c.accountKey)
|
|
h.Write([]byte(message))
|
|
return base64.StdEncoding.EncodeToString(h.Sum(nil))
|
|
}
|
|
|
|
func currentTimeRfc1123Formatted() string {
|
|
return timeRfc1123Formatted(time.Now().UTC())
|
|
}
|
|
|
|
func timeRfc1123Formatted(t time.Time) string {
|
|
return t.Format(http.TimeFormat)
|
|
}
|
|
|
|
func mergeParams(v1, v2 url.Values) url.Values {
|
|
out := url.Values{}
|
|
for k, v := range v1 {
|
|
out[k] = v
|
|
}
|
|
for k, v := range v2 {
|
|
vals, ok := out[k]
|
|
if ok {
|
|
vals = append(vals, v...)
|
|
out[k] = vals
|
|
} else {
|
|
out[k] = v
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
func prepareBlockListRequest(blocks []Block) string {
|
|
s := `<?xml version="1.0" encoding="utf-8"?><BlockList>`
|
|
for _, v := range blocks {
|
|
s += fmt.Sprintf("<%s>%s</%s>", v.Status, v.ID, v.Status)
|
|
}
|
|
s += `</BlockList>`
|
|
return s
|
|
}
|
|
|
|
func xmlUnmarshal(body io.Reader, v interface{}) error {
|
|
data, err := ioutil.ReadAll(body)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return xml.Unmarshal(data, v)
|
|
}
|
|
|
|
func xmlMarshal(v interface{}) (io.Reader, int, error) {
|
|
b, err := xml.Marshal(v)
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
return bytes.NewReader(b), len(b), nil
|
|
}
|