Skip to content

Commit c4b0d90

Browse files
authored
Merge branch 'kubernetes-sigs:master' into update-1.34-examples
2 parents 87548b7 + aa50e43 commit c4b0d90

File tree

71 files changed

+774
-487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+774
-487
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -519,83 +519,6 @@ updates:
519519
- "patch"
520520
- "minor"
521521
- "major"
522-
- package-ecosystem: "gomod"
523-
directory: "/"
524-
open-pull-requests-limit: 1
525-
schedule:
526-
interval: weekly
527-
time: "01:00"
528-
timezone: "Asia/Shanghai"
529-
labels:
530-
- "area/dependency"
531-
- "release-note-none"
532-
- "ok-to-test"
533-
- "kind/cleanup"
534-
- "lgtm"
535-
- "approved"
536-
- "release-1.30"
537-
target-branch: "release-1.30"
538-
ignore:
539-
- dependency-name: "k8s.io/*"
540-
versions: [">=0.31.0"]
541-
- dependency-name: "go"
542-
groups:
543-
all:
544-
applies-to: version-updates
545-
patterns:
546-
- "*"
547-
update-types:
548-
- "patch"
549-
- "minor"
550-
- "major"
551-
- package-ecosystem: "github-actions"
552-
directory: "/"
553-
schedule:
554-
interval: weekly
555-
time: "01:00"
556-
timezone: "Asia/Shanghai"
557-
target-branch: "release-1.30"
558-
labels:
559-
- "area/dependency"
560-
- "release-note-none"
561-
- "ok-to-test"
562-
- "kind/testing"
563-
- "lgtm"
564-
- "approved"
565-
- "release-1.30"
566-
groups:
567-
all:
568-
applies-to: version-updates
569-
patterns:
570-
- "*"
571-
update-types:
572-
- "patch"
573-
- "minor"
574-
- "major"
575-
- package-ecosystem: "docker"
576-
directory: "/"
577-
schedule:
578-
interval: "weekly"
579-
time: "01:00"
580-
timezone: "Asia/Shanghai"
581-
target-branch: "release-1.30"
582-
labels:
583-
- "area/dependency"
584-
- "release-note-none"
585-
- "ok-to-test"
586-
- "kind/cleanup"
587-
- "lgtm"
588-
- "approved"
589-
- "release-1.30"
590-
groups:
591-
all:
592-
applies-to: version-updates
593-
patterns:
594-
- "*"
595-
update-types:
596-
- "patch"
597-
- "minor"
598-
- "major"
599522
- package-ecosystem: "gomod"
600523
directory: "/"
601524
open-pull-requests-limit: 1

.github/workflows/lint-azclient.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
cache-dependency-path: |
3838
pkg/azclient/go.sum
3939
- name: golangci-lint
40-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
40+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
4141
with:
4242
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
43-
version: v1.64
43+
version: v2.5.0
4444
args: -v
4545
verify: true

.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ jobs:
5151
cache-dependency-path: |
5252
go.sum
5353
- name: golangci-lint
54-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6.5.2
54+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
5555
with:
5656
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
57-
version: v1.64
57+
version: v2.5.0
5858
args: -v
5959
install-mode: goinstall
6060
verify: true

