Skip to content

Commit

Permalink
[Tables] bump deps (#15350)
Browse files Browse the repository at this point in the history
* Sync eng/common directory with azure-sdk-tools for PR 1912 (#15314)

* Attempt to purge all vaults, managed HSMs

Reverts #1910. Vaults and managed HSMs are automatically purged on their purge date. The point was to purge them daily to preserve capacity. The default purge date is +90 days.

* Add timeout and more logging

* Pass required -Resource

* Fix log message

* Ensure the $Resource is correctly captured

Added comment to new code explaining why, since ScriptBlock.GetNewClosure() is not working as expected.

* Add -ErrorAction to Receive-Job

Worked without terminating when run locally, but failed on the first error in the AzDO agent.

* Use $using:r instead of creating ScriptBlock

More idiomatic for passing ScriptBlocks to jobs.

* Resolve PR feedback

* Change default DeleteAfterHours to 120

Resolves #1917

* Use the Az cmdlets built-in -AsJob

Co-authored-by: Heath Stewart <[email protected]>

* Fix query batch processing (#15319)

Co-authored-by: Wes Haggard <[email protected]>

* fix: three dots path not work in linux in build script (#15297)

* Release v56.3.0 1629350585 (#15323)

* Generated from specification/apimanagement/resource-manager/readme.md tag package-preview-2021-01 (commit hash: 30d1537f0c9aa49e6e04401b1d16f612b31231e7)

* Generated from specification/purview/resource-manager/readme.md tag package-2021-07-01 (commit hash: 30d1537f0c9aa49e6e04401b1d16f612b31231e7)

* v56.3.0

* fix

* Remove old unused update changelog script (#15326)

Co-authored-by: Wes Haggard <[email protected]>

* add clear output flag to build.ps1 (#15255)

* add clear output flag

* remove the path parameter and make sure the process-sdk function only runs in current directory

* change flag name

* [tools/generator] add automation and release command for track2 (#15271)

* [tools/generator] add automation and release command for track2

* add copyright and do gofmt

* Use semver to pump version, move git operation to repo package and fix some typo

* Add specfic version to release cmd, seperate package for automation and remove test config file

* add automation script and config for track2

* fix: three dots path not work in linux in build script

* fix: ln pwsh.exe to pwsh to run in linux

* fix: ignore dep check for go-git

* chore: label name change for track2

* fix: wrong package path result in empty git commit

* fix: repo addr replacement in autorest.md

* chore: move script to eng folder and change name

* fix: onboard generation need to replace NewClientMethod

* chore: change all naming from track2 to v2

* fix: add new build constraint

* fix: template compat with go 1.17 and change commit msg for release

* chore: add v2 to readme begin regex to support future change of `track2` naming

* chore: remove track2 naming

* fix: duplicated and wrong expression

* fix: add package title param to release cmd

* fix: ci

* Prevent ManagedIdentityCredential mutating GetToken arguments (#15331)

* [Azcore] bumps version of internal (#15347)

* bump internal to latest

* upgrading internal

* not the correct one

* changelog update

* [azidentity] bump azcore and internal dependencies (#15348)

* updating to latest core and identity

* trying to fix merge

* undoing changes to identity that should not be there

* more changes

* more changes

* removing a bunch more

* one last file

* formatting

* linting checks

* linting

* formatting

Co-authored-by: Azure SDK Bot <[email protected]>
Co-authored-by: Heath Stewart <[email protected]>
Co-authored-by: Wes Haggard <[email protected]>
Co-authored-by: tadelesh <[email protected]>
Co-authored-by: JiahuiPeng <[email protected]>
Co-authored-by: Arcturus <[email protected]>
Co-authored-by: Charles Lowell <[email protected]>
  • Loading branch information
8 people authored Aug 20, 2021
1 parent b1fe68c commit 088d5b0
Show file tree
Hide file tree
Showing 30 changed files with 632 additions and 402 deletions.
268 changes: 268 additions & 0 deletions sdk/internal/recording/recording.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
package recording

import (
"bytes"
"crypto/tls"
"crypto/x509"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
Expand All @@ -16,6 +20,7 @@ import (
"path/filepath"
"strconv"
"strings"
"testing"
"time"

"github.com/Azure/azure-sdk-for-go/sdk/internal/uuid"
Expand Down Expand Up @@ -433,3 +438,266 @@ var modeMap = map[RecordMode]recorder.Mode{
Live: recorder.ModeDisabled,
Playback: recorder.ModeReplaying,
}

var recordMode, _ = os.LookupEnv("AZURE_RECORD_MODE")
var ModeRecording = "record"
var ModePlayback = "playback"

var baseProxyURLSecure = "localhost:5001"
var baseProxyURL = "localhost:5000"

var recordingId string
var IdHeader = "x-recording-id"
var ModeHeader = "x-recording-mode"
var UpstreamUriHeader = "x-recording-upstream-base-uri"

var tr = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
var client = http.Client{
Transport: tr,
}

type RecordingOptions struct {
MaxRetries int32
UseHTTPS bool
Host string
Scheme string
}

func defaultOptions() *RecordingOptions {
return &RecordingOptions{
MaxRetries: 0,
UseHTTPS: true,
Host: "localhost:5001",
Scheme: "https",
}
}

func (r RecordingOptions) HostScheme() string {
if r.UseHTTPS {
return "https://localhost:5001"
}
return "http://localhost:5000"
}

func getTestId(pathToRecordings string, t *testing.T) string {
return pathToRecordings + "/recordings/" + t.Name() + ".json"
}

func StartRecording(t *testing.T, pathToRecordings string, options *RecordingOptions) error {
if options == nil {
options = defaultOptions()
}
if recordMode == "" {
t.Log("AZURE_RECORD_MODE was not set, options are \"record\" or \"playback\". \nDefaulting to playback")
recordMode = "playback"
} else {
t.Log("AZURE_RECORD_MODE: ", recordMode)
}
testId := getTestId(pathToRecordings, t)

url := fmt.Sprintf("%v/%v/start", options.HostScheme(), recordMode)

req, err := http.NewRequest("POST", url, nil)
if err != nil {
return err
}

req.Header.Set("x-recording-file", testId)

resp, err := client.Do(req)
if err != nil {
return err
}
recordingId = resp.Header.Get(IdHeader)
return nil
}

func StopRecording(t *testing.T, options *RecordingOptions) error {
if options == nil {
options = defaultOptions()
}

url := fmt.Sprintf("%v/%v/stop", options.HostScheme(), recordMode)
req, err := http.NewRequest("POST", url, nil)
if err != nil {
return err
}
if recordingId == "" {
return errors.New("Recording ID was never set. Did you call StartRecording?")
}
req.Header.Set("x-recording-id", recordingId)
_, err = client.Do(req)
if err != nil {
t.Errorf(err.Error())
}
return nil
}

func AddUriSanitizer(replacement, regex string, options *RecordingOptions) error {
if options == nil {
options = defaultOptions()
}
url := fmt.Sprintf("%v/Admin/AddSanitizer", options.HostScheme())
req, err := http.NewRequest("POST", url, nil)
if err != nil {
return err
}
req.Header.Set("x-abstraction-identifier", "UriRegexSanitizer")
bodyContent := map[string]string{
"value": replacement,
"regex": regex,
}
marshalled, err := json.Marshal(bodyContent)
if err != nil {
return err
}
req.Body = ioutil.NopCloser(bytes.NewReader(marshalled))
req.ContentLength = int64(len(marshalled))
_, err = client.Do(req)
return err
}

func (o *RecordingOptions) Init() {
if o.MaxRetries != 0 {
o.MaxRetries = 0
}
if o.UseHTTPS {
o.Host = baseProxyURLSecure
o.Scheme = "https"
} else {
o.Host = baseProxyURL
o.Scheme = "http"
}
}

// type recordingPolicy struct {
// options RecordingOptions
// }

// func NewRecordingPolicy(o *RecordingOptions) azcore.Policy {
// if o == nil {
// o = &RecordingOptions{}
// }
// p := &recordingPolicy{options: *o}
// p.options.init()
// return p
// }

// func (p *recordingPolicy) Do(req *azcore.Request) (resp *azcore.Response, err error) {
// originalURLHost := req.URL.Host
// req.URL.Scheme = "https"
// req.URL.Host = p.options.host
// req.Host = p.options.host

// req.Header.Set(UpstreamUriHeader, fmt.Sprintf("%v://%v", p.options.scheme, originalURLHost))
// req.Header.Set(ModeHeader, recordMode)
// req.Header.Set(IdHeader, recordingId)

// return req.Next()
// }

// This looks up an environment variable and if it is not found, returns the recordedValue
func GetEnvVariable(t *testing.T, varName string, recordedValue string) string {
val, ok := os.LookupEnv(varName)
if !ok {
t.Logf("Could not find environment variable: %v", varName)
return recordedValue
}
return val
}

func LiveOnly(t *testing.T) {
if GetRecordMode() != ModeRecording {
t.Skip("Live Test Only")
}
}

// Function for sleeping during a test for `duration` seconds. This method will only execute when
// AZURE_RECORD_MODE = "record", if a test is running in playback this will be a noop.
func Sleep(duration int) {
if GetRecordMode() == ModeRecording {
time.Sleep(time.Duration(duration) * time.Second)
}
}

func GetRecordingId() string {
return recordingId
}

func GetRecordMode() string {
return recordMode
}

func InPlayback() bool {
return GetRecordMode() == ModePlayback
}

func InRecord() bool {
return GetRecordMode() == ModeRecording
}

// type FakeCredential struct {
// accountName string
// accountKey string
// }

// func NewFakeCredential(accountName, accountKey string) *FakeCredential {
// return &FakeCredential{
// accountName: accountName,
// accountKey: accountKey,
// }
// }

// func (f *FakeCredential) AuthenticationPolicy(azcore.AuthenticationPolicyOptions) azcore.Policy {
// return azcore.PolicyFunc(func(req *azcore.Request) (*azcore.Response, error) {
// authHeader := strings.Join([]string{"Authorization ", f.accountName, ":", f.accountKey}, "")
// req.Request.Header.Set(azcore.HeaderAuthorization, authHeader)
// return req.Next()
// })
// }

func getRootCas() (*x509.CertPool, error) {
localFile, ok := os.LookupEnv("PROXY_CERT")

rootCAs, err := x509.SystemCertPool()
if err != nil {
rootCAs = x509.NewCertPool()
}

if !ok {
fmt.Println("Could not find path to proxy certificate, set the environment variable 'PROXY_CERT' to the location of your certificate")
return rootCAs, nil
}

cert, err := ioutil.ReadFile(localFile)
if err != nil {
fmt.Println("error opening cert file")
return nil, err
}

if ok := rootCAs.AppendCertsFromPEM(cert); !ok {
fmt.Println("No certs appended, using system certs only")
}

return rootCAs, nil
}

func GetHTTPClient() (*http.Client, error) {
transport := http.DefaultTransport.(*http.Transport).Clone()

rootCAs, err := getRootCas()
if err != nil {
return nil, err
}

transport.TLSClientConfig.RootCAs = rootCAs
transport.TLSClientConfig.MinVersion = tls.VersionTLS12
transport.TLSClientConfig.InsecureSkipVerify = true

defaultHttpClient := &http.Client{
Transport: transport,
}
return defaultHttpClient, nil
}
9 changes: 9 additions & 0 deletions sdk/tables/aztable/consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package aztable

const (
headerXmsDate = "x-ms-date"
headerAuthorization = "Authorization"
)
3 changes: 2 additions & 1 deletion sdk/tables/aztable/cosmos_patch_transform_policy.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.13
// +build go1.13

// Copyright (c) Microsoft Corporation. All rights reserved.
Expand All @@ -14,7 +15,7 @@ import (
// cosmosPatchTransformPolicy transforms PATCH requests into POST requests with the "X-HTTP-Method":"MERGE" header set.
type cosmosPatchTransformPolicy struct{}

func (p cosmosPatchTransformPolicy) Do(req *azcore.Request) (*azcore.Response, error) {
func (p cosmosPatchTransformPolicy) Do(req *azcore.Request) (*http.Response, error) {
transformPatchToCosmosPost(req)
return req.Next()
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/tables/aztable/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ var errInvalidUpdateMode = errors.New("invalid EntityUpdateMode")

func checkEntityForPkRk(entity *map[string]interface{}, err error) error {
if _, ok := (*entity)[partitionKey]; !ok {
return partitionKeyRowKeyError
return errPartitionKeyRowKeyError
}

if _, ok := (*entity)[rowKey]; !ok {
return partitionKeyRowKeyError
return errPartitionKeyRowKeyError
}

return err
Expand Down
11 changes: 4 additions & 7 deletions sdk/tables/aztable/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ module github.com/Azure/azure-sdk-for-go/sdk/tables/aztable
go 1.13

replace github.com/Azure/azure-sdk-for-go/sdk/internal => ../../internal
replace github.com/Azure/azure-sdk-for-go/sdk/azidentity => ../../azidentity
replace github.com/Azure/azure-sdk-for-go/sdk/azcore => ../../azcore

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.9.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1
github.com/Azure/azure-sdk-for-go/sdk/to v0.1.4 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.18.1
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.9.3
github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0
github.com/Azure/azure-sdk-for-go/sdk/to v0.1.4
github.com/stretchr/testify v1.7.0
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
19 changes: 6 additions & 13 deletions sdk/tables/aztable/go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.14.0/go.mod h1:pElNP+u99BvCZD+0jOlhI9OC/NB2IDTOTGZOZH0Qhq8=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.1 h1:yQw8Ah26gBP4dv66ZNjZpRBRV+gaHH/0TLn1taU4FZ4=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.1/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 h1:UC4vfOhW2l0f2QOCQpOxJS4/K6oKFy2tQZE+uWU1MEo=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.9.2 h1:3W8umQHRg0DXV5KvmbqU43uFi8MKvqLHQCE8L8v6Xds=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.9.2/go.mod h1:acANgl9stsT5xflESXKjZx4rhZJSr0TGgTDYY0xJPIE=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.18.1 h1:BxW0zeNz9VbxtaeyuwAsgZ2WgCG7wwjb17H3f5czlp4=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.18.1/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.9.3 h1:xxhrKdJQHnbzyquwt4GJuK0xGYIchlxtrbOCy1RcXyg=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.9.3/go.mod h1:uuSIs9Jj5y1WfsKhk9xGaEzyu/5SEmdKwY3Oi0UK59M=
github.com/Azure/azure-sdk-for-go/sdk/to v0.1.4 h1:3w4gk+uYOwplGhID1fDP305/8bI5Aug3URoC1V493KU=
github.com/Azure/azure-sdk-for-go/sdk/to v0.1.4/go.mod h1:UL/d4lvWAzSJUuX+19uKdN0ktyjoOyQhgY+HWNgtIYI=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
Expand All @@ -16,7 +13,6 @@ github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7T
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
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/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
Expand All @@ -26,11 +22,8 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNm
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/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-20210510120150-4163338589ed h1:p9UgmWI9wKpfYmgaV/IZKGdXc5qEK45tDwwwDyjS26I=
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A=
golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
Loading

0 comments on commit 088d5b0

Please sign in to comment.