template

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppHelpTemplate

func AppHelpTemplate() string

AppHelpTemplate returns the text template for the Default help topic. nolint:lll

func StripDefault

func StripDefault(v interface{}) string

StripDefault is a custom template function that will strip occurrences of the `(default: <TEXT>)` pattern from the help output to avoid leaking sensitive values.

The current distributed implementation of the help functionality inserts default values in the help description for each option (as applicable). Unfortunately, the downside to this is that defaults are read from hard-coded values but overridden by values that may be set in the environment (for options that support reading from env vars). While it's less likely that sensitive values would be hardcoded and compiled into the binary, it's more likely that these values would be set via env vars which means that at run time their values would be exposed to users that have the necessary level of access to run `inject -h`. A number of issues have been opened against the repo to provide a way of changing this behavior but no changes have been made to address the problem as of yet so we are just going to get around it with a custom `AppHelpTemplate` and passing this function to support the template.

You will need to insert statements like the following before you call `app.Run()`:

```go

cli.AppHelpTemplate = template.AppHelpTemplate()
cli.HelpPrinter = func(out io.Writer, templ string, data interface{}) {
	funcMap := tt.FuncMap{
		"stripDefault": template.StripDefault,
	}
	cli.HelpPrinterCustom(out, templ, data, funcMap)
}

```

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL