mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-17 05:48:21 +00:00
feat: ignore hidden feature files
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
This commit is contained in:
parent
b7aa0b2273
commit
6c895b496a
3 changed files with 15 additions and 4 deletions
|
@ -234,10 +234,12 @@ further be used in label rules specified in
|
||||||
[`custom`](#custom-feature-source) feature source.
|
[`custom`](#custom-feature-source) feature source.
|
||||||
|
|
||||||
> **NOTE:** Be careful when creating and/or updating hook or feature files
|
> **NOTE:** Be careful when creating and/or updating hook or feature files
|
||||||
> while NFD is running. In order to avoid race conditions you should write into
|
> while NFD is running. In order to avoid race conditions you should write
|
||||||
> a temporary file (outside the `source.d` and `features.d` directories), and,
|
> into a temporary file, and atomically create/update the original file by
|
||||||
> atomically create/update the original file by doing a filesystem move
|
> doing a file rename operation. NFD ignores dot files,
|
||||||
> operation.
|
> so temporary file can be written to the same directory and renamed
|
||||||
|
> (`.my.feature` -> `my.feature`) once file is complete. Both file names should
|
||||||
|
> (obviously) be unique for the given application.
|
||||||
|
|
||||||
### An example
|
### An example
|
||||||
|
|
||||||
|
|
|
@ -248,6 +248,10 @@ func getFeaturesFromHooks() (map[string]string, error) {
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
fileName := file.Name()
|
fileName := file.Name()
|
||||||
|
// ignore hidden feature file
|
||||||
|
if strings.HasPrefix(fileName, ".") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
lines, err := runHook(fileName)
|
lines, err := runHook(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.ErrorS(err, "failed to run hook", "fileName", fileName)
|
klog.ErrorS(err, "failed to run hook", "fileName", fileName)
|
||||||
|
@ -324,6 +328,10 @@ func getFeaturesFromFiles() (map[string]string, error) {
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
fileName := file.Name()
|
fileName := file.Name()
|
||||||
|
// ignore hidden feature file
|
||||||
|
if strings.HasPrefix(fileName, ".") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
lines, err := getFileContent(fileName)
|
lines, err := getFileContent(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.ErrorS(err, "failed to read file", "fileName", fileName)
|
klog.ErrorS(err, "failed to read file", "fileName", fileName)
|
||||||
|
|
1
source/local/testdata/features.d/.my.feature
vendored
Normal file
1
source/local/testdata/features.d/.my.feature
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
hiddenFeatureKey=hiddenFeatureValue
|
Loading…
Add table
Reference in a new issue