.golangci.yml

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,65 @@
1+
version: "2"
12
run:
2-
timeout: 30m
3+
modules-download-mode: mod
34
tests: true
4-
modules-download-mode: vendor
55
linters:
6-
disable-all: true
6+
default: none
77
enable:
8+
- asasalint
9+
- asciicheck
10+
- bidichk
811
- errcheck
9-
- gosimple
10-
- govet
11-
- ineffassign
12-
- staticcheck
13-
- unused
12+
- errorlint
1413
- goconst
15-
- goimports
16-
- revive
1714
- gosec
15+
- govet
16+
- ineffassign
17+
- loggercheck
1818
- misspell
1919
- nakedret
20-
- typecheck
20+
- revive
21+
- staticcheck
2122
- unconvert
22-
- asasalint
23-
- asciicheck
24-
- bidichk
25-
- errorlint
26-
- loggercheck
27-
fast: false
23+
- unused
24+
settings:
25+
goconst:
26+
min-occurrences: 10
27+
gosec:
28+
excludes:
29+
- G114
30+
- G115
31+
staticcheck:
32+
checks:
33+
- all
34+
- -SA1019
35+
exclusions:
36+
generated: lax
37+
presets:
38+
- comments
39+
- common-false-positives
40+
- legacy
41+
- std-error-handling
42+
rules:
43+
- linters:
44+
- revive
45+
path: tests/e2e
46+
paths:
47+
- third_party$
48+
- builtin$
49+
- examples$
2850
issues:
29-
exclude-rules:
30-
- path: tests/e2e
31-
linters:
32-
- revive
3351
max-issues-per-linter: 0
3452
max-same-issues: 0
35-
linters-settings:
36-
staticcheck:
37-
checks: ["all", "-SA1019"]
38-
gosec:
39-
excludes:
40-
- G114
41-
- G115
42-
goimports:
43-
local-prefixes: sigs.k8s.io/cloud-provider-azure
44-
goconst:
45-
min-occurrences: 10
46-
47-
53+
formatters:
54+
enable:
55+
- goimports
56+
settings:
57+
goimports:
58+
local-prefixes:
59+
- sigs.k8s.io/cloud-provider-azure
60+
exclusions:
61+
generated: lax
62+
paths:
63+
- third_party$
64+
- builtin$
65+
- examples$

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# syntax=docker/dockerfile:1
1616

17-
FROM --platform=linux/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.24.8-bookworm@sha256:3b2d4e2a67c649047ffd710a3c65538335a62d5270daebdcbf9e74065fd0690b AS builder
17+
FROM --platform=linux/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.24.9-bookworm@sha256:6b997a6bbbe5a4535e7b2d44db929532ed9ea0d936703a4288110b3c97835069 AS builder
1818

1919
ARG ENABLE_GIT_COMMAND=true
2020
ARG ARCH=amd64

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ delete-workload-cluster:
454454
##@ Tools
455455

456456
LINTER = $(shell pwd)/bin/golangci-lint
457-
LINTER_VERSION = v1.64.8
457+
LINTER_VERSION = v2.5.0
458458
.PHONY: golangci-lint
459459
golangci-lint: ## Download golangci-lint locally if necessary.
460460
@echo "Installing golangci-lint"

cloud-node-manager.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
FROM --platform=linux/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.24.8-bookworm@sha256:3b2d4e2a67c649047ffd710a3c65538335a62d5270daebdcbf9e74065fd0690b AS builder
17+
FROM --platform=linux/amd64 mcr.microsoft.com/oss/go/microsoft/golang:1.24.9-bookworm@sha256:6b997a6bbbe5a4535e7b2d44db929532ed9ea0d936703a4288110b3c97835069 AS builder
1818

1919
ARG ENABLE_GIT_COMMAND=true
2020
ARG ARCH=amd64

cmd/acr-credential-provider/main.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import (
3131
"k8s.io/component-base/logs"
3232
"k8s.io/klog/v2"
3333

34-
"sigs.k8s.io/cloud-provider-azure/pkg/credentialprovider"
3534
"sigs.k8s.io/cloud-provider-azure/pkg/version"
3635
)
3736

@@ -46,22 +45,16 @@ func main() {
4645
Long: `The acr credential provider is responsible for providing ACR credentials for kubelet`,
4746
Args: func(_ *cobra.Command, args []string) error {
4847
if len(args) == 0 {
49-
return errors.New("Config file is not specified")
48+
return errors.New("config file is not specified")
5049
}
5150
if len(args) > 1 {
5251
return fmt.Errorf("expected exactly one argument (config file); Got arguments: %v", args)
5352
}
5453
return nil
5554
},
5655
Version: version.Get().GitVersion,
57-
RunE: func(cmd *cobra.Command, args []string) error {
58-
acrProvider, err := credentialprovider.NewAcrProviderFromConfig(args[0], RegistryMirrorStr)
59-
if err != nil {
60-
klog.Errorf("Failed to initialize ACR provider: %v", err)
61-
return err
62-
}
63-
64-
if err := NewCredentialProvider(acrProvider).Run(cmd.Context()); err != nil {
56+
RunE: func(_ *cobra.Command, args []string) error {
57+
if err := NewCredentialProvider(args[0], RegistryMirrorStr).Run(context.TODO()); err != nil {
6558
klog.Errorf("Error running acr credential provider: %v", err)
6659
return err
6760
}

cmd/acr-credential-provider/plugin.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,18 @@ func init() {
4444

4545
// ExecPlugin implements the exec-based plugin for fetching credentials that is invoked by the kubelet.
4646
type ExecPlugin struct {
47-
plugin credentialprovider.CredentialProvider
47+
configFile string
48+
RegistryMirrorStr string
49+
plugin credentialprovider.CredentialProvider
4850
}
4951

5052
// NewCredentialProvider returns an instance of execPlugin that fetches
5153
// credentials based on the provided plugin implementing the CredentialProvider interface.
52-
func NewCredentialProvider(plugin credentialprovider.CredentialProvider) *ExecPlugin {
53-
return &ExecPlugin{plugin}
54+
func NewCredentialProvider(configFile string, registryMirrorStr string) *ExecPlugin {
55+
return &ExecPlugin{
56+
configFile: configFile,
57+
RegistryMirrorStr: registryMirrorStr,
58+
}
5459
}
5560

5661
// Run executes the credential provider plugin. Required information for the plugin request (in
@@ -85,6 +90,14 @@ func (e *ExecPlugin) runPlugin(ctx context.Context, r io.Reader, w io.Writer, ar
8590
return errors.New("image in plugin request was empty")
8691
}
8792

93+
if e.plugin == nil {
94+
// acr provider plugin are decided at runtime by the request information.
95+
e.plugin, err = credentialprovider.NewAcrProvider(request, e.RegistryMirrorStr, e.configFile)
96+
if err != nil {
97+
return err
98+
}
99+
}
100+
88101
response, err := e.plugin.GetCredentials(ctx, request.Image, args)
89102
if err != nil {
90103
return err

cmd/acr-credential-provider/plugin_test.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package main
1919
import (
2020
"bytes"
2121
"context"
22+
"os"
2223
"reflect"
2324
"testing"
2425
"time"
@@ -79,10 +80,25 @@ func Test_runPlugin(t *testing.T) {
7980

8081
for _, testcase := range testcases {
8182
t.Run(testcase.name, func(t *testing.T) {
82-
p := NewCredentialProvider(&fakePlugin{})
83+
configFile, err := os.CreateTemp(".", "config.json")
84+
if err != nil {
85+
t.Fatalf("Unexpected error when creating temp file: %v", err)
86+
}
87+
defer os.Remove(configFile.Name())
8388

89+
_, err = configFile.WriteString(`
90+
{
91+
"aadClientId": "foo",
92+
"aadClientSecret": "bar"
93+
}`)
94+
if err != nil {
95+
t.Fatalf("Unexpected error when writing to temp file: %v", err)
96+
}
97+
p := NewCredentialProvider(configFile.Name(), "mcr.microsoft.com:fakeacrname.azurecr.io")
98+
p.plugin = &fakePlugin{}
8499
out := &bytes.Buffer{}
85-
err := p.runPlugin(context.TODO(), testcase.in, out, nil)
100+
101+
err = p.runPlugin(context.TODO(), testcase.in, out, []string{configFile.Name(), "--registry-mirror=mcr.microsoft.com:fakeacrname.azurecr.io"})
86102
if err != nil && !testcase.expectErr {
87103
t.Fatal(err)
88104
}

0 commit comments

Comments
 (0)