Skip to content

Commit 6c895b4

Browse files
committed
feat: ignore hidden feature files
Signed-off-by: AhmedGrati <[email protected]>
1 parent b7aa0b2 commit 6c895b4

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

docs/usage/customization-guide.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,12 @@ further be used in label rules specified in
234234
[`custom`](#custom-feature-source) feature source.
235235

236236
> **NOTE:** Be careful when creating and/or updating hook or feature files
237-
> while NFD is running. In order to avoid race conditions you should write into
238-
> a temporary file (outside the `source.d` and `features.d` directories), and,
239-
> atomically create/update the original file by doing a filesystem move
240-
> operation.
237+
> while NFD is running. In order to avoid race conditions you should write
238+
> into a temporary file, and atomically create/update the original file by
239+
> doing a file rename operation. NFD ignores dot files,
240+
> so temporary file can be written to the same directory and renamed
241+
> (`.my.feature` -> `my.feature`) once file is complete. Both file names should
242+
> (obviously) be unique for the given application.
241243

242244
### An example
243245

source/local/local.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ func getFeaturesFromHooks() (map[string]string, error) {
248248

249249
for _, file := range files {
250250
fileName := file.Name()
251+
// ignore hidden feature file
252+
if strings.HasPrefix(fileName, ".") {
253+
continue
254+
}
251255
lines, err := runHook(fileName)
252256
if err != nil {
253257
klog.ErrorS(err, "failed to run hook", "fileName", fileName)
@@ -324,6 +328,10 @@ func getFeaturesFromFiles() (map[string]string, error) {
324328

325329
for _, file := range files {
326330
fileName := file.Name()
331+
// ignore hidden feature file
332+
if strings.HasPrefix(fileName, ".") {
333+
continue
334+
}
327335
lines, err := getFileContent(fileName)
328336
if err != nil {
329337
klog.ErrorS(err, "failed to read file", "fileName", fileName)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hiddenFeatureKey=hiddenFeatureValue

0 commit comments

Comments
 (0)