k8s.io/test-infra@v0.0.0-20240520184403-27c6b4c223d8/config/tests/lint/config_lint_test.go (about) 1 /* 2 Copyright 2019 The Kubernetes 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 17 package tests 18 19 import ( 20 "os" 21 "path/filepath" 22 "testing" 23 ) 24 25 var configPath = "../../../config/" 26 27 var exemptPaths = []string{ 28 "prow/cluster/monitoring/mixins/vendor", 29 } 30 31 func Test_ForbidYmlExtension(t *testing.T) { 32 exempt := map[string]bool{} 33 for _, path := range exemptPaths { 34 exempt[filepath.Join(configPath, path)] = true 35 } 36 err := filepath.Walk(configPath, func(path string, info os.FileInfo, err error) error { 37 if _, ok := exempt[path]; ok { 38 return filepath.SkipDir 39 } 40 if filepath.Ext(path) == ".yml" { 41 t.Errorf("*.yml extension not allowed in this repository's configuration; use *.yaml instead (at %s)", path) 42 } 43 return nil 44 }) 45 46 if err != nil { 47 t.Fatal(err) 48 } 49 }