Skip to content

Commit d1bb965

Browse files
authored
Merge pull request kubernetes#2521 from wojtek-t/canonical_files
Minor kepval changes to better validate dir-based templates
2 parents d3f05de + 013ff70 commit d1bb965

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

pkg/kepval/repository.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,26 @@ var walkFn = func(path string, info os.FileInfo, err error) error {
127127
dir := filepath.Dir(path)
128128
// true if the file is a symlink
129129
if info.Mode()&os.ModeSymlink != 0 {
130-
// assume symlink from old KEP location to new
131-
newLocation, err := os.Readlink(path)
132-
if err != nil {
133-
return err
134-
}
130+
// Assume symlink from old KEP location to new. The new location
131+
// will be processed separately, so no need to process it here.
132+
return nil
133+
}
135134

136-
files = append(files, filepath.Join(dir, filepath.Dir(newLocation), kepMetadata))
135+
metadataFile := filepath.Join(dir, kepMetadata)
136+
if _, err := os.Stat(metadataFile); err == nil {
137+
// There is kep metadata file in this directory, only that one should be processed.
138+
if info.Name() == kepMetadata {
139+
files = append(files, metadataFile)
140+
}
137141
return nil
138142
}
139143

140144
if ignore(dir, info.Name()) {
141145
return nil
142146
}
143147

148+
// TODO(#2220): Return an error as soon as all KEPs are migrated to directory-based
149+
// KEP format.
144150
files = append(files, path)
145151
return nil
146152
}
@@ -149,21 +155,12 @@ var walkFn = func(path string, info os.FileInfo, err error) error {
149155
// TODO: Is this a duplicate of the package function?
150156
// ignore certain files in the keps/ subdirectory
151157
func ignore(dir, name string) bool {
152-
if dir == "../keps/NNNN-kep-template" {
153-
return true // ignore the template directory because its metadata file does not use a valid sig name
154-
}
155-
156-
if name == kepMetadata {
157-
return false // always check metadata files
158-
}
159-
160158
if !strings.HasSuffix(name, "md") {
161159
return true
162160
}
163161

164162
if name == "0023-documentation-for-images.md" ||
165163
name == "0004-cloud-provider-template.md" ||
166-
name == "YYYYMMDD-kep-template.md" ||
167164
name == "README.md" ||
168165
name == "kep-faq.md" {
169166
return true

0 commit comments

Comments
 (0)