mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Switch to new ClientConfig for Azure cloud provider
This commit is contained in:
parent
7382a7c801
commit
31d6cc5792
199
Godeps/LICENSES
generated
199
Godeps/LICENSES
generated
@ -1547,6 +1547,205 @@ THE SOFTWARE.
|
|||||||
================================================================================
|
================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
= vendor/github.com/Azure/go-autorest/autorest/mocks licensed under: =
|
||||||
|
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
Copyright 2015 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.
|
||||||
|
|
||||||
|
= vendor/github.com/Azure/go-autorest/autorest/mocks/LICENSE a250e5ac3848f2acadb5adcb9555c18b
|
||||||
|
================================================================================
|
||||||
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
= vendor/github.com/Azure/go-autorest/autorest/to licensed under: =
|
= vendor/github.com/Azure/go-autorest/autorest/to licensed under: =
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ go_library(
|
|||||||
"//staging/src/k8s.io/component-base/metrics:go_default_library",
|
"//staging/src/k8s.io/component-base/metrics:go_default_library",
|
||||||
"//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library",
|
"//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library",
|
||||||
"//staging/src/k8s.io/legacy-cloud-providers/azure/auth:go_default_library",
|
"//staging/src/k8s.io/legacy-cloud-providers/azure/auth:go_default_library",
|
||||||
|
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients:go_default_library",
|
||||||
"//staging/src/k8s.io/legacy-cloud-providers/azure/retry:go_default_library",
|
"//staging/src/k8s.io/legacy-cloud-providers/azure/retry:go_default_library",
|
||||||
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library",
|
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library",
|
||||||
"//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network:go_default_library",
|
"//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network:go_default_library",
|
||||||
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage:go_default_library",
|
"//vendor/github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-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/azure:go_default_library",
|
"//vendor/github.com/Azure/go-autorest/autorest/azure: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/rubiojr/go-vhd/vhd:go_default_library",
|
"//vendor/github.com/rubiojr/go-vhd/vhd:go_default_library",
|
||||||
@ -118,6 +118,7 @@ go_test(
|
|||||||
"//staging/src/k8s.io/cloud-provider:go_default_library",
|
"//staging/src/k8s.io/cloud-provider:go_default_library",
|
||||||
"//staging/src/k8s.io/cloud-provider/service/helpers:go_default_library",
|
"//staging/src/k8s.io/cloud-provider/service/helpers:go_default_library",
|
||||||
"//staging/src/k8s.io/legacy-cloud-providers/azure/auth:go_default_library",
|
"//staging/src/k8s.io/legacy-cloud-providers/azure/auth:go_default_library",
|
||||||
|
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients:go_default_library",
|
||||||
"//staging/src/k8s.io/legacy-cloud-providers/azure/retry:go_default_library",
|
"//staging/src/k8s.io/legacy-cloud-providers/azure/retry:go_default_library",
|
||||||
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library",
|
"//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library",
|
||||||
"//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network:go_default_library",
|
"//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network:go_default_library",
|
||||||
@ -141,6 +142,7 @@ filegroup(
|
|||||||
srcs = [
|
srcs = [
|
||||||
":package-srcs",
|
":package-srcs",
|
||||||
"//staging/src/k8s.io/legacy-cloud-providers/azure/auth:all-srcs",
|
"//staging/src/k8s.io/legacy-cloud-providers/azure/auth:all-srcs",
|
||||||
|
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients:all-srcs",
|
||||||
"//staging/src/k8s.io/legacy-cloud-providers/azure/retry:all-srcs",
|
"//staging/src/k8s.io/legacy-cloud-providers/azure/retry:all-srcs",
|
||||||
],
|
],
|
||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
|
@ -8,7 +8,10 @@ load(
|
|||||||
|
|
||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = ["azure_auth.go"],
|
srcs = [
|
||||||
|
"azure_auth.go",
|
||||||
|
"doc.go",
|
||||||
|
],
|
||||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/legacy-cloud-providers/azure/auth",
|
importmap = "k8s.io/kubernetes/vendor/k8s.io/legacy-cloud-providers/azure/auth",
|
||||||
importpath = "k8s.io/legacy-cloud-providers/azure/auth",
|
importpath = "k8s.io/legacy-cloud-providers/azure/auth",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
|
18
staging/src/k8s.io/legacy-cloud-providers/azure/auth/doc.go
Normal file
18
staging/src/k8s.io/legacy-cloud-providers/azure/auth/doc.go
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Package auth provides a general libraty to authorize Azure ARM clients.
|
||||||
|
package auth // import "k8s.io/legacy-cloud-providers/azure/auth"
|
@ -45,6 +45,8 @@ import (
|
|||||||
cloudprovider "k8s.io/cloud-provider"
|
cloudprovider "k8s.io/cloud-provider"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/legacy-cloud-providers/azure/auth"
|
"k8s.io/legacy-cloud-providers/azure/auth"
|
||||||
|
azclients "k8s.io/legacy-cloud-providers/azure/clients"
|
||||||
|
"k8s.io/legacy-cloud-providers/azure/retry"
|
||||||
"sigs.k8s.io/yaml"
|
"sigs.k8s.io/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -448,13 +450,23 @@ func (az *Cloud) InitializeCloudFromConfig(config *Config, fromSecret bool) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize Azure clients.
|
// Initialize Azure clients.
|
||||||
azClientConfig := &azClientConfig{
|
azClientConfig := &azclients.ClientConfig{
|
||||||
subscriptionID: config.SubscriptionID,
|
Location: config.Location,
|
||||||
resourceManagerEndpoint: env.ResourceManagerEndpoint,
|
SubscriptionID: config.SubscriptionID,
|
||||||
servicePrincipalToken: servicePrincipalToken,
|
ResourceManagerEndpoint: env.ResourceManagerEndpoint,
|
||||||
|
ServicePrincipalToken: servicePrincipalToken,
|
||||||
CloudProviderBackoffRetries: config.CloudProviderBackoffRetries,
|
CloudProviderBackoffRetries: config.CloudProviderBackoffRetries,
|
||||||
CloudProviderBackoffDuration: config.CloudProviderBackoffDuration,
|
CloudProviderBackoffDuration: config.CloudProviderBackoffDuration,
|
||||||
ShouldOmitCloudProviderBackoff: config.shouldOmitCloudProviderBackoff(),
|
ShouldOmitCloudProviderBackoff: config.shouldOmitCloudProviderBackoff(),
|
||||||
|
Backoff: &retry.Backoff{Steps: 1},
|
||||||
|
}
|
||||||
|
if config.CloudProviderBackoff {
|
||||||
|
azClientConfig.Backoff = &retry.Backoff{
|
||||||
|
Steps: config.CloudProviderBackoffRetries,
|
||||||
|
Factor: config.CloudProviderBackoffExponent,
|
||||||
|
Duration: time.Duration(config.CloudProviderBackoffDuration) * time.Second,
|
||||||
|
Jitter: config.CloudProviderBackoffJitter,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
az.DisksClient = newAzDisksClient(azClientConfig.WithRateLimiter(config.DiskRateLimit))
|
az.DisksClient = newAzDisksClient(azClientConfig.WithRateLimiter(config.DiskRateLimit))
|
||||||
az.SnapshotsClient = newSnapshotsClient(azClientConfig.WithRateLimiter(config.SnapshotRateLimit))
|
az.SnapshotsClient = newSnapshotsClient(azClientConfig.WithRateLimiter(config.SnapshotRateLimit))
|
||||||
|
@ -28,10 +28,10 @@ import (
|
|||||||
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network"
|
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network"
|
||||||
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
|
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
"github.com/Azure/go-autorest/autorest/adal"
|
|
||||||
|
|
||||||
"k8s.io/client-go/util/flowcontrol"
|
"k8s.io/client-go/util/flowcontrol"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
|
azclients "k8s.io/legacy-cloud-providers/azure/clients"
|
||||||
"k8s.io/legacy-cloud-providers/azure/retry"
|
"k8s.io/legacy-cloud-providers/azure/retry"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -145,24 +145,6 @@ type VirtualMachineSizesClient interface {
|
|||||||
List(ctx context.Context, location string) (result compute.VirtualMachineSizeListResult, rerr *retry.Error)
|
List(ctx context.Context, location string) (result compute.VirtualMachineSizeListResult, rerr *retry.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// azClientConfig contains all essential information to create an Azure client.
|
|
||||||
type azClientConfig struct {
|
|
||||||
subscriptionID string
|
|
||||||
resourceManagerEndpoint string
|
|
||||||
servicePrincipalToken *adal.ServicePrincipalToken
|
|
||||||
rateLimitConfig *RateLimitConfig
|
|
||||||
|
|
||||||
CloudProviderBackoffRetries int
|
|
||||||
CloudProviderBackoffDuration int
|
|
||||||
ShouldOmitCloudProviderBackoff bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithRateLimiter returns azClientConfig with rateLimitConfig set.
|
|
||||||
func (cfg *azClientConfig) WithRateLimiter(rl *RateLimitConfig) *azClientConfig {
|
|
||||||
cfg.rateLimitConfig = rl
|
|
||||||
return cfg
|
|
||||||
}
|
|
||||||
|
|
||||||
// azVirtualMachinesClient implements VirtualMachinesClient.
|
// azVirtualMachinesClient implements VirtualMachinesClient.
|
||||||
type azVirtualMachinesClient struct {
|
type azVirtualMachinesClient struct {
|
||||||
client compute.VirtualMachinesClient
|
client compute.VirtualMachinesClient
|
||||||
@ -174,10 +156,10 @@ func getContextWithCancel() (context.Context, context.CancelFunc) {
|
|||||||
return context.WithCancel(context.Background())
|
return context.WithCancel(context.Background())
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzVirtualMachinesClient(config *azClientConfig) *azVirtualMachinesClient {
|
func newAzVirtualMachinesClient(config *azclients.ClientConfig) *azVirtualMachinesClient {
|
||||||
virtualMachinesClient := compute.NewVirtualMachinesClient(config.subscriptionID)
|
virtualMachinesClient := compute.NewVirtualMachinesClient(config.SubscriptionID)
|
||||||
virtualMachinesClient.BaseURI = config.resourceManagerEndpoint
|
virtualMachinesClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
virtualMachinesClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
virtualMachinesClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
virtualMachinesClient.PollingDelay = 5 * time.Second
|
virtualMachinesClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
virtualMachinesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
virtualMachinesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -186,12 +168,12 @@ func newAzVirtualMachinesClient(config *azClientConfig) *azVirtualMachinesClient
|
|||||||
configureUserAgent(&virtualMachinesClient.Client)
|
configureUserAgent(&virtualMachinesClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure VirtualMachinesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure VirtualMachinesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure VirtualMachinesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure VirtualMachinesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azVirtualMachinesClient{
|
return &azVirtualMachinesClient{
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
rateLimiterWriter: rateLimiterWriter,
|
rateLimiterWriter: rateLimiterWriter,
|
||||||
@ -302,10 +284,10 @@ type azInterfacesClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzInterfacesClient(config *azClientConfig) *azInterfacesClient {
|
func newAzInterfacesClient(config *azclients.ClientConfig) *azInterfacesClient {
|
||||||
interfacesClient := network.NewInterfacesClient(config.subscriptionID)
|
interfacesClient := network.NewInterfacesClient(config.SubscriptionID)
|
||||||
interfacesClient.BaseURI = config.resourceManagerEndpoint
|
interfacesClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
interfacesClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
interfacesClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
interfacesClient.PollingDelay = 5 * time.Second
|
interfacesClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
interfacesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
interfacesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -314,12 +296,12 @@ func newAzInterfacesClient(config *azClientConfig) *azInterfacesClient {
|
|||||||
configureUserAgent(&interfacesClient.Client)
|
configureUserAgent(&interfacesClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure InterfacesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure InterfacesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure InterfacesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure InterfacesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azInterfacesClient{
|
return &azInterfacesClient{
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
rateLimiterWriter: rateLimiterWriter,
|
rateLimiterWriter: rateLimiterWriter,
|
||||||
@ -394,10 +376,10 @@ type azLoadBalancersClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzLoadBalancersClient(config *azClientConfig) *azLoadBalancersClient {
|
func newAzLoadBalancersClient(config *azclients.ClientConfig) *azLoadBalancersClient {
|
||||||
loadBalancerClient := network.NewLoadBalancersClient(config.subscriptionID)
|
loadBalancerClient := network.NewLoadBalancersClient(config.SubscriptionID)
|
||||||
loadBalancerClient.BaseURI = config.resourceManagerEndpoint
|
loadBalancerClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
loadBalancerClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
loadBalancerClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
loadBalancerClient.PollingDelay = 5 * time.Second
|
loadBalancerClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
loadBalancerClient.RetryAttempts = config.CloudProviderBackoffRetries
|
loadBalancerClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -406,12 +388,12 @@ func newAzLoadBalancersClient(config *azClientConfig) *azLoadBalancersClient {
|
|||||||
configureUserAgent(&loadBalancerClient.Client)
|
configureUserAgent(&loadBalancerClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure LoadBalancersClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure LoadBalancersClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure LoadBalancersClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure LoadBalancersClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azLoadBalancersClient{
|
return &azLoadBalancersClient{
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
rateLimiterWriter: rateLimiterWriter,
|
rateLimiterWriter: rateLimiterWriter,
|
||||||
@ -552,10 +534,10 @@ type azPublicIPAddressesClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzPublicIPAddressesClient(config *azClientConfig) *azPublicIPAddressesClient {
|
func newAzPublicIPAddressesClient(config *azclients.ClientConfig) *azPublicIPAddressesClient {
|
||||||
publicIPAddressClient := network.NewPublicIPAddressesClient(config.subscriptionID)
|
publicIPAddressClient := network.NewPublicIPAddressesClient(config.SubscriptionID)
|
||||||
publicIPAddressClient.BaseURI = config.resourceManagerEndpoint
|
publicIPAddressClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
publicIPAddressClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
publicIPAddressClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
publicIPAddressClient.PollingDelay = 5 * time.Second
|
publicIPAddressClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
publicIPAddressClient.RetryAttempts = config.CloudProviderBackoffRetries
|
publicIPAddressClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -564,12 +546,12 @@ func newAzPublicIPAddressesClient(config *azClientConfig) *azPublicIPAddressesCl
|
|||||||
configureUserAgent(&publicIPAddressClient.Client)
|
configureUserAgent(&publicIPAddressClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure PublicIPAddressesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure PublicIPAddressesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure PublicIPAddressesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure PublicIPAddressesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azPublicIPAddressesClient{
|
return &azPublicIPAddressesClient{
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
rateLimiterWriter: rateLimiterWriter,
|
rateLimiterWriter: rateLimiterWriter,
|
||||||
@ -696,10 +678,10 @@ type azSubnetsClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzSubnetsClient(config *azClientConfig) *azSubnetsClient {
|
func newAzSubnetsClient(config *azclients.ClientConfig) *azSubnetsClient {
|
||||||
subnetsClient := network.NewSubnetsClient(config.subscriptionID)
|
subnetsClient := network.NewSubnetsClient(config.SubscriptionID)
|
||||||
subnetsClient.BaseURI = config.resourceManagerEndpoint
|
subnetsClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
subnetsClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
subnetsClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
subnetsClient.PollingDelay = 5 * time.Second
|
subnetsClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
subnetsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
subnetsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -708,12 +690,12 @@ func newAzSubnetsClient(config *azClientConfig) *azSubnetsClient {
|
|||||||
configureUserAgent(&subnetsClient.Client)
|
configureUserAgent(&subnetsClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure SubnetsClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure SubnetsClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure SubnetsClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure SubnetsClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azSubnetsClient{
|
return &azSubnetsClient{
|
||||||
client: subnetsClient,
|
client: subnetsClient,
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
@ -821,10 +803,10 @@ type azSecurityGroupsClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzSecurityGroupsClient(config *azClientConfig) *azSecurityGroupsClient {
|
func newAzSecurityGroupsClient(config *azclients.ClientConfig) *azSecurityGroupsClient {
|
||||||
securityGroupsClient := network.NewSecurityGroupsClient(config.subscriptionID)
|
securityGroupsClient := network.NewSecurityGroupsClient(config.SubscriptionID)
|
||||||
securityGroupsClient.BaseURI = config.resourceManagerEndpoint
|
securityGroupsClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
securityGroupsClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
securityGroupsClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
securityGroupsClient.PollingDelay = 5 * time.Second
|
securityGroupsClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
securityGroupsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
securityGroupsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -833,12 +815,12 @@ func newAzSecurityGroupsClient(config *azClientConfig) *azSecurityGroupsClient {
|
|||||||
configureUserAgent(&securityGroupsClient.Client)
|
configureUserAgent(&securityGroupsClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure SecurityGroupsClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure SecurityGroupsClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure SecurityGroupsClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure SecurityGroupsClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azSecurityGroupsClient{
|
return &azSecurityGroupsClient{
|
||||||
client: securityGroupsClient,
|
client: securityGroupsClient,
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
@ -978,10 +960,10 @@ type azVirtualMachineScaleSetsClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzVirtualMachineScaleSetsClient(config *azClientConfig) *azVirtualMachineScaleSetsClient {
|
func newAzVirtualMachineScaleSetsClient(config *azclients.ClientConfig) *azVirtualMachineScaleSetsClient {
|
||||||
virtualMachineScaleSetsClient := compute.NewVirtualMachineScaleSetsClient(config.subscriptionID)
|
virtualMachineScaleSetsClient := compute.NewVirtualMachineScaleSetsClient(config.SubscriptionID)
|
||||||
virtualMachineScaleSetsClient.BaseURI = config.resourceManagerEndpoint
|
virtualMachineScaleSetsClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
virtualMachineScaleSetsClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
virtualMachineScaleSetsClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
virtualMachineScaleSetsClient.PollingDelay = 5 * time.Second
|
virtualMachineScaleSetsClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
virtualMachineScaleSetsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
virtualMachineScaleSetsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -990,12 +972,12 @@ func newAzVirtualMachineScaleSetsClient(config *azClientConfig) *azVirtualMachin
|
|||||||
configureUserAgent(&virtualMachineScaleSetsClient.Client)
|
configureUserAgent(&virtualMachineScaleSetsClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure VirtualMachineScaleSetsClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure VirtualMachineScaleSetsClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure VirtualMachineScaleSetsClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure VirtualMachineScaleSetsClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azVirtualMachineScaleSetsClient{
|
return &azVirtualMachineScaleSetsClient{
|
||||||
client: virtualMachineScaleSetsClient,
|
client: virtualMachineScaleSetsClient,
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
@ -1082,10 +1064,10 @@ type azVirtualMachineScaleSetVMsClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzVirtualMachineScaleSetVMsClient(config *azClientConfig) *azVirtualMachineScaleSetVMsClient {
|
func newAzVirtualMachineScaleSetVMsClient(config *azclients.ClientConfig) *azVirtualMachineScaleSetVMsClient {
|
||||||
virtualMachineScaleSetVMsClient := compute.NewVirtualMachineScaleSetVMsClient(config.subscriptionID)
|
virtualMachineScaleSetVMsClient := compute.NewVirtualMachineScaleSetVMsClient(config.SubscriptionID)
|
||||||
virtualMachineScaleSetVMsClient.BaseURI = config.resourceManagerEndpoint
|
virtualMachineScaleSetVMsClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
virtualMachineScaleSetVMsClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
virtualMachineScaleSetVMsClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
virtualMachineScaleSetVMsClient.PollingDelay = 5 * time.Second
|
virtualMachineScaleSetVMsClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
virtualMachineScaleSetVMsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
virtualMachineScaleSetVMsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -1094,12 +1076,12 @@ func newAzVirtualMachineScaleSetVMsClient(config *azClientConfig) *azVirtualMach
|
|||||||
configureUserAgent(&virtualMachineScaleSetVMsClient.Client)
|
configureUserAgent(&virtualMachineScaleSetVMsClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure VirtualMachineScaleSetVMsClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure VirtualMachineScaleSetVMsClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure VirtualMachineScaleSetVMsClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure VirtualMachineScaleSetVMsClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azVirtualMachineScaleSetVMsClient{
|
return &azVirtualMachineScaleSetVMsClient{
|
||||||
client: virtualMachineScaleSetVMsClient,
|
client: virtualMachineScaleSetVMsClient,
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
@ -1185,10 +1167,10 @@ type azRoutesClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzRoutesClient(config *azClientConfig) *azRoutesClient {
|
func newAzRoutesClient(config *azclients.ClientConfig) *azRoutesClient {
|
||||||
routesClient := network.NewRoutesClient(config.subscriptionID)
|
routesClient := network.NewRoutesClient(config.SubscriptionID)
|
||||||
routesClient.BaseURI = config.resourceManagerEndpoint
|
routesClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
routesClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
routesClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
routesClient.PollingDelay = 5 * time.Second
|
routesClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
routesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
routesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -1197,12 +1179,12 @@ func newAzRoutesClient(config *azClientConfig) *azRoutesClient {
|
|||||||
configureUserAgent(&routesClient.Client)
|
configureUserAgent(&routesClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure RoutesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure RoutesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure RoutesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure RoutesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azRoutesClient{
|
return &azRoutesClient{
|
||||||
client: routesClient,
|
client: routesClient,
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
@ -1295,10 +1277,10 @@ type azRouteTablesClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzRouteTablesClient(config *azClientConfig) *azRouteTablesClient {
|
func newAzRouteTablesClient(config *azclients.ClientConfig) *azRouteTablesClient {
|
||||||
routeTablesClient := network.NewRouteTablesClient(config.subscriptionID)
|
routeTablesClient := network.NewRouteTablesClient(config.SubscriptionID)
|
||||||
routeTablesClient.BaseURI = config.resourceManagerEndpoint
|
routeTablesClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
routeTablesClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
routeTablesClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
routeTablesClient.PollingDelay = 5 * time.Second
|
routeTablesClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
routeTablesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
routeTablesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -1307,12 +1289,12 @@ func newAzRouteTablesClient(config *azClientConfig) *azRouteTablesClient {
|
|||||||
configureUserAgent(&routeTablesClient.Client)
|
configureUserAgent(&routeTablesClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure RouteTablesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure RouteTablesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure RouteTablesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure RouteTablesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azRouteTablesClient{
|
return &azRouteTablesClient{
|
||||||
client: routeTablesClient,
|
client: routeTablesClient,
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
@ -1400,9 +1382,9 @@ type azStorageAccountClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzStorageAccountClient(config *azClientConfig) *azStorageAccountClient {
|
func newAzStorageAccountClient(config *azclients.ClientConfig) *azStorageAccountClient {
|
||||||
storageAccountClient := storage.NewAccountsClientWithBaseURI(config.resourceManagerEndpoint, config.subscriptionID)
|
storageAccountClient := storage.NewAccountsClientWithBaseURI(config.ResourceManagerEndpoint, config.SubscriptionID)
|
||||||
storageAccountClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
storageAccountClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
storageAccountClient.PollingDelay = 5 * time.Second
|
storageAccountClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
storageAccountClient.RetryAttempts = config.CloudProviderBackoffRetries
|
storageAccountClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -1411,12 +1393,12 @@ func newAzStorageAccountClient(config *azClientConfig) *azStorageAccountClient {
|
|||||||
configureUserAgent(&storageAccountClient.Client)
|
configureUserAgent(&storageAccountClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure StorageAccountClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure StorageAccountClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure StorageAccountClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure StorageAccountClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azStorageAccountClient{
|
return &azStorageAccountClient{
|
||||||
client: storageAccountClient,
|
client: storageAccountClient,
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
@ -1528,9 +1510,9 @@ type azDisksClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzDisksClient(config *azClientConfig) *azDisksClient {
|
func newAzDisksClient(config *azclients.ClientConfig) *azDisksClient {
|
||||||
disksClient := compute.NewDisksClientWithBaseURI(config.resourceManagerEndpoint, config.subscriptionID)
|
disksClient := compute.NewDisksClientWithBaseURI(config.ResourceManagerEndpoint, config.SubscriptionID)
|
||||||
disksClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
disksClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
disksClient.PollingDelay = 5 * time.Second
|
disksClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
disksClient.RetryAttempts = config.CloudProviderBackoffRetries
|
disksClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -1539,12 +1521,12 @@ func newAzDisksClient(config *azClientConfig) *azDisksClient {
|
|||||||
configureUserAgent(&disksClient.Client)
|
configureUserAgent(&disksClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure DisksClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure DisksClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure DisksClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure DisksClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azDisksClient{
|
return &azDisksClient{
|
||||||
client: disksClient,
|
client: disksClient,
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
@ -1615,9 +1597,9 @@ func (az *azDisksClient) Get(ctx context.Context, resourceGroupName string, disk
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO(feiskyer): refactor compute.SnapshotsClient to Interface.
|
// TODO(feiskyer): refactor compute.SnapshotsClient to Interface.
|
||||||
func newSnapshotsClient(config *azClientConfig) *compute.SnapshotsClient {
|
func newSnapshotsClient(config *azclients.ClientConfig) *compute.SnapshotsClient {
|
||||||
snapshotsClient := compute.NewSnapshotsClientWithBaseURI(config.resourceManagerEndpoint, config.subscriptionID)
|
snapshotsClient := compute.NewSnapshotsClientWithBaseURI(config.ResourceManagerEndpoint, config.SubscriptionID)
|
||||||
snapshotsClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
snapshotsClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
snapshotsClient.PollingDelay = 5 * time.Second
|
snapshotsClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
snapshotsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
snapshotsClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -1634,10 +1616,10 @@ type azVirtualMachineSizesClient struct {
|
|||||||
rateLimiterWriter flowcontrol.RateLimiter
|
rateLimiterWriter flowcontrol.RateLimiter
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAzVirtualMachineSizesClient(config *azClientConfig) *azVirtualMachineSizesClient {
|
func newAzVirtualMachineSizesClient(config *azclients.ClientConfig) *azVirtualMachineSizesClient {
|
||||||
VirtualMachineSizesClient := compute.NewVirtualMachineSizesClient(config.subscriptionID)
|
VirtualMachineSizesClient := compute.NewVirtualMachineSizesClient(config.SubscriptionID)
|
||||||
VirtualMachineSizesClient.BaseURI = config.resourceManagerEndpoint
|
VirtualMachineSizesClient.BaseURI = config.ResourceManagerEndpoint
|
||||||
VirtualMachineSizesClient.Authorizer = autorest.NewBearerAuthorizer(config.servicePrincipalToken)
|
VirtualMachineSizesClient.Authorizer = autorest.NewBearerAuthorizer(config.ServicePrincipalToken)
|
||||||
VirtualMachineSizesClient.PollingDelay = 5 * time.Second
|
VirtualMachineSizesClient.PollingDelay = 5 * time.Second
|
||||||
if config.ShouldOmitCloudProviderBackoff {
|
if config.ShouldOmitCloudProviderBackoff {
|
||||||
VirtualMachineSizesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
VirtualMachineSizesClient.RetryAttempts = config.CloudProviderBackoffRetries
|
||||||
@ -1646,12 +1628,12 @@ func newAzVirtualMachineSizesClient(config *azClientConfig) *azVirtualMachineSiz
|
|||||||
configureUserAgent(&VirtualMachineSizesClient.Client)
|
configureUserAgent(&VirtualMachineSizesClient.Client)
|
||||||
|
|
||||||
klog.V(2).Infof("Azure VirtualMachineSizesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure VirtualMachineSizesClient (read ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPS,
|
config.RateLimitConfig.CloudProviderRateLimitQPS,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucket)
|
config.RateLimitConfig.CloudProviderRateLimitBucket)
|
||||||
klog.V(2).Infof("Azure VirtualMachineSizesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
klog.V(2).Infof("Azure VirtualMachineSizesClient (write ops) using rate limit config: QPS=%g, bucket=%d",
|
||||||
config.rateLimitConfig.CloudProviderRateLimitQPSWrite,
|
config.RateLimitConfig.CloudProviderRateLimitQPSWrite,
|
||||||
config.rateLimitConfig.CloudProviderRateLimitBucketWrite)
|
config.RateLimitConfig.CloudProviderRateLimitBucketWrite)
|
||||||
rateLimiterReader, rateLimiterWriter := NewRateLimiter(config.rateLimitConfig)
|
rateLimiterReader, rateLimiterWriter := azclients.NewRateLimiter(config.RateLimitConfig)
|
||||||
return &azVirtualMachineSizesClient{
|
return &azVirtualMachineSizesClient{
|
||||||
rateLimiterReader: rateLimiterReader,
|
rateLimiterReader: rateLimiterReader,
|
||||||
rateLimiterWriter: rateLimiterWriter,
|
rateLimiterWriter: rateLimiterWriter,
|
||||||
|
@ -19,42 +19,28 @@ limitations under the License.
|
|||||||
package azure
|
package azure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/client-go/util/flowcontrol"
|
azclients "k8s.io/legacy-cloud-providers/azure/clients"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RateLimitConfig indicates the rate limit config options.
|
|
||||||
type RateLimitConfig struct {
|
|
||||||
// Enable rate limiting
|
|
||||||
CloudProviderRateLimit bool `json:"cloudProviderRateLimit,omitempty" yaml:"cloudProviderRateLimit,omitempty"`
|
|
||||||
// Rate limit QPS (Read)
|
|
||||||
CloudProviderRateLimitQPS float32 `json:"cloudProviderRateLimitQPS,omitempty" yaml:"cloudProviderRateLimitQPS,omitempty"`
|
|
||||||
// Rate limit Bucket Size
|
|
||||||
CloudProviderRateLimitBucket int `json:"cloudProviderRateLimitBucket,omitempty" yaml:"cloudProviderRateLimitBucket,omitempty"`
|
|
||||||
// Rate limit QPS (Write)
|
|
||||||
CloudProviderRateLimitQPSWrite float32 `json:"cloudProviderRateLimitQPSWrite,omitempty" yaml:"cloudProviderRateLimitQPSWrite,omitempty"`
|
|
||||||
// Rate limit Bucket Size
|
|
||||||
CloudProviderRateLimitBucketWrite int `json:"cloudProviderRateLimitBucketWrite,omitempty" yaml:"cloudProviderRateLimitBucketWrite,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// CloudProviderRateLimitConfig indicates the rate limit config for each clients.
|
// CloudProviderRateLimitConfig indicates the rate limit config for each clients.
|
||||||
type CloudProviderRateLimitConfig struct {
|
type CloudProviderRateLimitConfig struct {
|
||||||
// The default rate limit config options.
|
// The default rate limit config options.
|
||||||
RateLimitConfig
|
azclients.RateLimitConfig
|
||||||
|
|
||||||
// Rate limit config for each clients. Values would override default settings above.
|
// Rate limit config for each clients. Values would override default settings above.
|
||||||
RouteRateLimit *RateLimitConfig `json:"routeRateLimit,omitempty" yaml:"routeRateLimit,omitempty"`
|
RouteRateLimit *azclients.RateLimitConfig `json:"routeRateLimit,omitempty" yaml:"routeRateLimit,omitempty"`
|
||||||
SubnetsRateLimit *RateLimitConfig `json:"subnetsRateLimit,omitempty" yaml:"subnetsRateLimit,omitempty"`
|
SubnetsRateLimit *azclients.RateLimitConfig `json:"subnetsRateLimit,omitempty" yaml:"subnetsRateLimit,omitempty"`
|
||||||
InterfaceRateLimit *RateLimitConfig `json:"interfaceRateLimit,omitempty" yaml:"interfaceRateLimit,omitempty"`
|
InterfaceRateLimit *azclients.RateLimitConfig `json:"interfaceRateLimit,omitempty" yaml:"interfaceRateLimit,omitempty"`
|
||||||
RouteTableRateLimit *RateLimitConfig `json:"routeTableRateLimit,omitempty" yaml:"routeTableRateLimit,omitempty"`
|
RouteTableRateLimit *azclients.RateLimitConfig `json:"routeTableRateLimit,omitempty" yaml:"routeTableRateLimit,omitempty"`
|
||||||
LoadBalancerRateLimit *RateLimitConfig `json:"loadBalancerRateLimit,omitempty" yaml:"loadBalancerRateLimit,omitempty"`
|
LoadBalancerRateLimit *azclients.RateLimitConfig `json:"loadBalancerRateLimit,omitempty" yaml:"loadBalancerRateLimit,omitempty"`
|
||||||
PublicIPAddressRateLimit *RateLimitConfig `json:"publicIPAddressRateLimit,omitempty" yaml:"publicIPAddressRateLimit,omitempty"`
|
PublicIPAddressRateLimit *azclients.RateLimitConfig `json:"publicIPAddressRateLimit,omitempty" yaml:"publicIPAddressRateLimit,omitempty"`
|
||||||
SecurityGroupRateLimit *RateLimitConfig `json:"securityGroupRateLimit,omitempty" yaml:"securityGroupRateLimit,omitempty"`
|
SecurityGroupRateLimit *azclients.RateLimitConfig `json:"securityGroupRateLimit,omitempty" yaml:"securityGroupRateLimit,omitempty"`
|
||||||
VirtualMachineRateLimit *RateLimitConfig `json:"virtualMachineRateLimit,omitempty" yaml:"virtualMachineRateLimit,omitempty"`
|
VirtualMachineRateLimit *azclients.RateLimitConfig `json:"virtualMachineRateLimit,omitempty" yaml:"virtualMachineRateLimit,omitempty"`
|
||||||
StorageAccountRateLimit *RateLimitConfig `json:"storageAccountRateLimit,omitempty" yaml:"storageAccountRateLimit,omitempty"`
|
StorageAccountRateLimit *azclients.RateLimitConfig `json:"storageAccountRateLimit,omitempty" yaml:"storageAccountRateLimit,omitempty"`
|
||||||
DiskRateLimit *RateLimitConfig `json:"diskRateLimit,omitempty" yaml:"diskRateLimit,omitempty"`
|
DiskRateLimit *azclients.RateLimitConfig `json:"diskRateLimit,omitempty" yaml:"diskRateLimit,omitempty"`
|
||||||
SnapshotRateLimit *RateLimitConfig `json:"snapshotRateLimit,omitempty" yaml:"snapshotRateLimit,omitempty"`
|
SnapshotRateLimit *azclients.RateLimitConfig `json:"snapshotRateLimit,omitempty" yaml:"snapshotRateLimit,omitempty"`
|
||||||
VirtualMachineScaleSetRateLimit *RateLimitConfig `json:"virtualMachineScaleSetRateLimit,omitempty" yaml:"virtualMachineScaleSetRateLimit,omitempty"`
|
VirtualMachineScaleSetRateLimit *azclients.RateLimitConfig `json:"virtualMachineScaleSetRateLimit,omitempty" yaml:"virtualMachineScaleSetRateLimit,omitempty"`
|
||||||
VirtualMachineSizeRateLimit *RateLimitConfig `json:"virtualMachineSizesRateLimit,omitempty" yaml:"virtualMachineSizesRateLimit,omitempty"`
|
VirtualMachineSizeRateLimit *azclients.RateLimitConfig `json:"virtualMachineSizesRateLimit,omitempty" yaml:"virtualMachineSizesRateLimit,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitializeCloudProviderRateLimitConfig initializes rate limit configs.
|
// InitializeCloudProviderRateLimitConfig initializes rate limit configs.
|
||||||
@ -94,7 +80,7 @@ func InitializeCloudProviderRateLimitConfig(config *CloudProviderRateLimitConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// overrideDefaultRateLimitConfig overrides the default CloudProviderRateLimitConfig.
|
// overrideDefaultRateLimitConfig overrides the default CloudProviderRateLimitConfig.
|
||||||
func overrideDefaultRateLimitConfig(defaults, config *RateLimitConfig) *RateLimitConfig {
|
func overrideDefaultRateLimitConfig(defaults, config *azclients.RateLimitConfig) *azclients.RateLimitConfig {
|
||||||
// If config not set, apply defaults.
|
// If config not set, apply defaults.
|
||||||
if config == nil {
|
if config == nil {
|
||||||
return defaults
|
return defaults
|
||||||
@ -102,7 +88,7 @@ func overrideDefaultRateLimitConfig(defaults, config *RateLimitConfig) *RateLimi
|
|||||||
|
|
||||||
// Remain disabled if it's set explicitly.
|
// Remain disabled if it's set explicitly.
|
||||||
if !config.CloudProviderRateLimit {
|
if !config.CloudProviderRateLimit {
|
||||||
return &RateLimitConfig{CloudProviderRateLimit: false}
|
return &azclients.RateLimitConfig{CloudProviderRateLimit: false}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply default values.
|
// Apply default values.
|
||||||
@ -121,26 +107,3 @@ func overrideDefaultRateLimitConfig(defaults, config *RateLimitConfig) *RateLimi
|
|||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
// RateLimitEnabled returns true if CloudProviderRateLimit is set to true.
|
|
||||||
func RateLimitEnabled(config *RateLimitConfig) bool {
|
|
||||||
return config != nil && config.CloudProviderRateLimit
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewRateLimiter creates new read and write flowcontrol.RateLimiter from RateLimitConfig.
|
|
||||||
func NewRateLimiter(config *RateLimitConfig) (flowcontrol.RateLimiter, flowcontrol.RateLimiter) {
|
|
||||||
readLimiter := flowcontrol.NewFakeAlwaysRateLimiter()
|
|
||||||
writeLimiter := flowcontrol.NewFakeAlwaysRateLimiter()
|
|
||||||
|
|
||||||
if config != nil && config.CloudProviderRateLimit {
|
|
||||||
readLimiter = flowcontrol.NewTokenBucketRateLimiter(
|
|
||||||
config.CloudProviderRateLimitQPS,
|
|
||||||
config.CloudProviderRateLimitBucket)
|
|
||||||
|
|
||||||
writeLimiter = flowcontrol.NewTokenBucketRateLimiter(
|
|
||||||
config.CloudProviderRateLimitQPSWrite,
|
|
||||||
config.CloudProviderRateLimitBucketWrite)
|
|
||||||
}
|
|
||||||
|
|
||||||
return readLimiter, writeLimiter
|
|
||||||
}
|
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"k8s.io/legacy-cloud-providers/azure/auth"
|
"k8s.io/legacy-cloud-providers/azure/auth"
|
||||||
|
azclients "k8s.io/legacy-cloud-providers/azure/clients"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -78,7 +79,7 @@ var (
|
|||||||
vmType: "standard"
|
vmType: "standard"
|
||||||
}`
|
}`
|
||||||
|
|
||||||
testDefaultRateLimitConfig = RateLimitConfig{
|
testDefaultRateLimitConfig = azclients.RateLimitConfig{
|
||||||
CloudProviderRateLimit: true,
|
CloudProviderRateLimit: true,
|
||||||
CloudProviderRateLimitBucket: 1,
|
CloudProviderRateLimitBucket: 1,
|
||||||
CloudProviderRateLimitBucketWrite: 1,
|
CloudProviderRateLimitBucketWrite: 1,
|
||||||
@ -106,10 +107,10 @@ func TestParseConfig(t *testing.T) {
|
|||||||
CloudProviderBackoffRetries: 1,
|
CloudProviderBackoffRetries: 1,
|
||||||
CloudProviderRateLimitConfig: CloudProviderRateLimitConfig{
|
CloudProviderRateLimitConfig: CloudProviderRateLimitConfig{
|
||||||
RateLimitConfig: testDefaultRateLimitConfig,
|
RateLimitConfig: testDefaultRateLimitConfig,
|
||||||
LoadBalancerRateLimit: &RateLimitConfig{
|
LoadBalancerRateLimit: &azclients.RateLimitConfig{
|
||||||
CloudProviderRateLimit: false,
|
CloudProviderRateLimit: false,
|
||||||
},
|
},
|
||||||
VirtualMachineScaleSetRateLimit: &RateLimitConfig{
|
VirtualMachineScaleSetRateLimit: &azclients.RateLimitConfig{
|
||||||
CloudProviderRateLimit: true,
|
CloudProviderRateLimit: true,
|
||||||
CloudProviderRateLimitBucket: 2,
|
CloudProviderRateLimitBucket: 2,
|
||||||
CloudProviderRateLimitBucketWrite: 2,
|
CloudProviderRateLimitBucketWrite: 2,
|
||||||
@ -149,10 +150,10 @@ func TestInitializeCloudProviderRateLimitConfig(t *testing.T) {
|
|||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
InitializeCloudProviderRateLimitConfig(&config.CloudProviderRateLimitConfig)
|
InitializeCloudProviderRateLimitConfig(&config.CloudProviderRateLimitConfig)
|
||||||
assert.Equal(t, config.LoadBalancerRateLimit, &RateLimitConfig{
|
assert.Equal(t, config.LoadBalancerRateLimit, &azclients.RateLimitConfig{
|
||||||
CloudProviderRateLimit: false,
|
CloudProviderRateLimit: false,
|
||||||
})
|
})
|
||||||
assert.Equal(t, config.VirtualMachineScaleSetRateLimit, &RateLimitConfig{
|
assert.Equal(t, config.VirtualMachineScaleSetRateLimit, &azclients.RateLimitConfig{
|
||||||
CloudProviderRateLimit: true,
|
CloudProviderRateLimit: true,
|
||||||
CloudProviderRateLimitBucket: 2,
|
CloudProviderRateLimitBucket: 2,
|
||||||
CloudProviderRateLimitBucketWrite: 2,
|
CloudProviderRateLimitBucketWrite: 2,
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
// +build !providerless
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2019 The Kubernetes Authors.
|
Copyright 2019 The Kubernetes Authors.
|
||||||
|
|
||||||
@ -14,4 +16,6 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package azure
|
// Package azure is an implementation of CloudProvider Interface, LoadBalancer
|
||||||
|
// and Instances for Azure.
|
||||||
|
package azure // import "k8s.io/legacy-cloud-providers/azure"
|
||||||
|
@ -12,6 +12,7 @@ go_library(
|
|||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//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/mocks:go_default_library",
|
||||||
"//vendor/k8s.io/klog:go_default_library",
|
"//vendor/k8s.io/klog:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -24,9 +24,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Azure/go-autorest/autorest"
|
"github.com/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/mocks"
|
||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Ensure package autorest/mocks is imported and vendored.
|
||||||
|
var _ autorest.Sender = mocks.NewSender()
|
||||||
|
|
||||||
// Backoff holds parameters applied to a Backoff function.
|
// Backoff holds parameters applied to a Backoff function.
|
||||||
type Backoff struct {
|
type Backoff struct {
|
||||||
// The initial duration.
|
// The initial duration.
|
||||||
|
@ -9,6 +9,7 @@ require (
|
|||||||
github.com/Azure/azure-sdk-for-go v35.0.0+incompatible
|
github.com/Azure/azure-sdk-for-go v35.0.0+incompatible
|
||||||
github.com/Azure/go-autorest/autorest v0.9.0
|
github.com/Azure/go-autorest/autorest v0.9.0
|
||||||
github.com/Azure/go-autorest/autorest/adal v0.5.0
|
github.com/Azure/go-autorest/autorest/adal v0.5.0
|
||||||
|
github.com/Azure/go-autorest/autorest/mocks v0.2.0
|
||||||
github.com/Azure/go-autorest/autorest/to v0.2.0
|
github.com/Azure/go-autorest/autorest/to v0.2.0
|
||||||
github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect
|
github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect
|
||||||
github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20190822182118-27a4ced34534
|
github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20190822182118-27a4ced34534
|
||||||
|
1
staging/src/k8s.io/legacy-cloud-providers/go.sum
generated
1
staging/src/k8s.io/legacy-cloud-providers/go.sum
generated
@ -98,6 +98,7 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
|
|||||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903 h1:LbsanbbD6LieFkXbj9YNNBupiGHJgFeLpO0j0Fza1h8=
|
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903 h1:LbsanbbD6LieFkXbj9YNNBupiGHJgFeLpO0j0Fza1h8=
|
||||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk=
|
||||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
1
vendor/github.com/Azure/go-autorest/autorest/BUILD
generated
vendored
1
vendor/github.com/Azure/go-autorest/autorest/BUILD
generated
vendored
@ -40,6 +40,7 @@ filegroup(
|
|||||||
"//vendor/github.com/Azure/go-autorest/autorest/adal:all-srcs",
|
"//vendor/github.com/Azure/go-autorest/autorest/adal:all-srcs",
|
||||||
"//vendor/github.com/Azure/go-autorest/autorest/azure:all-srcs",
|
"//vendor/github.com/Azure/go-autorest/autorest/azure:all-srcs",
|
||||||
"//vendor/github.com/Azure/go-autorest/autorest/date:all-srcs",
|
"//vendor/github.com/Azure/go-autorest/autorest/date:all-srcs",
|
||||||
|
"//vendor/github.com/Azure/go-autorest/autorest/mocks:all-srcs",
|
||||||
"//vendor/github.com/Azure/go-autorest/autorest/to:all-srcs",
|
"//vendor/github.com/Azure/go-autorest/autorest/to:all-srcs",
|
||||||
"//vendor/github.com/Azure/go-autorest/autorest/validation:all-srcs",
|
"//vendor/github.com/Azure/go-autorest/autorest/validation:all-srcs",
|
||||||
],
|
],
|
||||||
|
26
vendor/github.com/Azure/go-autorest/autorest/mocks/BUILD
generated
vendored
Normal file
26
vendor/github.com/Azure/go-autorest/autorest/mocks/BUILD
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||||
|
|
||||||
|
go_library(
|
||||||
|
name = "go_default_library",
|
||||||
|
srcs = [
|
||||||
|
"helpers.go",
|
||||||
|
"mocks.go",
|
||||||
|
],
|
||||||
|
importmap = "k8s.io/kubernetes/vendor/github.com/Azure/go-autorest/autorest/mocks",
|
||||||
|
importpath = "github.com/Azure/go-autorest/autorest/mocks",
|
||||||
|
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"],
|
||||||
|
)
|
191
vendor/github.com/Azure/go-autorest/autorest/mocks/LICENSE
generated
vendored
Normal file
191
vendor/github.com/Azure/go-autorest/autorest/mocks/LICENSE
generated
vendored
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
Copyright 2015 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.
|
3
vendor/github.com/Azure/go-autorest/autorest/mocks/go.mod
generated
vendored
Normal file
3
vendor/github.com/Azure/go-autorest/autorest/mocks/go.mod
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module github.com/Azure/go-autorest/autorest/mocks
|
||||||
|
|
||||||
|
go 1.12
|
171
vendor/github.com/Azure/go-autorest/autorest/mocks/helpers.go
generated
vendored
Normal file
171
vendor/github.com/Azure/go-autorest/autorest/mocks/helpers.go
generated
vendored
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
package mocks
|
||||||
|
|
||||||
|
// 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 (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// TestAuthorizationHeader is a faux HTTP Authorization header value
|
||||||
|
TestAuthorizationHeader = "BEARER SECRETTOKEN"
|
||||||
|
|
||||||
|
// TestBadURL is a malformed URL
|
||||||
|
TestBadURL = " "
|
||||||
|
|
||||||
|
// TestDelay is the Retry-After delay used in tests.
|
||||||
|
TestDelay = 0 * time.Second
|
||||||
|
|
||||||
|
// TestHeader is the header used in tests.
|
||||||
|
TestHeader = "x-test-header"
|
||||||
|
|
||||||
|
// TestURL is the URL used in tests.
|
||||||
|
TestURL = "https://microsoft.com/a/b/c/"
|
||||||
|
|
||||||
|
// TestAzureAsyncURL is a URL used in Azure asynchronous tests
|
||||||
|
TestAzureAsyncURL = "https://microsoft.com/a/b/c/async"
|
||||||
|
|
||||||
|
// TestLocationURL is a URL used in Azure asynchronous tests
|
||||||
|
TestLocationURL = "https://microsoft.com/a/b/c/location"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
headerLocation = "Location"
|
||||||
|
headerRetryAfter = "Retry-After"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewRequest instantiates a new request.
|
||||||
|
func NewRequest() *http.Request {
|
||||||
|
return NewRequestWithContent("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRequestWithContent instantiates a new request using the passed string for the body content.
|
||||||
|
func NewRequestWithContent(c string) *http.Request {
|
||||||
|
r, _ := http.NewRequest("GET", "https://microsoft.com/a/b/c/", NewBody(c))
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRequestWithCloseBody instantiates a new request.
|
||||||
|
func NewRequestWithCloseBody() *http.Request {
|
||||||
|
return NewRequestWithCloseBodyContent("request body")
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRequestWithCloseBodyContent instantiates a new request using the passed string for the body content.
|
||||||
|
func NewRequestWithCloseBodyContent(c string) *http.Request {
|
||||||
|
r, _ := http.NewRequest("GET", "https://microsoft.com/a/b/c/", NewBodyClose(c))
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRequestForURL instantiates a new request using the passed URL.
|
||||||
|
func NewRequestForURL(u string) *http.Request {
|
||||||
|
return NewRequestWithParams("GET", u, NewBody(""))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRequestWithParams instantiates a new request using the provided parameters.
|
||||||
|
func NewRequestWithParams(method, u string, body io.Reader) *http.Request {
|
||||||
|
r, err := http.NewRequest(method, u, body)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Sprintf("mocks: ERROR (%v) parsing testing URL %s", err, u))
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResponse instantiates a new response.
|
||||||
|
func NewResponse() *http.Response {
|
||||||
|
return NewResponseWithContent("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResponseWithBytes instantiates a new response with the passed bytes as the body content.
|
||||||
|
func NewResponseWithBytes(input []byte) *http.Response {
|
||||||
|
return &http.Response{
|
||||||
|
Status: "200 OK",
|
||||||
|
StatusCode: 200,
|
||||||
|
Proto: "HTTP/1.0",
|
||||||
|
ProtoMajor: 1,
|
||||||
|
ProtoMinor: 0,
|
||||||
|
Body: NewBodyWithBytes(input),
|
||||||
|
Request: NewRequest(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResponseWithContent instantiates a new response with the passed string as the body content.
|
||||||
|
func NewResponseWithContent(c string) *http.Response {
|
||||||
|
return &http.Response{
|
||||||
|
Status: "200 OK",
|
||||||
|
StatusCode: 200,
|
||||||
|
Proto: "HTTP/1.0",
|
||||||
|
ProtoMajor: 1,
|
||||||
|
ProtoMinor: 0,
|
||||||
|
Body: NewBody(c),
|
||||||
|
Request: NewRequest(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResponseWithStatus instantiates a new response using the passed string and integer as the
|
||||||
|
// status and status code.
|
||||||
|
func NewResponseWithStatus(s string, c int) *http.Response {
|
||||||
|
resp := NewResponse()
|
||||||
|
resp.Status = s
|
||||||
|
resp.StatusCode = c
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResponseWithBodyAndStatus instantiates a new response using the specified mock body,
|
||||||
|
// status and status code
|
||||||
|
func NewResponseWithBodyAndStatus(body *Body, c int, s string) *http.Response {
|
||||||
|
resp := NewResponse()
|
||||||
|
resp.Body = body
|
||||||
|
resp.ContentLength = body.Length()
|
||||||
|
resp.Status = s
|
||||||
|
resp.StatusCode = c
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResponseHeader adds a header to the passed response.
|
||||||
|
func SetResponseHeader(resp *http.Response, h string, v string) {
|
||||||
|
if resp.Header == nil {
|
||||||
|
resp.Header = make(http.Header)
|
||||||
|
}
|
||||||
|
resp.Header.Set(h, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetResponseHeaderValues adds a header containing all the passed string values.
|
||||||
|
func SetResponseHeaderValues(resp *http.Response, h string, values []string) {
|
||||||
|
if resp.Header == nil {
|
||||||
|
resp.Header = make(http.Header)
|
||||||
|
}
|
||||||
|
for _, v := range values {
|
||||||
|
resp.Header.Add(h, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAcceptedHeaders adds the headers usually associated with a 202 Accepted response.
|
||||||
|
func SetAcceptedHeaders(resp *http.Response) {
|
||||||
|
SetLocationHeader(resp, TestURL)
|
||||||
|
SetRetryHeader(resp, TestDelay)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLocationHeader adds the Location header.
|
||||||
|
func SetLocationHeader(resp *http.Response, location string) {
|
||||||
|
SetResponseHeader(resp, http.CanonicalHeaderKey(headerLocation), location)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetRetryHeader adds the Retry-After header.
|
||||||
|
func SetRetryHeader(resp *http.Response, delay time.Duration) {
|
||||||
|
SetResponseHeader(resp, http.CanonicalHeaderKey(headerRetryAfter), fmt.Sprintf("%v", delay.Seconds()))
|
||||||
|
}
|
235
vendor/github.com/Azure/go-autorest/autorest/mocks/mocks.go
generated
vendored
Normal file
235
vendor/github.com/Azure/go-autorest/autorest/mocks/mocks.go
generated
vendored
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
/*
|
||||||
|
Package mocks provides mocks and helpers used in testing.
|
||||||
|
*/
|
||||||
|
package mocks
|
||||||
|
|
||||||
|
// 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 (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Body implements acceptable body over a string.
|
||||||
|
type Body struct {
|
||||||
|
s string
|
||||||
|
b []byte
|
||||||
|
isOpen bool
|
||||||
|
closeAttempts int
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewBody creates a new instance of Body.
|
||||||
|
func NewBody(s string) *Body {
|
||||||
|
return (&Body{s: s}).reset()
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewBodyWithBytes creates a new instance of Body.
|
||||||
|
func NewBodyWithBytes(b []byte) *Body {
|
||||||
|
return &Body{
|
||||||
|
b: b,
|
||||||
|
isOpen: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewBodyClose creates a new instance of Body.
|
||||||
|
func NewBodyClose(s string) *Body {
|
||||||
|
return &Body{s: s}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read reads into the passed byte slice and returns the bytes read.
|
||||||
|
func (body *Body) Read(b []byte) (n int, err error) {
|
||||||
|
if !body.IsOpen() {
|
||||||
|
return 0, fmt.Errorf("ERROR: Body has been closed")
|
||||||
|
}
|
||||||
|
if len(body.b) == 0 {
|
||||||
|
return 0, io.EOF
|
||||||
|
}
|
||||||
|
n = copy(b, body.b)
|
||||||
|
body.b = body.b[n:]
|
||||||
|
return n, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close closes the body.
|
||||||
|
func (body *Body) Close() error {
|
||||||
|
if body.isOpen {
|
||||||
|
body.isOpen = false
|
||||||
|
body.closeAttempts++
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloseAttempts returns the number of times Close was called.
|
||||||
|
func (body *Body) CloseAttempts() int {
|
||||||
|
return body.closeAttempts
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsOpen returns true if the Body has not been closed, false otherwise.
|
||||||
|
func (body *Body) IsOpen() bool {
|
||||||
|
return body.isOpen
|
||||||
|
}
|
||||||
|
|
||||||
|
func (body *Body) reset() *Body {
|
||||||
|
body.isOpen = true
|
||||||
|
body.b = []byte(body.s)
|
||||||
|
return body
|
||||||
|
}
|
||||||
|
|
||||||
|
// Length returns the number of bytes in the body.
|
||||||
|
func (body *Body) Length() int64 {
|
||||||
|
if body == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return int64(len(body.b))
|
||||||
|
}
|
||||||
|
|
||||||
|
type response struct {
|
||||||
|
r *http.Response
|
||||||
|
e error
|
||||||
|
d time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sender implements a simple null sender.
|
||||||
|
type Sender struct {
|
||||||
|
attempts int
|
||||||
|
responses []response
|
||||||
|
numResponses int
|
||||||
|
repeatResponse []int
|
||||||
|
err error
|
||||||
|
repeatError int
|
||||||
|
emitErrorAfter int
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSender creates a new instance of Sender.
|
||||||
|
func NewSender() *Sender {
|
||||||
|
return &Sender{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do accepts the passed request and, based on settings, emits a response and possible error.
|
||||||
|
func (c *Sender) Do(r *http.Request) (resp *http.Response, err error) {
|
||||||
|
c.attempts++
|
||||||
|
|
||||||
|
if len(c.responses) > 0 {
|
||||||
|
resp = c.responses[0].r
|
||||||
|
if resp != nil {
|
||||||
|
if b, ok := resp.Body.(*Body); ok {
|
||||||
|
b.reset()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err = c.responses[0].e
|
||||||
|
}
|
||||||
|
time.Sleep(c.responses[0].d)
|
||||||
|
c.repeatResponse[0]--
|
||||||
|
if c.repeatResponse[0] == 0 {
|
||||||
|
c.responses = c.responses[1:]
|
||||||
|
c.repeatResponse = c.repeatResponse[1:]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resp = NewResponse()
|
||||||
|
}
|
||||||
|
if resp != nil {
|
||||||
|
resp.Request = r
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.emitErrorAfter > 0 {
|
||||||
|
c.emitErrorAfter--
|
||||||
|
} else if c.err != nil {
|
||||||
|
err = c.err
|
||||||
|
c.repeatError--
|
||||||
|
if c.repeatError == 0 {
|
||||||
|
c.err = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppendResponse adds the passed http.Response to the response stack.
|
||||||
|
func (c *Sender) AppendResponse(resp *http.Response) {
|
||||||
|
c.AppendAndRepeatResponse(resp, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppendResponseWithDelay adds the passed http.Response to the response stack with the specified delay.
|
||||||
|
func (c *Sender) AppendResponseWithDelay(resp *http.Response, delay time.Duration) {
|
||||||
|
c.AppendAndRepeatResponseWithDelay(resp, delay, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppendAndRepeatResponse adds the passed http.Response to the response stack along with a
|
||||||
|
// repeat count. A negative repeat count will return the response for all remaining calls to Do.
|
||||||
|
func (c *Sender) AppendAndRepeatResponse(resp *http.Response, repeat int) {
|
||||||
|
c.appendAndRepeat(response{r: resp}, repeat)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppendAndRepeatResponseWithDelay adds the passed http.Response to the response stack with the specified
|
||||||
|
// delay along with a repeat count. A negative repeat count will return the response for all remaining calls to Do.
|
||||||
|
func (c *Sender) AppendAndRepeatResponseWithDelay(resp *http.Response, delay time.Duration, repeat int) {
|
||||||
|
c.appendAndRepeat(response{r: resp, d: delay}, repeat)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppendError adds the passed error to the response stack.
|
||||||
|
func (c *Sender) AppendError(err error) {
|
||||||
|
c.AppendAndRepeatError(err, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppendAndRepeatError adds the passed error to the response stack along with a repeat
|
||||||
|
// count. A negative repeat count will return the response for all remaining calls to Do.
|
||||||
|
func (c *Sender) AppendAndRepeatError(err error, repeat int) {
|
||||||
|
c.appendAndRepeat(response{e: err}, repeat)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Sender) appendAndRepeat(resp response, repeat int) {
|
||||||
|
if c.responses == nil {
|
||||||
|
c.responses = []response{resp}
|
||||||
|
c.repeatResponse = []int{repeat}
|
||||||
|
} else {
|
||||||
|
c.responses = append(c.responses, resp)
|
||||||
|
c.repeatResponse = append(c.repeatResponse, repeat)
|
||||||
|
}
|
||||||
|
c.numResponses++
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attempts returns the number of times Do was called.
|
||||||
|
func (c *Sender) Attempts() int {
|
||||||
|
return c.attempts
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetError sets the error Do should return.
|
||||||
|
func (c *Sender) SetError(err error) {
|
||||||
|
c.SetAndRepeatError(err, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAndRepeatError sets the error Do should return and how many calls to Do will return the error.
|
||||||
|
// A negative repeat value will return the error for all remaining calls to Do.
|
||||||
|
func (c *Sender) SetAndRepeatError(err error, repeat int) {
|
||||||
|
c.err = err
|
||||||
|
c.repeatError = repeat
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetEmitErrorAfter sets the number of attempts to be made before errors are emitted.
|
||||||
|
func (c *Sender) SetEmitErrorAfter(ea int) {
|
||||||
|
c.emitErrorAfter = ea
|
||||||
|
}
|
||||||
|
|
||||||
|
// NumResponses returns the number of responses that have been added to the sender.
|
||||||
|
func (c *Sender) NumResponses() int {
|
||||||
|
return c.numResponses
|
||||||
|
}
|
||||||
|
|
||||||
|
// T is a simple testing struct.
|
||||||
|
type T struct {
|
||||||
|
Name string `json:"name" xml:"Name"`
|
||||||
|
Age int `json:"age" xml:"Age"`
|
||||||
|
}
|
3
vendor/modules.txt
vendored
3
vendor/modules.txt
vendored
@ -19,6 +19,8 @@ github.com/Azure/go-autorest/autorest/adal
|
|||||||
github.com/Azure/go-autorest/autorest/azure
|
github.com/Azure/go-autorest/autorest/azure
|
||||||
# github.com/Azure/go-autorest/autorest/date v0.1.0 => github.com/Azure/go-autorest/autorest/date v0.1.0
|
# github.com/Azure/go-autorest/autorest/date v0.1.0 => github.com/Azure/go-autorest/autorest/date v0.1.0
|
||||||
github.com/Azure/go-autorest/autorest/date
|
github.com/Azure/go-autorest/autorest/date
|
||||||
|
# github.com/Azure/go-autorest/autorest/mocks v0.2.0 => github.com/Azure/go-autorest/autorest/mocks v0.2.0
|
||||||
|
github.com/Azure/go-autorest/autorest/mocks
|
||||||
# github.com/Azure/go-autorest/autorest/to v0.2.0 => github.com/Azure/go-autorest/autorest/to v0.2.0
|
# github.com/Azure/go-autorest/autorest/to v0.2.0 => github.com/Azure/go-autorest/autorest/to v0.2.0
|
||||||
github.com/Azure/go-autorest/autorest/to
|
github.com/Azure/go-autorest/autorest/to
|
||||||
# github.com/Azure/go-autorest/autorest/validation v0.1.0 => github.com/Azure/go-autorest/autorest/validation v0.1.0
|
# github.com/Azure/go-autorest/autorest/validation v0.1.0 => github.com/Azure/go-autorest/autorest/validation v0.1.0
|
||||||
@ -1836,6 +1838,7 @@ k8s.io/kubelet/pkg/apis/pluginregistration/v1
|
|||||||
k8s.io/legacy-cloud-providers/aws
|
k8s.io/legacy-cloud-providers/aws
|
||||||
k8s.io/legacy-cloud-providers/azure
|
k8s.io/legacy-cloud-providers/azure
|
||||||
k8s.io/legacy-cloud-providers/azure/auth
|
k8s.io/legacy-cloud-providers/azure/auth
|
||||||
|
k8s.io/legacy-cloud-providers/azure/clients
|
||||||
k8s.io/legacy-cloud-providers/azure/retry
|
k8s.io/legacy-cloud-providers/azure/retry
|
||||||
k8s.io/legacy-cloud-providers/gce
|
k8s.io/legacy-cloud-providers/gce
|
||||||
k8s.io/legacy-cloud-providers/openstack
|
k8s.io/legacy-cloud-providers/openstack
|
||||||
|
Loading…
Reference in New Issue
Block a user