Commit 12284c98 authored by andyzhangx's avatar andyzhangx

upgrade azure go sdk for azure file premium support

update azure sdk for azure file premium support update azure sdk to support azure file premium update bazel
parent a29b093a
...@@ -36,33 +36,33 @@ ...@@ -36,33 +36,33 @@
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute", "ImportPath": "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute",
"Comment": "v19.0.0", "Comment": "v21.1.0",
"Rev": "520918e6c8e8e1064154f51d13e02fad92b287b8" "Rev": "6d20bdbae88c06c36d72eb512295417693bfdf4e"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry", "ImportPath": "github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry",
"Comment": "v19.0.0", "Comment": "v21.1.0",
"Rev": "520918e6c8e8e1064154f51d13e02fad92b287b8" "Rev": "6d20bdbae88c06c36d72eb512295417693bfdf4e"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network", "ImportPath": "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network",
"Comment": "v19.0.0", "Comment": "v21.1.0",
"Rev": "520918e6c8e8e1064154f51d13e02fad92b287b8" "Rev": "6d20bdbae88c06c36d72eb512295417693bfdf4e"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage", "ImportPath": "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage",
"Comment": "v19.0.0", "Comment": "v21.1.0",
"Rev": "520918e6c8e8e1064154f51d13e02fad92b287b8" "Rev": "6d20bdbae88c06c36d72eb512295417693bfdf4e"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/storage", "ImportPath": "github.com/Azure/azure-sdk-for-go/storage",
"Comment": "v19.0.0", "Comment": "v21.1.0",
"Rev": "520918e6c8e8e1064154f51d13e02fad92b287b8" "Rev": "6d20bdbae88c06c36d72eb512295417693bfdf4e"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/version", "ImportPath": "github.com/Azure/azure-sdk-for-go/version",
"Comment": "v19.0.0", "Comment": "v21.1.0",
"Rev": "520918e6c8e8e1064154f51d13e02fad92b287b8" "Rev": "6d20bdbae88c06c36d72eb512295417693bfdf4e"
}, },
{ {
"ImportPath": "github.com/Azure/go-ansiterm", "ImportPath": "github.com/Azure/go-ansiterm",
...@@ -74,38 +74,43 @@ ...@@ -74,38 +74,43 @@
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest", "ImportPath": "github.com/Azure/go-autorest/autorest",
"Comment": "v10.14.0", "Comment": "v10.15.4",
"Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/adal", "ImportPath": "github.com/Azure/go-autorest/autorest/adal",
"Comment": "v10.14.0", "Comment": "v10.15.4",
"Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/azure", "ImportPath": "github.com/Azure/go-autorest/autorest/azure",
"Comment": "v10.14.0", "Comment": "v10.15.4",
"Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/date", "ImportPath": "github.com/Azure/go-autorest/autorest/date",
"Comment": "v10.14.0", "Comment": "v10.15.4",
"Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/to", "ImportPath": "github.com/Azure/go-autorest/autorest/to",
"Comment": "v10.14.0", "Comment": "v10.15.4",
"Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/validation", "ImportPath": "github.com/Azure/go-autorest/autorest/validation",
"Comment": "v10.14.0", "Comment": "v10.15.4",
"Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed"
},
{
"ImportPath": "github.com/Azure/go-autorest/logger",
"Comment": "v10.15.4",
"Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/version", "ImportPath": "github.com/Azure/go-autorest/version",
"Comment": "v10.14.0", "Comment": "v10.15.4",
"Rev": "bca49d5b51a50dc5bb17bbf6204c711c6dbded06" "Rev": "a88c19ef2016e095f0b6c3b451074b4663f53bed"
}, },
{ {
"ImportPath": "github.com/GeertJohan/go.rice", "ImportPath": "github.com/GeertJohan/go.rice",
......
...@@ -60,7 +60,7 @@ go_library( ...@@ -60,7 +60,7 @@ go_library(
"//staging/src/k8s.io/cloud-provider:go_default_library", "//staging/src/k8s.io/cloud-provider:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/storage:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/storage:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/adal:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest/adal:go_default_library",
...@@ -103,7 +103,7 @@ go_test( ...@@ -103,7 +103,7 @@ go_test(
"//staging/src/k8s.io/cloud-provider:go_default_library", "//staging/src/k8s.io/cloud-provider:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library",
......
...@@ -27,7 +27,7 @@ import ( ...@@ -27,7 +27,7 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
azstorage "github.com/Azure/azure-sdk-for-go/storage" azstorage "github.com/Azure/azure-sdk-for-go/storage"
"github.com/Azure/go-autorest/autorest/to" "github.com/Azure/go-autorest/autorest/to"
"github.com/golang/glog" "github.com/golang/glog"
......
...@@ -24,7 +24,7 @@ import ( ...@@ -24,7 +24,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network" "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/adal" "github.com/Azure/go-autorest/autorest/adal"
"github.com/golang/glog" "github.com/golang/glog"
......
...@@ -31,7 +31,7 @@ import ( ...@@ -31,7 +31,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute"
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network" "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/to" "github.com/Azure/go-autorest/autorest/to"
) )
......
...@@ -24,7 +24,7 @@ import ( ...@@ -24,7 +24,7 @@ import (
"strings" "strings"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
......
...@@ -19,7 +19,7 @@ package azure ...@@ -19,7 +19,7 @@ package azure
import ( import (
"fmt" "fmt"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
"github.com/golang/glog" "github.com/golang/glog"
) )
......
...@@ -19,7 +19,7 @@ package azure ...@@ -19,7 +19,7 @@ package azure
import ( import (
"testing" "testing"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
) )
func TestCreateFileShare(t *testing.T) { func TestCreateFileShare(t *testing.T) {
......
...@@ -20,7 +20,7 @@ import ( ...@@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
"github.com/Azure/go-autorest/autorest/to" "github.com/Azure/go-autorest/autorest/to"
"github.com/golang/glog" "github.com/golang/glog"
) )
......
...@@ -20,7 +20,7 @@ import ( ...@@ -20,7 +20,7 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
) )
func TestGetStorageAccessKeys(t *testing.T) { func TestGetStorageAccessKeys(t *testing.T) {
......
...@@ -40,7 +40,7 @@ go_library( ...@@ -40,7 +40,7 @@ go_library(
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//staging/src/k8s.io/cloud-provider:go_default_library", "//staging/src/k8s.io/cloud-provider:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage:go_default_library",
"//vendor/github.com/golang/glog:go_default_library", "//vendor/github.com/golang/glog:go_default_library",
], ],
) )
...@@ -76,7 +76,7 @@ go_test( ...@@ -76,7 +76,7 @@ go_test(
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/client-go/util/testing:go_default_library", "//staging/src/k8s.io/client-go/util/testing:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:go_default_library",
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library",
], ],
......
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
"path/filepath" "path/filepath"
libstrings "strings" libstrings "strings"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
......
...@@ -24,7 +24,7 @@ import ( ...@@ -24,7 +24,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/mount"
......
...@@ -22,7 +22,7 @@ import ( ...@@ -22,7 +22,7 @@ import (
"strings" "strings"
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage" "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage"
"github.com/golang/glog" "github.com/golang/glog"
"k8s.io/api/core/v1" "k8s.io/api/core/v1"
......
...@@ -18,11 +18,12 @@ filegroup( ...@@ -18,11 +18,12 @@ filegroup(
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:all-srcs", "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-04-01/compute:all-srcs",
"//vendor/github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry:all-srcs", "//vendor/github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry:all-srcs",
"//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network:all-srcs", "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2017-09-01/network:all-srcs",
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage:all-srcs", "//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage:all-srcs",
"//vendor/github.com/Azure/azure-sdk-for-go/storage:all-srcs", "//vendor/github.com/Azure/azure-sdk-for-go/storage:all-srcs",
"//vendor/github.com/Azure/azure-sdk-for-go/version:all-srcs", "//vendor/github.com/Azure/azure-sdk-for-go/version:all-srcs",
"//vendor/github.com/Azure/go-ansiterm:all-srcs", "//vendor/github.com/Azure/go-ansiterm:all-srcs",
"//vendor/github.com/Azure/go-autorest/autorest:all-srcs", "//vendor/github.com/Azure/go-autorest/autorest:all-srcs",
"//vendor/github.com/Azure/go-autorest/logger:all-srcs",
"//vendor/github.com/Azure/go-autorest/version:all-srcs", "//vendor/github.com/Azure/go-autorest/version:all-srcs",
"//vendor/github.com/GeertJohan/go.rice:all-srcs", "//vendor/github.com/GeertJohan/go.rice:all-srcs",
"//vendor/github.com/JeffAshton/win_pdh:all-srcs", "//vendor/github.com/JeffAshton/win_pdh:all-srcs",
......
...@@ -798,84 +798,6 @@ func PossibleVirtualMachineSizeTypesValues() []VirtualMachineSizeTypes { ...@@ -798,84 +798,6 @@ func PossibleVirtualMachineSizeTypesValues() []VirtualMachineSizeTypes {
// AccessURI a disk access SAS uri. // AccessURI a disk access SAS uri.
type AccessURI struct { type AccessURI struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
// AccessURIOutput - Operation output data (raw JSON)
*AccessURIOutput `json:"properties,omitempty"`
}
// MarshalJSON is the custom marshaler for AccessURI.
func (au AccessURI) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if au.AccessURIOutput != nil {
objectMap["properties"] = au.AccessURIOutput
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AccessURI struct.
func (au *AccessURI) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "properties":
if v != nil {
var accessURIOutput AccessURIOutput
err = json.Unmarshal(*v, &accessURIOutput)
if err != nil {
return err
}
au.AccessURIOutput = &accessURIOutput
}
}
}
return nil
}
// AccessURIOutput azure properties, including output.
type AccessURIOutput struct {
// AccessURIRaw - Operation output data (raw JSON)
*AccessURIRaw `json:"output,omitempty"`
}
// MarshalJSON is the custom marshaler for AccessURIOutput.
func (auo AccessURIOutput) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if auo.AccessURIRaw != nil {
objectMap["output"] = auo.AccessURIRaw
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for AccessURIOutput struct.
func (auo *AccessURIOutput) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "output":
if v != nil {
var accessURIRaw AccessURIRaw
err = json.Unmarshal(*v, &accessURIRaw)
if err != nil {
return err
}
auo.AccessURIRaw = &accessURIRaw
}
}
}
return nil
}
// AccessURIRaw a disk access SAS uri.
type AccessURIRaw struct {
// AccessSAS - A SAS uri for accessing a disk. // AccessSAS - A SAS uri for accessing a disk.
AccessSAS *string `json:"accessSAS,omitempty"` AccessSAS *string `json:"accessSAS,omitempty"`
} }
...@@ -1290,7 +1212,7 @@ type DataDisk struct { ...@@ -1290,7 +1212,7 @@ type DataDisk struct {
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"` WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
// CreateOption - Specifies how the virtual machine should be created.<br><br> Possible values are:<br><br> **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.<br><br> **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach' // CreateOption - Specifies how the virtual machine should be created.<br><br> Possible values are:<br><br> **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.<br><br> **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"` CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
// DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. <br><br> This value cannot be larger than 1023 GB // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. <br><br> This value cannot be larger than 1023 GB
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// ManagedDisk - The managed disk parameters. // ManagedDisk - The managed disk parameters.
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"` ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
...@@ -2718,7 +2640,7 @@ type OSDisk struct { ...@@ -2718,7 +2640,7 @@ type OSDisk struct {
WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"` WriteAcceleratorEnabled *bool `json:"writeAcceleratorEnabled,omitempty"`
// CreateOption - Specifies how the virtual machine should be created.<br><br> Possible values are:<br><br> **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.<br><br> **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach' // CreateOption - Specifies how the virtual machine should be created.<br><br> Possible values are:<br><br> **Attach** \u2013 This value is used when you are using a specialized disk to create the virtual machine.<br><br> **FromImage** \u2013 This value is used when you are using an image to create the virtual machine. If you are using a platform image, you also use the imageReference element described above. If you are using a marketplace image, you also use the plan element previously described. Possible values include: 'DiskCreateOptionTypesFromImage', 'DiskCreateOptionTypesEmpty', 'DiskCreateOptionTypesAttach'
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"` CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
// DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the name of the disk in a virtual machine image. <br><br> This value cannot be larger than 1023 GB // DiskSizeGB - Specifies the size of an empty data disk in gigabytes. This element can be used to overwrite the size of the disk in a virtual machine image. <br><br> This value cannot be larger than 1023 GB
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
// ManagedDisk - The managed disk parameters. // ManagedDisk - The managed disk parameters.
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"` ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
......
...@@ -441,8 +441,10 @@ type ImportImageParameters struct { ...@@ -441,8 +441,10 @@ type ImportImageParameters struct {
// ImportSource ... // ImportSource ...
type ImportSource struct { type ImportSource struct {
// ResourceID - The resource identifier of the target Azure Container Registry. // ResourceID - The resource identifier of the source Azure Container Registry.
ResourceID *string `json:"resourceId,omitempty"` ResourceID *string `json:"resourceId,omitempty"`
// RegistryURI - The address of the source registry.
RegistryURI *string `json:"registryUri,omitempty"`
// SourceImage - Repository name of the source image. // SourceImage - Repository name of the source image.
// Specify an image by repository ('hello-world'). This will use the 'latest' tag. // Specify an image by repository ('hello-world'). This will use the 'latest' tag.
// Specify an image by tag ('hello-world:latest'). // Specify an image by tag ('hello-world:latest').
......
...@@ -372,9 +372,7 @@ func (client RegistriesClient) ImportImage(ctx context.Context, resourceGroupNam ...@@ -372,9 +372,7 @@ func (client RegistriesClient) ImportImage(ctx context.Context, resourceGroupNam
{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
{TargetValue: parameters, {TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Source", Name: validation.Null, Rule: true, Constraints: []validation.Constraint{{Target: "parameters.Source", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Source.ResourceID", Name: validation.Null, Rule: true, Chain: nil}, Chain: []validation.Constraint{{Target: "parameters.Source.SourceImage", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
{Target: "parameters.Source.SourceImage", Name: validation.Null, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewError("containerregistry.RegistriesClient", "ImportImage", err.Error()) return result, validation.NewError("containerregistry.RegistriesClient", "ImportImage", err.Error())
} }
......
...@@ -4,15 +4,17 @@ go_library( ...@@ -4,15 +4,17 @@ go_library(
name = "go_default_library", name = "go_default_library",
srcs = [ srcs = [
"accounts.go", "accounts.go",
"blobcontainers.go",
"client.go", "client.go",
"managementpolicies.go",
"models.go", "models.go",
"operations.go", "operations.go",
"skus.go", "skus.go",
"usage.go", "usages.go",
"version.go", "version.go",
], ],
importmap = "k8s.io/kubernetes/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage", importmap = "k8s.io/kubernetes/vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage",
importpath = "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage", importpath = "github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2018-07-01/storage",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//vendor/github.com/Azure/azure-sdk-for-go/version:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/version:go_default_library",
......
// Package storage implements the Azure ARM Storage service API version 2017-10-01. // Package storage implements the Azure ARM Storage service API version .
// //
// The Azure Storage Management API. // The Azure Storage Management API.
package storage package storage
......
...@@ -64,7 +64,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe ...@@ -64,7 +64,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe
// ListPreparer prepares the List request. // ListPreparer prepares the List request.
func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
const APIVersion = "2017-10-01" const APIVersion = "2018-07-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": APIVersion, "api-version": APIVersion,
} }
......
...@@ -21,6 +21,7 @@ import ( ...@@ -21,6 +21,7 @@ import (
"context" "context"
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http" "net/http"
) )
...@@ -41,6 +42,12 @@ func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient ...@@ -41,6 +42,12 @@ func NewSkusClientWithBaseURI(baseURI string, subscriptionID string) SkusClient
// List lists the available SKUs supported by Microsoft.Storage for given subscription. // List lists the available SKUs supported by Microsoft.Storage for given subscription.
func (client SkusClient) List(ctx context.Context) (result SkuListResult, err error) { func (client SkusClient) List(ctx context.Context) (result SkuListResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: client.SubscriptionID,
Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
return result, validation.NewError("storage.SkusClient", "List", err.Error())
}
req, err := client.ListPreparer(ctx) req, err := client.ListPreparer(ctx)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "storage.SkusClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.SkusClient", "List", nil, "Failure preparing request")
...@@ -68,7 +75,7 @@ func (client SkusClient) ListPreparer(ctx context.Context) (*http.Request, error ...@@ -68,7 +75,7 @@ func (client SkusClient) ListPreparer(ctx context.Context) (*http.Request, error
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-10-01" const APIVersion = "2018-07-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": APIVersion, "api-version": APIVersion,
} }
......
...@@ -21,54 +21,64 @@ import ( ...@@ -21,54 +21,64 @@ import (
"context" "context"
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http" "net/http"
) )
// UsageClient is the the Azure Storage Management API. // UsagesClient is the the Azure Storage Management API.
type UsageClient struct { type UsagesClient struct {
BaseClient BaseClient
} }
// NewUsageClient creates an instance of the UsageClient client. // NewUsagesClient creates an instance of the UsagesClient client.
func NewUsageClient(subscriptionID string) UsageClient { func NewUsagesClient(subscriptionID string) UsagesClient {
return NewUsageClientWithBaseURI(DefaultBaseURI, subscriptionID) return NewUsagesClientWithBaseURI(DefaultBaseURI, subscriptionID)
} }
// NewUsageClientWithBaseURI creates an instance of the UsageClient client. // NewUsagesClientWithBaseURI creates an instance of the UsagesClient client.
func NewUsageClientWithBaseURI(baseURI string, subscriptionID string) UsageClient { func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesClient {
return UsageClient{NewWithBaseURI(baseURI, subscriptionID)} return UsagesClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// List gets the current usage count and the limit for the resources under the subscription. // ListByLocation gets the current usage count and the limit for the resources of the location under the subscription.
func (client UsageClient) List(ctx context.Context) (result UsageListResult, err error) { // Parameters:
req, err := client.ListPreparer(ctx) // location - the location of the Azure Storage resource.
func (client UsagesClient) ListByLocation(ctx context.Context, location string) (result UsageListResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: client.SubscriptionID,
Constraints: []validation.Constraint{{Target: "client.SubscriptionID", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
return result, validation.NewError("storage.UsagesClient", "ListByLocation", err.Error())
}
req, err := client.ListByLocationPreparer(ctx, location)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "storage.UsageClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.UsagesClient", "ListByLocation", nil, "Failure preparing request")
return return
} }
resp, err := client.ListSender(req) resp, err := client.ListByLocationSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "storage.UsageClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.UsagesClient", "ListByLocation", resp, "Failure sending request")
return return
} }
result, err = client.ListResponder(resp) result, err = client.ListByLocationResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "storage.UsageClient", "List", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "storage.UsagesClient", "ListByLocation", resp, "Failure responding to request")
} }
return return
} }
// ListPreparer prepares the List request. // ListByLocationPreparer prepares the ListByLocation request.
func (client UsageClient) ListPreparer(ctx context.Context) (*http.Request, error) { func (client UsagesClient) ListByLocationPreparer(ctx context.Context, location string) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"location": autorest.Encode("path", location),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-10-01" const APIVersion = "2018-07-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": APIVersion, "api-version": APIVersion,
} }
...@@ -76,21 +86,21 @@ func (client UsageClient) ListPreparer(ctx context.Context) (*http.Request, erro ...@@ -76,21 +86,21 @@ func (client UsageClient) ListPreparer(ctx context.Context) (*http.Request, erro
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
autorest.AsGet(), autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI), autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages", pathParameters), autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages", pathParameters),
autorest.WithQueryParameters(queryParameters)) autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx)) return preparer.Prepare((&http.Request{}).WithContext(ctx))
} }
// ListSender sends the List request. The method will close the // ListByLocationSender sends the ListByLocation request. The method will close the
// http.Response Body if it receives an error. // http.Response Body if it receives an error.
func (client UsageClient) ListSender(req *http.Request) (*http.Response, error) { func (client UsagesClient) ListByLocationSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req, return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client)) azure.DoRetryWithRegistration(client.Client))
} }
// ListResponder handles the response to the List request. The method always // ListByLocationResponder handles the response to the ListByLocation request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client UsageClient) ListResponder(resp *http.Response) (result UsageListResult, err error) { func (client UsagesClient) ListByLocationResponder(resp *http.Response) (result UsageListResult, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
......
...@@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" ...@@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version"
// UserAgent returns the UserAgent string to use when sending http.Requests. // UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string { func UserAgent() string {
return "Azure-SDK-For-Go/" + version.Number + " storage/2017-10-01" return "Azure-SDK-For-Go/" + version.Number + " storage/2018-07-01"
} }
// Version returns the semantic version (see http://semver.org) of the client. // Version returns the semantic version (see http://semver.org) of the client.
......
...@@ -18,4 +18,4 @@ package version ...@@ -18,4 +18,4 @@ package version
// Changes may cause incorrect behavior and will be lost if the code is regenerated. // Changes may cause incorrect behavior and will be lost if the code is regenerated.
// Number contains the semantic version of this SDK. // Number contains the semantic version of this SDK.
const Number = "v19.0.0" const Number = "v21.1.0"
...@@ -21,6 +21,7 @@ go_library( ...@@ -21,6 +21,7 @@ go_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//vendor/github.com/Azure/go-autorest/autorest/adal:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest/adal:go_default_library",
"//vendor/github.com/Azure/go-autorest/logger:go_default_library",
"//vendor/github.com/Azure/go-autorest/version:go_default_library", "//vendor/github.com/Azure/go-autorest/version:go_default_library",
], ],
) )
......
...@@ -119,7 +119,10 @@ func (f *Future) Done(sender autorest.Sender) (bool, error) { ...@@ -119,7 +119,10 @@ func (f *Future) Done(sender autorest.Sender) (bool, error) {
if err := f.pt.updatePollingState(f.pt.provisioningStateApplicable()); err != nil { if err := f.pt.updatePollingState(f.pt.provisioningStateApplicable()); err != nil {
return false, err return false, err
} }
if err := f.pt.updateHeaders(); err != nil { if err := f.pt.initPollingMethod(); err != nil {
return false, err
}
if err := f.pt.updatePollingMethod(); err != nil {
return false, err return false, err
} }
return f.pt.hasTerminated(), f.pt.pollingError() return f.pt.hasTerminated(), f.pt.pollingError()
...@@ -264,7 +267,7 @@ type pollingTracker interface { ...@@ -264,7 +267,7 @@ type pollingTracker interface {
// these methods can differ per tracker // these methods can differ per tracker
// checks the response headers and status code to determine the polling mechanism // checks the response headers and status code to determine the polling mechanism
updateHeaders() error updatePollingMethod() error
// checks the response for tracker-specific error conditions // checks the response for tracker-specific error conditions
checkForErrors() error checkForErrors() error
...@@ -274,6 +277,10 @@ type pollingTracker interface { ...@@ -274,6 +277,10 @@ type pollingTracker interface {
// methods common to all trackers // methods common to all trackers
// initializes a tracker's polling URL and method, called for each iteration.
// these values can be overridden by each polling tracker as required.
initPollingMethod() error
// initializes the tracker's internal state, call this when the tracker is created // initializes the tracker's internal state, call this when the tracker is created
initializeState() error initializeState() error
...@@ -348,6 +355,10 @@ func (pt *pollingTrackerBase) initializeState() error { ...@@ -348,6 +355,10 @@ func (pt *pollingTrackerBase) initializeState() error {
case http.StatusOK: case http.StatusOK:
if ps := pt.getProvisioningState(); ps != nil { if ps := pt.getProvisioningState(); ps != nil {
pt.State = *ps pt.State = *ps
if pt.hasFailed() {
pt.updateErrorFromResponse()
return pt.pollingError()
}
} else { } else {
pt.State = operationSucceeded pt.State = operationSucceeded
} }
...@@ -364,8 +375,9 @@ func (pt *pollingTrackerBase) initializeState() error { ...@@ -364,8 +375,9 @@ func (pt *pollingTrackerBase) initializeState() error {
default: default:
pt.State = operationFailed pt.State = operationFailed
pt.updateErrorFromResponse() pt.updateErrorFromResponse()
return pt.pollingError()
} }
return nil return pt.initPollingMethod()
} }
func (pt pollingTrackerBase) getProvisioningState() *string { func (pt pollingTrackerBase) getProvisioningState() *string {
...@@ -416,12 +428,14 @@ func (pt *pollingTrackerBase) pollForStatus(sender autorest.Sender) error { ...@@ -416,12 +428,14 @@ func (pt *pollingTrackerBase) pollForStatus(sender autorest.Sender) error {
} else { } else {
// check response body for error content // check response body for error content
pt.updateErrorFromResponse() pt.updateErrorFromResponse()
err = pt.pollingError()
} }
return err return err
} }
// attempts to unmarshal a ServiceError type from the response body. // attempts to unmarshal a ServiceError type from the response body.
// if that fails then make a best attempt at creating something meaningful. // if that fails then make a best attempt at creating something meaningful.
// NOTE: this assumes that the async operation has failed.
func (pt *pollingTrackerBase) updateErrorFromResponse() { func (pt *pollingTrackerBase) updateErrorFromResponse() {
var err error var err error
if pt.resp.ContentLength != 0 { if pt.resp.ContentLength != 0 {
...@@ -431,8 +445,7 @@ func (pt *pollingTrackerBase) updateErrorFromResponse() { ...@@ -431,8 +445,7 @@ func (pt *pollingTrackerBase) updateErrorFromResponse() {
re := respErr{} re := respErr{}
defer pt.resp.Body.Close() defer pt.resp.Body.Close()
var b []byte var b []byte
b, err = ioutil.ReadAll(pt.resp.Body) if b, err = ioutil.ReadAll(pt.resp.Body); err != nil {
if err != nil {
goto Default goto Default
} }
if err = json.Unmarshal(b, &re); err != nil { if err = json.Unmarshal(b, &re); err != nil {
...@@ -445,20 +458,29 @@ func (pt *pollingTrackerBase) updateErrorFromResponse() { ...@@ -445,20 +458,29 @@ func (pt *pollingTrackerBase) updateErrorFromResponse() {
goto Default goto Default
} }
} }
if re.ServiceError != nil { // the unmarshaller will ensure re.ServiceError is non-nil
// even if there was no content unmarshalled so check the code.
if re.ServiceError.Code != "" {
pt.Err = re.ServiceError pt.Err = re.ServiceError
return return
} }
} }
Default: Default:
se := &ServiceError{ se := &ServiceError{
Code: fmt.Sprintf("HTTP status code %v", pt.resp.StatusCode), Code: pt.pollingStatus(),
Message: pt.resp.Status, Message: "The async operation failed.",
} }
if err != nil { if err != nil {
se.InnerError = make(map[string]interface{}) se.InnerError = make(map[string]interface{})
se.InnerError["unmarshalError"] = err.Error() se.InnerError["unmarshalError"] = err.Error()
} }
// stick the response body into the error object in hopes
// it contains something useful to help diagnose the failure.
if len(pt.rawBody) > 0 {
se.AdditionalInfo = []map[string]interface{}{
pt.rawBody,
}
}
pt.Err = se pt.Err = se
} }
...@@ -538,13 +560,33 @@ func (pt pollingTrackerBase) baseCheckForErrors() error { ...@@ -538,13 +560,33 @@ func (pt pollingTrackerBase) baseCheckForErrors() error {
return nil return nil
} }
// default initialization of polling URL/method. each verb tracker will update this as required.
func (pt *pollingTrackerBase) initPollingMethod() error {
if ao, err := getURLFromAsyncOpHeader(pt.resp); err != nil {
return err
} else if ao != "" {
pt.URI = ao
pt.Pm = PollingAsyncOperation
return nil
}
if lh, err := getURLFromLocationHeader(pt.resp); err != nil {
return err
} else if lh != "" {
pt.URI = lh
pt.Pm = PollingLocation
return nil
}
// it's ok if we didn't find a polling header, this will be handled elsewhere
return nil
}
// DELETE // DELETE
type pollingTrackerDelete struct { type pollingTrackerDelete struct {
pollingTrackerBase pollingTrackerBase
} }
func (pt *pollingTrackerDelete) updateHeaders() error { func (pt *pollingTrackerDelete) updatePollingMethod() error {
// for 201 the Location header is required // for 201 the Location header is required
if pt.resp.StatusCode == http.StatusCreated { if pt.resp.StatusCode == http.StatusCreated {
if lh, err := getURLFromLocationHeader(pt.resp); err != nil { if lh, err := getURLFromLocationHeader(pt.resp); err != nil {
...@@ -600,7 +642,7 @@ type pollingTrackerPatch struct { ...@@ -600,7 +642,7 @@ type pollingTrackerPatch struct {
pollingTrackerBase pollingTrackerBase
} }
func (pt *pollingTrackerPatch) updateHeaders() error { func (pt *pollingTrackerPatch) updatePollingMethod() error {
// by default we can use the original URL for polling and final GET // by default we can use the original URL for polling and final GET
if pt.URI == "" { if pt.URI == "" {
pt.URI = pt.resp.Request.URL.String() pt.URI = pt.resp.Request.URL.String()
...@@ -658,7 +700,7 @@ type pollingTrackerPost struct { ...@@ -658,7 +700,7 @@ type pollingTrackerPost struct {
pollingTrackerBase pollingTrackerBase
} }
func (pt *pollingTrackerPost) updateHeaders() error { func (pt *pollingTrackerPost) updatePollingMethod() error {
// 201 requires Location header // 201 requires Location header
if pt.resp.StatusCode == http.StatusCreated { if pt.resp.StatusCode == http.StatusCreated {
if lh, err := getURLFromLocationHeader(pt.resp); err != nil { if lh, err := getURLFromLocationHeader(pt.resp); err != nil {
...@@ -714,7 +756,7 @@ type pollingTrackerPut struct { ...@@ -714,7 +756,7 @@ type pollingTrackerPut struct {
pollingTrackerBase pollingTrackerBase
} }
func (pt *pollingTrackerPut) updateHeaders() error { func (pt *pollingTrackerPut) updatePollingMethod() error {
// by default we can use the original URL for polling and final GET // by default we can use the original URL for polling and final GET
if pt.URI == "" { if pt.URI == "" {
pt.URI = pt.resp.Request.URL.String() pt.URI = pt.resp.Request.URL.String()
...@@ -808,7 +850,7 @@ func createPollingTracker(resp *http.Response) (pollingTracker, error) { ...@@ -808,7 +850,7 @@ func createPollingTracker(resp *http.Response) (pollingTracker, error) {
// this initializes the polling header values, we do this during creation in case the // this initializes the polling header values, we do this during creation in case the
// initial response send us invalid values; this way the API call will return a non-nil // initial response send us invalid values; this way the API call will return a non-nil
// error (not doing this means the error shows up in Future.Done) // error (not doing this means the error shows up in Future.Done)
return pt, pt.updateHeaders() return pt, pt.updatePollingMethod()
} }
// gets the polling URL from the Azure-AsyncOperation header. // gets the polling URL from the Azure-AsyncOperation header.
......
...@@ -22,8 +22,10 @@ import ( ...@@ -22,8 +22,10 @@ import (
"log" "log"
"net/http" "net/http"
"net/http/cookiejar" "net/http/cookiejar"
"strings"
"time" "time"
"github.com/Azure/go-autorest/logger"
"github.com/Azure/go-autorest/version" "github.com/Azure/go-autorest/version"
) )
...@@ -208,8 +210,17 @@ func (c Client) Do(r *http.Request) (*http.Response, error) { ...@@ -208,8 +210,17 @@ func (c Client) Do(r *http.Request) (*http.Response, error) {
} }
return resp, NewErrorWithError(err, "autorest/Client", "Do", nil, "Preparing request failed") return resp, NewErrorWithError(err, "autorest/Client", "Do", nil, "Preparing request failed")
} }
logger.Instance.WriteRequest(r, logger.Filter{
Header: func(k string, v []string) (bool, []string) {
// remove the auth token from the log
if strings.EqualFold(k, "Authorization") || strings.EqualFold(k, "Ocp-Apim-Subscription-Key") {
v = []string{"**REDACTED**"}
}
return true, v
},
})
resp, err := SendWithSender(c.sender(), r) resp, err := SendWithSender(c.sender(), r)
logger.Instance.WriteResponse(resp, logger.Filter{})
Respond(resp, c.ByInspecting()) Respond(resp, c.ByInspecting())
return resp, err return resp, err
} }
......
load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["logger.go"],
importmap = "k8s.io/kubernetes/vendor/github.com/Azure/go-autorest/logger",
importpath = "github.com/Azure/go-autorest/logger",
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
package logger
// Copyright 2017 Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import (
"bytes"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
"strings"
"sync"
"time"
)
// LevelType tells a logger the minimum level to log. When code reports a log entry,
// the LogLevel indicates the level of the log entry. The logger only records entries
// whose level is at least the level it was told to log. See the Log* constants.
// For example, if a logger is configured with LogError, then LogError, LogPanic,
// and LogFatal entries will be logged; lower level entries are ignored.
type LevelType uint32
const (
// LogNone tells a logger not to log any entries passed to it.
LogNone LevelType = iota
// LogFatal tells a logger to log all LogFatal entries passed to it.
LogFatal
// LogPanic tells a logger to log all LogPanic and LogFatal entries passed to it.
LogPanic
// LogError tells a logger to log all LogError, LogPanic and LogFatal entries passed to it.
LogError
// LogWarning tells a logger to log all LogWarning, LogError, LogPanic and LogFatal entries passed to it.
LogWarning
// LogInfo tells a logger to log all LogInfo, LogWarning, LogError, LogPanic and LogFatal entries passed to it.
LogInfo
// LogDebug tells a logger to log all LogDebug, LogInfo, LogWarning, LogError, LogPanic and LogFatal entries passed to it.
LogDebug
)
const (
logNone = "NONE"
logFatal = "FATAL"
logPanic = "PANIC"
logError = "ERROR"
logWarning = "WARNING"
logInfo = "INFO"
logDebug = "DEBUG"
logUnknown = "UNKNOWN"
)
// ParseLevel converts the specified string into the corresponding LevelType.
func ParseLevel(s string) (lt LevelType, err error) {
switch strings.ToUpper(s) {
case logFatal:
lt = LogFatal
case logPanic:
lt = LogPanic
case logError:
lt = LogError
case logWarning:
lt = LogWarning
case logInfo:
lt = LogInfo
case logDebug:
lt = LogDebug
default:
err = fmt.Errorf("bad log level '%s'", s)
}
return
}
// String implements the stringer interface for LevelType.
func (lt LevelType) String() string {
switch lt {
case LogNone:
return logNone
case LogFatal:
return logFatal
case LogPanic:
return logPanic
case LogError:
return logError
case LogWarning:
return logWarning
case LogInfo:
return logInfo
case LogDebug:
return logDebug
default:
return logUnknown
}
}
// Filter defines functions for filtering HTTP request/response content.
type Filter struct {
// URL returns a potentially modified string representation of a request URL.
URL func(u *url.URL) string
// Header returns a potentially modified set of values for the specified key.
// To completely exclude the header key/values return false.
Header func(key string, val []string) (bool, []string)
// Body returns a potentially modified request/response body.
Body func(b []byte) []byte
}
func (f Filter) processURL(u *url.URL) string {
if f.URL == nil {
return u.String()
}
return f.URL(u)
}
func (f Filter) processHeader(k string, val []string) (bool, []string) {
if f.Header == nil {
return true, val
}
return f.Header(k, val)
}
func (f Filter) processBody(b []byte) []byte {
if f.Body == nil {
return b
}
return f.Body(b)
}
// Writer defines methods for writing to a logging facility.
type Writer interface {
// Writeln writes the specified message with the standard log entry header and new-line character.
Writeln(level LevelType, message string)
// Writef writes the specified format specifier with the standard log entry header and no new-line character.
Writef(level LevelType, format string, a ...interface{})
// WriteRequest writes the specified HTTP request to the logger if the log level is greater than
// or equal to LogInfo. The request body, if set, is logged at level LogDebug or higher.
// Custom filters can be specified to exclude URL, header, and/or body content from the log.
// By default no request content is excluded.
WriteRequest(req *http.Request, filter Filter)
// WriteResponse writes the specified HTTP response to the logger if the log level is greater than
// or equal to LogInfo. The response body, if set, is logged at level LogDebug or higher.
// Custom filters can be specified to exclude URL, header, and/or body content from the log.
// By default no respone content is excluded.
WriteResponse(resp *http.Response, filter Filter)
}
// Instance is the default log writer initialized during package init.
// This can be replaced with a custom implementation as required.
var Instance Writer
// default log level
var logLevel = LogNone
// Level returns the value specified in AZURE_GO_AUTOREST_LOG_LEVEL.
// If no value was specified the default value is LogNone.
// Custom loggers can call this to retrieve the configured log level.
func Level() LevelType {
return logLevel
}
func init() {
// separated for testing purposes
initDefaultLogger()
}
func initDefaultLogger() {
// init with nilLogger so callers don't have to do a nil check on Default
Instance = nilLogger{}
llStr := strings.ToLower(os.Getenv("AZURE_GO_SDK_LOG_LEVEL"))
if llStr == "" {
return
}
var err error
logLevel, err = ParseLevel(llStr)
if err != nil {
fmt.Fprintf(os.Stderr, "go-autorest: failed to parse log level: %s\n", err.Error())
return
}
if logLevel == LogNone {
return
}
// default to stderr
dest := os.Stderr
lfStr := os.Getenv("AZURE_GO_SDK_LOG_FILE")
if strings.EqualFold(lfStr, "stdout") {
dest = os.Stdout
} else if lfStr != "" {
lf, err := os.Create(lfStr)
if err == nil {
dest = lf
} else {
fmt.Fprintf(os.Stderr, "go-autorest: failed to create log file, using stderr: %s\n", err.Error())
}
}
Instance = fileLogger{
logLevel: logLevel,
mu: &sync.Mutex{},
logFile: dest,
}
}
// the nil logger does nothing
type nilLogger struct{}
func (nilLogger) Writeln(LevelType, string) {}
func (nilLogger) Writef(LevelType, string, ...interface{}) {}
func (nilLogger) WriteRequest(*http.Request, Filter) {}
func (nilLogger) WriteResponse(*http.Response, Filter) {}
// A File is used instead of a Logger so the stream can be flushed after every write.
type fileLogger struct {
logLevel LevelType
mu *sync.Mutex // for synchronizing writes to logFile
logFile *os.File
}
func (fl fileLogger) Writeln(level LevelType, message string) {
fl.Writef(level, "%s\n", message)
}
func (fl fileLogger) Writef(level LevelType, format string, a ...interface{}) {
if fl.logLevel >= level {
fl.mu.Lock()
defer fl.mu.Unlock()
fmt.Fprintf(fl.logFile, "%s %s", entryHeader(level), fmt.Sprintf(format, a...))
fl.logFile.Sync()
}
}
func (fl fileLogger) WriteRequest(req *http.Request, filter Filter) {
if req == nil || fl.logLevel < LogInfo {
return
}
b := &bytes.Buffer{}
fmt.Fprintf(b, "%s REQUEST: %s %s\n", entryHeader(LogInfo), req.Method, filter.processURL(req.URL))
// dump headers
for k, v := range req.Header {
if ok, mv := filter.processHeader(k, v); ok {
fmt.Fprintf(b, "%s: %s\n", k, strings.Join(mv, ","))
}
}
if fl.shouldLogBody(req.Header, req.Body) {
// dump body
body, err := ioutil.ReadAll(req.Body)
if err == nil {
fmt.Fprintln(b, string(filter.processBody(body)))
if nc, ok := req.Body.(io.Seeker); ok {
// rewind to the beginning
nc.Seek(0, io.SeekStart)
} else {
// recreate the body
req.Body = ioutil.NopCloser(bytes.NewReader(body))
}
} else {
fmt.Fprintf(b, "failed to read body: %v\n", err)
}
}
fl.mu.Lock()
defer fl.mu.Unlock()
fmt.Fprint(fl.logFile, b.String())
fl.logFile.Sync()
}
func (fl fileLogger) WriteResponse(resp *http.Response, filter Filter) {
if resp == nil || fl.logLevel < LogInfo {
return
}
b := &bytes.Buffer{}
fmt.Fprintf(b, "%s RESPONSE: %d %s\n", entryHeader(LogInfo), resp.StatusCode, filter.processURL(resp.Request.URL))
// dump headers
for k, v := range resp.Header {
if ok, mv := filter.processHeader(k, v); ok {
fmt.Fprintf(b, "%s: %s\n", k, strings.Join(mv, ","))
}
}
if fl.shouldLogBody(resp.Header, resp.Body) {
// dump body
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err == nil {
fmt.Fprintln(b, string(filter.processBody(body)))
resp.Body = ioutil.NopCloser(bytes.NewReader(body))
} else {
fmt.Fprintf(b, "failed to read body: %v\n", err)
}
}
fl.mu.Lock()
defer fl.mu.Unlock()
fmt.Fprint(fl.logFile, b.String())
fl.logFile.Sync()
}
// returns true if the provided body should be included in the log
func (fl fileLogger) shouldLogBody(header http.Header, body io.ReadCloser) bool {
ct := header.Get("Content-Type")
return fl.logLevel >= LogDebug && body != nil && strings.Index(ct, "application/octet-stream") == -1
}
// creates standard header for log entries, it contains a timestamp and the log level
func entryHeader(level LevelType) string {
// this format provides a fixed number of digits so the size of the timestamp is constant
return fmt.Sprintf("(%s) %s:", time.Now().Format("2006-01-02T15:04:05.0000000Z07:00"), level.String())
}
...@@ -20,7 +20,7 @@ import ( ...@@ -20,7 +20,7 @@ import (
) )
// Number contains the semantic version of this SDK. // Number contains the semantic version of this SDK.
const Number = "v10.14.0" const Number = "v10.15.4"
var ( var (
userAgent = fmt.Sprintf("Go/%s (%s-%s) go-autorest/%s", userAgent = fmt.Sprintf("Go/%s (%s-%s) go-autorest/%s",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment