Skip to content

Commit 4807b85

Browse files
authored
Merge pull request #20857 from ivanvc/update-fix-yamllint-to-use-new-script
Update fix-yamllint Makefile target to use stand-alone script
2 parents 69b9f4e + b16a46e commit 4807b85

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

Makefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,9 @@ endif
168168
verify-markdown-marker:
169169
PASSES="markdown_marker" ./scripts/test.sh
170170

171-
YAMLFMT_VERSION = $(shell cd tools/mod && go list -m -f '{{.Version}}' github.com/google/yamlfmt)
172-
173171
.PHONY: fix-yamllint
174172
fix-yamllint:
175-
ifeq (, $(shell command -v yamlfmt))
176-
$(shell go install github.com/google/yamlfmt/cmd/yamlfmt@$(YAMLFMT_VERSION))
177-
endif
178-
yamlfmt -conf tools/.yamlfmt .
173+
./scripts/fix/yamllint.sh
179174

180175
.PHONY: run-govulncheck
181176
run-govulncheck:

scripts/fix/yamllint.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2025 The etcd Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# Fixes linter issues in YAML files.
17+
18+
set -euo pipefail
19+
20+
ETCD_ROOT_DIR=${ETCD_ROOT_DIR:-$(git rev-parse --show-toplevel)}
21+
source "${ETCD_ROOT_DIR}/scripts/test_lib.sh"
22+
23+
function main {
24+
run_go_tool github.com/google/yamlfmt/cmd/yamlfmt \
25+
-conf "${ETCD_ROOT_DIR}/tools/.yamlfmt" .
26+
}
27+
28+
# only run when called directly, not sourced
29+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
30+
main
31+
fi

0 commit comments

Comments
 (0)