Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: '1.24.0'
go-version: '1.25.0'
cache-dependency-path: |
${{ env.GOPATH}}/src/k8s.io/autoscaler/cluster-autoscaler/go.sum
${{ env.GOPATH}}/src/k8s.io/autoscaler/vertical-pod-autoscaler/go.sum
Expand Down
2 changes: 2 additions & 0 deletions hack/install-verify-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ go install github.com/tools/godep@latest

go install github.com/client9/misspell/cmd/misspell@latest

go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest

# ex: ts=2 sw=2 et filetype=sh
6 changes: 6 additions & 0 deletions hack/tools/.custom-gcl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: v2.5.0
name: golangci-kube-api-linter
destination: ./bin
plugins:
- module: 'sigs.k8s.io/kube-api-linter'
version: v0.0.0-20250908163129-65a570bd22aa
53 changes: 53 additions & 0 deletions hack/tools/.golangci-kal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: "2"
run:
go: "1.25"
allow-parallel-runners: true
linters:
default: none
enable:
- kubeapilinter # linter for Kube API conventions
settings:
custom:
kubeapilinter:
type: module
description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices.
settings:
linters:
enable:
#- "commentstart" # Ensure comments start with the serialized version of the field name.
#- "conditions" # Ensure conditions have the correct json tags and markers.
#- "conflictingmarkers"
#- "duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields.
#- "integers" # Ensure only int32 and int64 are used for integers.
#- "jsontags" # Ensure every field has a json tag.
#- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
#- "nobools" # Bools do not evolve over time, should use enums instead.
#- "nodurations" # Prevents usage of `Duration` types.
#- "nofloats" # Ensure floats are not used.
#- "nomaps" # Ensure maps are not used.
#- "nonullable" # Ensure that types and fields do not have the nullable marker.
#- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
#- "requiredfields" # Required fields should not be pointers, and should not have `omitempty`.
#- "ssatags" # Ensure array fields have the appropriate listType markers
#- "statusoptional" # Ensure all first children within status should be optional.
#- "statussubresource" # All root objects that have a `status` field should have a status subresource.
#- "uniquemarkers" # Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
disable:
- "*" # Disable all by default.
lintersConfig:


exclusions:
build-tags:
- ignore_autogenerated
paths:
- ".*_test.go" # Exclude test files.
rules:
## KAL should only run on APIS folders.
- path-except: "apis//*"
linters:
- kubeapilinter

issues:
max-same-issues: 0
max-issues-per-linter: 0
47 changes: 47 additions & 0 deletions hack/verify-kubelint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Copyright 2014 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.

set -o errexit
set -o nounset
set -o pipefail

echo "verify-kubelint"

KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
cd "${KUBE_ROOT}"
ROOT_DIR="$PWD"

TOOLS_DIR="${ROOT_DIR}/hack/tools"
TOOLS_BIN_DIR="${TOOLS_DIR}/bin"

GOLANGCI_LINT_BIN=${GOLANGCI_LINT_BIN:-"golangci-lint"}
GOLANGCI_LINT_KAL_BIN=${GOLANGCI_LINT_KAL_BIN:-"${TOOLS_BIN_DIR}/golangci-kube-api-linter"}
GOLANGCI_LINT_CONFIG_PATH=${GOLANGCI_LINT_CONFIG_PATH:-"${TOOLS_DIR}/.golangci-kal.yml"}

echo "creating custom golangci linter"
cd "${TOOLS_DIR}"; "${GOLANGCI_LINT_BIN}" custom

cd "${ROOT_DIR}"

PACKAGES=(
"${ROOT_DIR}/cluster-autoscaler"
"${ROOT_DIR}/vertical-pod-autoscaler"
)

for package in "${PACKAGES[@]}"; do
cd "${package}"
"${GOLANGCI_LINT_KAL_BIN}" run -v --config "${GOLANGCI_LINT_CONFIG_PATH}"
done
Loading