Skip to content

Commit 730e1a5

Browse files
committed
Merge remote-tracking branch 'upstream/main' into dev/mogliang/fixcache
2 parents e9e142d + e6bd3f3 commit 730e1a5

File tree

668 files changed

+43919
-20624
lines changed

Some content is hidden

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

668 files changed

+43919
-20624
lines changed

.github/workflows/pr-dependabot.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Check out code into the Go module directory
22-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
22+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
2323
- name: Calculate go version
2424
id: vars
2525
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
2626
- name: Set up Go
2727
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # tag=v5.5.0
2828
with:
2929
go-version: ${{ steps.vars.outputs.go_version }}
30-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # tag=v4.2.3
30+
- uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # tag=v4.2.4
3131
name: Restore go cache
3232
with:
3333
path: |

.github/workflows/pr-golangci-lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- test
2020
- hack/tools
2121
steps:
22-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
22+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
2323
- name: Calculate go version
2424
id: vars
2525
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
@@ -30,7 +30,7 @@ jobs:
3030
- name: golangci-lint
3131
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # tag=v8.0.0
3232
with:
33-
version: v2.1.0
33+
version: v2.3.0
3434
working-directory: ${{matrix.working-directory}}
3535
- name: Lint API
3636
run: make lint-api

.github/workflows/pr-md-link-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
name: Broken Links
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
17+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
1818
- uses: gaurav-nelson/github-action-markdown-link-check@3c3b66f1f7d0900e37b71eca45b63ea9eedfce31 # tag=1.0.17
1919
with:
2020
use-quiet-mode: 'yes'

.github/workflows/pr-verify.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
12+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
1313

1414
- name: Check if PR title is valid
1515
env:

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
release_tag: ${{ steps.release-version.outputs.release_version }}
1818
steps:
1919
- name: Checkout code
20-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
20+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
2121
with:
2222
fetch-depth: 0
2323
- name: Get changed files
@@ -88,7 +88,7 @@ jobs:
8888
env:
8989
RELEASE_TAG: ${{needs.push_release_tags.outputs.release_tag}}
9090
- name: checkout code
91-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
91+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
9292
with:
9393
fetch-depth: 0
9494
ref: ${{ env.RELEASE_TAG }}

.github/workflows/weekly-md-link-check.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
branch: [ main, release-1.10, release-1.9, release-1.8 ]
17+
branch: [ main, release-1.11, release-1.10, release-1.9 ]
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
20+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
2121
with:
2222
ref: ${{ matrix.branch }}
2323
- uses: gaurav-nelson/github-action-markdown-link-check@3c3b66f1f7d0900e37b71eca45b63ea9eedfce31 # tag=1.0.17

.github/workflows/weekly-security-scan.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
branch: [ main, release-1.10, release-1.9, release-1.8 ]
16+
branch: [ main, release-1.11, release-1.10, release-1.9 ]
1717
name: Trivy
1818
runs-on: ubuntu-latest
1919
steps:
2020
- name: Check out code
21-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
21+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
2222
with:
2323
ref: ${{ matrix.branch }}
2424
- name: Calculate go version

.github/workflows/weekly-test-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
branch: [ main, release-1.10, release-1.9, release-1.8 ]
20+
branch: [ main, release-1.11, release-1.10, release-1.9 ]
2121
runs-on: ubuntu-latest
2222
steps:
23-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
23+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
2424
with:
2525
ref: ${{ matrix.branch }}
2626
fetch-depth: 0

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ hack/tools/bin
1414
test/e2e/data/infrastructure-docker/**/cluster-template*.yaml
1515
!test/e2e/data/infrastructure-docker/**/clusterclass-quick-start.yaml
1616
!test/e2e/data/infrastructure-docker/**/clusterclass-quick-start-runtimesdk.yaml
17+
!test/e2e/data/infrastructure-docker/**/clusterclass-quick-start-runtimesdk-v1beta1.yaml
1718
!test/e2e/data/infrastructure-docker/**/cluster-template-in-memory.yaml
1819
!test/e2e/data/infrastructure-docker/**/clusterclass-in-memory.yaml
1920
test/e2e/data/infrastructure-docker/**/clusterclass-*.yaml

.golangci-kal.yml

Lines changed: 74 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,23 @@ linters:
1616
enable:
1717
- "commentstart" # Ensure comments start with the serialized version of the field name.
1818
- "conditions" # Ensure conditions have the correct json tags and markers.
19+
- "conflictingmarkers"
1920
- "duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields.
2021
- "integers" # Ensure only int32 and int64 are used for integers.
2122
- "jsontags" # Ensure every field has a json tag.
2223
- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
2324
- "nobools" # Bools do not evolve over time, should use enums instead.
2425
- "nofloats" # Ensure floats are not used.
2526
- "nomaps" # Ensure maps are not used.
27+
- "notimestamp" # Prevents usage of 'Timestamp' fields
28+
- "optionalfields" # Ensure that all fields marked as optional adhere to being pointers and
29+
# having the `omitempty` value in their `json` tag where appropriate.
2630
- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
2731
- "requiredfields" # Required fields should not be pointers, and should not have `omitempty`.
32+
- "ssatags" # Ensure array fields have the appropriate listType markers
2833
- "statusoptional" # Ensure all first children within status should be optional.
2934
- "statussubresource" # All root objects that have a `status` field should have a status subresource.
35+
- "uniquemarkers" # Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
3036

3137
# Per discussion in July 2024, we are keeping phase fields for now.
3238
# See https://github.com/kubernetes-sigs/cluster-api/pull/10897#discussion_r1685929508
@@ -37,17 +43,23 @@ linters:
3743
disable:
3844
- "*" # We will manually enable new linters after understanding the impact. Disable all by default.
3945
lintersConfig:
46+
conflictingmarkers:
47+
conflicts:
48+
- name: "default_vs_required"
49+
sets:
50+
- ["default", "kubebuilder:default"]
51+
- ["required", "kubebuilder:validation:Required", "k8s:required"]
52+
description: "A field with a default value cannot be required"
4053
conditions:
4154
isFirstField: Warn # Require conditions to be the first field in the status struct.
42-
usePatchStrategy: Forbid # Require conditions to be the first field in the status struct.
55+
usePatchStrategy: Forbid # Forbid patchStrategy markers on the Conditions field.
4356
useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required.
44-
# jsonTags:
45-
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
46-
# optionalOrRequired:
47-
# preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
48-
# preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
49-
# requiredFields:
50-
# pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers.
57+
optionalfields:
58+
pointers:
59+
preference: WhenRequired # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
60+
policy: SuggestFix # SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
61+
omitempty:
62+
policy: SuggestFix # SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
5163

5264
exclusions:
5365
generated: strict
@@ -63,86 +75,96 @@ linters:
6375
linters:
6476
- kubeapilinter
6577

66-
## Excludes that can be removed once v1alpha1/v1beta1 apiVersions are dropped
67-
68-
# .status.deprecated.v1beta1.conditions fields are using v1beta1.Condition types, these fields will be removed once v1alpha1/v1beta1 is removed.
69-
- path: "api/addons/v1beta2/*|api/bootstrap/kubeadm/v1beta2/*|api/controlplane/kubeadm/v1beta2/*|api/core/v1beta2/*|api/ipam/v1beta2/*|api/runtime/v1beta2/*|api/addons/v1beta1/*|api/bootstrap/kubeadm/v1beta1/*|api/controlplane/kubeadm/v1beta1/*|api/core/v1beta1/*|api/ipam/v1beta1/*|api/ipam/v1alpha1/*|api/runtime/v1alpha1/*"
70-
text: "Conditions field must be a slice of metav1.Condition"
78+
## Excludes for old apiVersions that can be removed once the apiVersions are dropped (we don't want to make any changes to these APIs).
79+
- path: "api/addons/v1beta1|api/bootstrap/kubeadm/v1beta1|api/controlplane/kubeadm/v1beta1|api/core/v1beta1|api/ipam/v1beta1|api/ipam/v1alpha1|api/runtime/v1alpha1"
7180
linters:
7281
- kubeapilinter
73-
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
74-
text: "field Conditions type Conditions must have a maximum items, add kubebuilder:validation:MaxItems marker"
82+
83+
## Excludes for current apiVersions that can be removed once v1beta1 is removed.
84+
# .status.deprecated.v1beta1.conditions fields are using v1beta1.Condition types.
85+
- path: "api/addons/v1beta2|api/bootstrap/kubeadm/v1beta2|api/controlplane/kubeadm/v1beta2|api/core/v1beta2|api/ipam/v1beta2|api/runtime/v1beta2"
86+
text: "Conditions field in .*V1Beta1DeprecatedStatus must be a slice of metav1.Condition"
7587
linters:
7688
- kubeapilinter
77-
# excludes for v1alpha1/v1beta1 API packages
78-
- path: "api/core/v1beta1/*"
79-
text: "type ClusterIPFamily should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
89+
- path: "api/addons/v1beta2|api/bootstrap/kubeadm/v1beta2|api/controlplane/kubeadm/v1beta2|api/core/v1beta2|api/ipam/v1beta2|api/runtime/v1beta2"
90+
text: "ssatags: Conditions should have a listType marker for proper Server-Side Apply behavior"
8091
linters:
8192
- kubeapilinter
82-
- path: "api/ipam/v1alpha1/*|api/ipam/v1beta1/*"
83-
text: "field Prefix should not use an int, int8 or int16. Use int32 or int64 depending on bounding requirements"
93+
- path: "api/core/v1beta2"
94+
text: "field Conditions type Conditions must have a maximum items, add kubebuilder:validation:MaxItems marker"
8495
linters:
8596
- kubeapilinter
86-
- path: "api/core/v1beta1/*"
87-
text: "field Addresses type MachineAddresses must have a maximum items, add kubebuilder:validation:MaxItems marker"
97+
- path: "api/core/v1beta2/condition_types.go"
98+
text: "requiredfields: field (Type|Status|LastTransitionTime) should have the omitempty tag"
8899
linters:
89100
- kubeapilinter
90-
- path: "api/bootstrap/kubeadm/v1beta1/*"
91-
text: "nomaps: APIEndpoints should not use a map type, use a list type with a unique name/identifier instead"
101+
102+
## Excludes for current clusterctl v1alpha3 and Runtime Hooks v1alpha1 apiVersions (can be fixed once we bump their apiVersion).
103+
# Note: The types in api/runtime/hooks/v1alpha1 are not CRDs, so e.g. SSA markers don't make sense there.
104+
- path: "cmd/clusterctl/api/v1alpha3|api/runtime/hooks/v1alpha1"
105+
text: "optionalfields|requiredfields|maxlength|ssatags"
92106
linters:
93107
- kubeapilinter
94-
- path: "api/core/v1beta1/*"
95-
text: "nomaps: FailureDomains should not use a map type, use a list type with a unique name/identifier instead"
108+
109+
## Excludes for JSONSchemaProps
110+
# We want to align to the JSON tags of the CustomResourceDefinition fields.
111+
- path: "api/core/v1beta2/clusterclass_types"
112+
text: "field (XPreserveUnknownFields|XPreserveUnknownFields|XValidations|XMetadata|XIntOrString) json tag does not match pattern"
96113
linters:
97114
- kubeapilinter
98-
99-
## Excludes for clusterctl and Runtime Hooks (can be fixed once we bump their apiVersion)
100-
- path: "cmd/clusterctl/api/v1alpha3|api/runtime/hooks/v1alpha1"
101-
text: "maxlength"
115+
# We want to align Properties to the corresponding field in CustomResourceDefinitions.
116+
- path: "api/core/v1beta2/clusterclass_types"
117+
text: "Properties should not use a map type, use a list type with a unique name/identifier instead"
102118
linters:
103119
- kubeapilinter
104-
105-
## controller-gen does not allow to add MaxItems to Schemaless fields
106-
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
107-
text: "maxlength: field (AllOf|OneOf|AnyOf) must have a maximum items, add kubebuilder:validation:MaxItems marker"
120+
# It's simpler to check these fields against nil vs. using reflect.DeepEqual everywhere.
121+
- path: "api/core/v1beta2/clusterclass_types.go"
122+
text: "optionalfields: field (AdditionalProperties|Items|Not) does not allow the zero value. (The field does not need to be a pointer|It must have the omitzero tag)"
108123
linters:
109124
- kubeapilinter
110125

111126
## Removal of bool fields of existing types requires further discussion
112-
- path: "api/bootstrap/kubeadm/v1beta2/*|api/controlplane/kubeadm/v1beta2/*|api/core/v1beta2/*|api/addons/v1beta2/*|api/bootstrap/kubeadm/v1beta1/*|api/controlplane/kubeadm/v1beta1/*|api/v1alpha1/*|api/core/v1beta1/*|api/addons/v1beta1/*"
127+
- path: "api/bootstrap/kubeadm/v1beta2|api/controlplane/kubeadm/v1beta2|api/core/v1beta2|api/addons/v1beta2"
113128
text: "nobools"
114129
linters:
115130
- kubeapilinter
116131

117-
## Excludes for JSONSchemaProps
118-
# We want to align to the JSON tags of the CustomResourceDefinition fields.
119-
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
120-
text: "field (XPreserveUnknownFields|XPreserveUnknownFields|XValidations|XMetadata|XIntOrString) json tag does not match pattern"
132+
## Excludes for kubeadm types
133+
# We want to align the FeatureGates field to the FeatureGates field in kubeadm.
134+
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go"
135+
text: "nomaps: FeatureGates should not use a map type, use a list type with a unique name/identifier instead"
121136
linters:
122137
- kubeapilinter
123-
# We want to align Properties to the corresponding field in CustomResourceDefinitions.
124-
- path: "api/core/v1beta2/*|api/core/v1beta1/*"
125-
text: "Properties should not use a map type, use a list type with a unique name/identifier instead"
138+
139+
## Excludes for requiredfields
140+
# Empty Bootstrap object is blocked via validating webhooks. This cannot be detected by KAL (same if we move the validation to CEL).
141+
- path: "api/core/v1beta2/machine_types.go"
142+
text: "requiredfields: field Bootstrap has a valid zero value \\({}\\), but the validation is not complete \\(e.g. min properties/adding required fields\\). The field should be a pointer to allow the zero value to be set. If the zero value is not a valid use case, complete the validation and remove the pointer."
126143
linters:
127144
- kubeapilinter
128145

129-
## Excludes for kubeadm types
130-
# We want to align the FeatureGates field to the FeatureGates field in kubeadm.
131-
- path: "api/bootstrap/kubeadm/v1beta2/*|api/bootstrap/kubeadm/v1beta1/*"
132-
text: "nomaps: FeatureGates should not use a map type, use a list type with a unique name/identifier instead"
146+
## Excludes for optionalfields
147+
## The ExtraEnvs field intentionally has type *[]EnvVar.
148+
## Today we have MinItems=1, but we might have to support MinItems=0 in the future if kubeadm starts supporting it.
149+
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go"
150+
text: "optionalfields: field ExtraEnvs does not allow the zero value. The field does not need to be a pointer."
133151
linters:
134152
- kubeapilinter
135153

136-
## TODO: The following rules are disabled until we migrate to the new API.
137-
# Note: Maybe this has to stay a pointer for marshalling reasons.
138-
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go|api/bootstrap/kubeadm/v1beta1/kubeadm_types.go"
139-
text: "field Token is marked as required, should not be a pointer"
154+
# TODO: Excludes that should be removed once the corresponding issues in KAL are fixed
155+
# KAL incorrectly reports that the Taints field doesn't have to be a pointer (it has to be to preserve []).
156+
# See: https://github.com/kubernetes-sigs/kube-api-linter/issues/116
157+
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go"
158+
text: "optionalfields: field Taints underlying type does not need to be a pointer. The pointer should be removed."
140159
linters:
141160
- kubeapilinter
142-
- path: "api/core/v1beta2/clusterclass_types.go|api/core/v1beta1/clusterclass_types.go"
143-
text: "field Ref is marked as required, should not be a pointer"
161+
# KAL incorrectly reports that the zero value is valid
162+
# See: https://github.com/kubernetes-sigs/kube-api-linter/issues/138
163+
- path: "api/bootstrap/kubeadm/v1beta2/kubeadm_types.go"
164+
text: "requiredfields: field Token has a valid zero value \\({\"\": \"\", \"\": \"\"}\\) and should be a pointer."
144165
linters:
145166
- kubeapilinter
167+
146168
issues:
147169
max-same-issues: 0
148170
max-issues-per-linter: 0

0 commit comments

Comments
 (0)