mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-07 01:56:57 +02:00
chore(docs): moved to folder internal/gen/docs/flags
Signed-off-by: ivan katliarchuk <ivan.katliarchuk@gmail.com>
This commit is contained in:
parent
1fdc578012
commit
02cb8a6f6b
@ -1,7 +1,7 @@
|
|||||||
# Flags
|
# Flags
|
||||||
|
|
||||||
<!-- THIS FILE MUST NOT BE EDITED BY HAND -->
|
<!-- THIS FILE MUST NOT BE EDITED BY HAND -->
|
||||||
<!-- ON NEW FLAG ADDED PLEASE RUN 'make generate-documentation' -->
|
<!-- ON NEW FLAG ADDED PLEASE RUN 'make generate-flags-documentation' -->
|
||||||
|
|
||||||
| Flag | Description |
|
| Flag | Description |
|
||||||
| :------ | :----------- |
|
| :------ | :----------- |
|
||||||
|
@ -33,14 +33,14 @@ type Flag struct {
|
|||||||
type Flags []Flag
|
type Flags []Flag
|
||||||
|
|
||||||
// AddFlag adds a new flag to the Flags struct
|
// AddFlag adds a new flag to the Flags struct
|
||||||
func (f *Flags) AddFlag(name, description string) {
|
func (f *Flags) addFlag(name, description string) {
|
||||||
*f = append(*f, Flag{Name: name, Description: description})
|
*f = append(*f, Flag{Name: name, Description: description})
|
||||||
}
|
}
|
||||||
|
|
||||||
const markdownTemplate = `# Flags
|
const markdownTemplate = `# Flags
|
||||||
|
|
||||||
<!-- THIS FILE MUST NOT BE EDITED BY HAND -->
|
<!-- THIS FILE MUST NOT BE EDITED BY HAND -->
|
||||||
<!-- ON NEW FLAG ADDED PLEASE RUN 'make generate-documentation' -->
|
<!-- ON NEW FLAG ADDED PLEASE RUN 'make generate-flags-documentation' -->
|
||||||
|
|
||||||
| Flag | Description |
|
| Flag | Description |
|
||||||
| :------ | :----------- |
|
| :------ | :----------- |
|
||||||
@ -85,7 +85,7 @@ func computeFlags() Flags {
|
|||||||
if !flag.IsBoolFlag() {
|
if !flag.IsBoolFlag() {
|
||||||
flagString += fmt.Sprintf("=%s", flag.FormatPlaceHolder())
|
flagString += fmt.Sprintf("=%s", flag.FormatPlaceHolder())
|
||||||
}
|
}
|
||||||
flags.AddFlag(fmt.Sprintf("`%s`", flagString), flag.HelpWithEnvar())
|
flags.addFlag(fmt.Sprintf("`%s`", flagString), flag.HelpWithEnvar())
|
||||||
}
|
}
|
||||||
return flags
|
return flags
|
||||||
}
|
}
|
@ -26,6 +26,8 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const pathToDocs = "%s/../../../../docs"
|
||||||
|
|
||||||
func TestComputeFlags(t *testing.T) {
|
func TestComputeFlags(t *testing.T) {
|
||||||
flags := computeFlags()
|
flags := computeFlags()
|
||||||
|
|
||||||
@ -54,35 +56,35 @@ func TestGenerateMarkdownTableRenderer(t *testing.T) {
|
|||||||
|
|
||||||
func TestFlagsMdExists(t *testing.T) {
|
func TestFlagsMdExists(t *testing.T) {
|
||||||
testPath, _ := os.Getwd()
|
testPath, _ := os.Getwd()
|
||||||
fsys := os.DirFS(fmt.Sprintf("%s/../../docs", testPath))
|
fsys := os.DirFS(fmt.Sprintf(pathToDocs, testPath))
|
||||||
filePath := "flags.md"
|
fileName := "flags.md"
|
||||||
_, err := fs.Stat(fsys, filePath)
|
st, err := fs.Stat(fsys, fileName)
|
||||||
assert.NoError(t, err, "expected file %s to exist", filePath)
|
assert.NoError(t, err, "expected file %s to exist", fileName)
|
||||||
|
assert.Equal(t, fileName, st.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFlagsMdUpToDate(t *testing.T) {
|
func TestFlagsMdUpToDate(t *testing.T) {
|
||||||
testPath, _ := os.Getwd()
|
testPath, _ := os.Getwd()
|
||||||
fsys := os.DirFS(fmt.Sprintf("%s/../../docs", testPath))
|
fsys := os.DirFS(fmt.Sprintf(pathToDocs, testPath))
|
||||||
filePath := "flags.md"
|
fileName := "flags.md"
|
||||||
expected, err := fs.ReadFile(fsys, filePath)
|
expected, err := fs.ReadFile(fsys, fileName)
|
||||||
assert.NoError(t, err, "expected file %s to exist", filePath)
|
assert.NoError(t, err, "expected file %s to exist", fileName)
|
||||||
|
|
||||||
flags := computeFlags()
|
flags := computeFlags()
|
||||||
actual, err := flags.generateMarkdownTable()
|
actual, err := flags.generateMarkdownTable()
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
assert.True(t, len(expected) == len(actual), "expected file '%s' to be up to date. execute 'make generate-flags-documentation", fileName)
|
||||||
assert.True(t, len(expected) == len(actual), "expected file '%s' to be up to date. execute 'make generate-documentation", filePath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFlagsMdExtraFlagAdded(t *testing.T) {
|
func TestFlagsMdExtraFlagAdded(t *testing.T) {
|
||||||
testPath, _ := os.Getwd()
|
testPath, _ := os.Getwd()
|
||||||
fsys := os.DirFS(fmt.Sprintf("%s/../../docs", testPath))
|
fsys := os.DirFS(fmt.Sprintf(pathToDocs, testPath))
|
||||||
filePath := "flags.md"
|
filePath := "flags.md"
|
||||||
expected, err := fs.ReadFile(fsys, filePath)
|
expected, err := fs.ReadFile(fsys, filePath)
|
||||||
assert.NoError(t, err, "expected file %s to exist", filePath)
|
assert.NoError(t, err, "expected file %s to exist", filePath)
|
||||||
|
|
||||||
flags := computeFlags()
|
flags := computeFlags()
|
||||||
flags.AddFlag("new-flag", "description2")
|
flags.addFlag("new-flag", "description2")
|
||||||
actual, err := flags.generateMarkdownTable()
|
actual, err := flags.generateMarkdownTable()
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
Loading…
Reference in New Issue
Block a user