1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-06 16:06:56 +00:00
kyverno/cmd/cli/kubectl-kyverno/commands/docs/utils.go
Charles-Edouard Brétéché d24b0848a6
chore: add cli commands unit tests (#8366)
* chore: add cli unit tests

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

* chore: add cli commands unit tests

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>

---------

Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-09-12 21:47:03 +00:00

35 lines
599 B
Go

package docs
import (
"fmt"
"path"
"path/filepath"
"strings"
"time"
)
const fmTemplate = `---
date: %s
title: "%s"
weight: 35
---
`
func websitePrepender(filename string) string {
now := time.Now().Format(time.RFC3339)
name := filepath.Base(filename)
base := strings.TrimSuffix(name, path.Ext(name))
return fmt.Sprintf(fmTemplate, now, strings.Replace(base, "_", " ", -1))
}
func websiteLinkHandler(filename string) string {
return "../" + strings.TrimSuffix(filename, filepath.Ext(filename))
}
func identity(s string) string {
return s
}
func empty(s string) string {
return ""
}