Skip to content

Commit

Permalink
Merge pull request #4180 from MartinForReal/shafan/azclientsecret
Browse files Browse the repository at this point in the history
track2 sdk: add config loader
  • Loading branch information
k8s-ci-robot authored Jun 29, 2023
2 parents 7650475 + 7ee24f6 commit 33b0311
Show file tree
Hide file tree
Showing 22 changed files with 1,402 additions and 40 deletions.
2 changes: 1 addition & 1 deletion pkg/azclient/client-gen/generator/codegenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (g Generator) Generate(ctx *genall.GenerationContext) error {
})
if err != nil {
root.AddError(err)
break
return err
}
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/azclient/client-gen/generator/genclientfactory_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ type ClientFactoryImpl struct {
{{end -}}
}
func NewClientFactory(config *ClientFactoryConfig, cred azcore.TokenCredential) (ClientFactory,error) {
func NewClientFactory(config *ClientFactoryConfig, armConfig *ARMClientConfig, cred azcore.TokenCredential) (ClientFactory,error) {
if config == nil {
config = &ClientFactoryConfig{}
}
Expand All @@ -157,7 +157,8 @@ func NewClientFactory(config *ClientFactoryConfig, cred azcore.TokenCredential)
{{ $rateLimitPolicyNotDefined := true -}}
{{range $key, $client := . }}
options, err = GetDefaultResourceClientOption(config)
//initialize {{$client}}
options, err = GetDefaultResourceClientOption(armConfig, config)
if err != nil {
return nil, err
}
Expand All @@ -176,7 +177,7 @@ func NewClientFactory(config *ClientFactoryConfig, cred azcore.TokenCredential)
if err != nil {
return nil, err
}
{{end -}}
{{end}}
return &ClientFactoryImpl{
ClientFactoryConfig: config,
cred: cred,
Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions pkg/azclient/configloader/config_loader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2023 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 configloader

import (
"context"

"sigs.k8s.io/cloud-provider-azure/pkg/azclient"
)

type ConfigLoader[Type any] interface {
Load(ctx context.Context) (*Type, error)
}

type FactoryConfigLoader ConfigLoader[azclient.ClientFactoryConfig]
type AuthConfigLoader ConfigLoader[azclient.AzureAuthConfig]
29 changes: 29 additions & 0 deletions pkg/azclient/configloader/configloader_suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright 2023 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 configloader_test

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestConfigloader(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Configloader Suite")
}
76 changes: 76 additions & 0 deletions pkg/azclient/configloader/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module sigs.k8s.io/cloud-provider-azure/pkg/azclient/configloader

go 1.20

require (
github.com/golang/mock v1.6.0
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.8
k8s.io/api v0.27.3
k8s.io/apimachinery v0.27.3
k8s.io/client-go v0.27.3
sigs.k8s.io/cloud-provider-azure/pkg/azclient v0.0.0
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.0.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4 v4.0.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v3 v3.0.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/privatedns/armprivatedns v1.1.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect
github.com/Azure/go-armbalancer v0.0.2 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20230602010524-ada837c32108 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
go.opentelemetry.io/otel v1.16.0 // indirect
go.opentelemetry.io/otel/metric v1.16.0 // indirect
go.opentelemetry.io/otel/trace v1.16.0 // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/oauth2 v0.9.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/term v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.3 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230505201702-9f6742963106 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)

replace sigs.k8s.io/cloud-provider-azure/pkg/azclient => ../
Loading

0 comments on commit 33b0311

Please sign in to comment.