Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/kosli/testdata/output/docs/mintlify/artifact.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ is set), registry credentials are resolved as follows:
| `-h`, `--help` | help for artifact |
| `-n`, `--name` string | [optional] Artifact display name, if different from file, image or directory name. |
| `--registry-password` string | [conditional] The container registry password or access token. Only required if you want to read container image SHA256 digest from a remote container registry and it is not already accessible via Docker/Podman auth files or a credential helper. |
| `--registry-provider` string | [deprecated] The docker registry provider or url. Only required if you want to read docker image SHA256 digest from a remote docker registry. (DEPRECATED: no longer used) |
| `--registry-username` string | [conditional] The container registry username. Only required if you want to read container image SHA256 digest from a remote container registry and it is not already accessible via Docker/Podman auth files or a credential helper. |
| `--repo-root` string | [defaulted] The directory where the source git repository is available. (default ".") |

Expand Down
1 change: 1 addition & 0 deletions cmd/kosli/testdata/output/docs/mintlify/snyk.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ In other CI systems, set them explicitly to capture repository metadata.
| `-o`, `--origin-url` string | [optional] The url pointing to where the attestation came from or is related. (defaulted to the CI url in some CIs: [docs](/integrations/ci_cd/#defaulted-kosli-command-flags-from-ci-variables) ). |
| `--redact-commit-info` strings | [optional] The list of commit info to be redacted before sending to Kosli. Allowed values are one or more of [author, message, branch]. |
| `--registry-password` string | [conditional] The container registry password or access token. Only required if you want to read container image SHA256 digest from a remote container registry and it is not already accessible via Docker/Podman auth files or a credential helper. |
| `--registry-provider` string | [deprecated] The docker registry provider or url. Only required if you want to read docker image SHA256 digest from a remote docker registry. (DEPRECATED: no longer used) |
| `--registry-username` string | [conditional] The container registry username. Only required if you want to read container image SHA256 digest from a remote container registry and it is not already accessible via Docker/Podman auth files or a credential helper. |
| `--repo-id` string | [conditional] The stable, unique identifier for the repository in your VCS provider (e.g. a numeric ID). Do not use the repository name as it can change if the repo is renamed. All three of `--repo-id`, `--repo-url` and `--repository` must be set to record repository information (defaulted in some CIs: [docs](/integrations/ci_cd) ). |
| `--repo-provider` string | [optional] The source code hosting provider. One of: github, gitlab, bitbucket, bitbucket_cloud, bitbucket_dc, azure-devops, azure_devops_services, azure_devops_server, git, subversion (defaulted in some CIs: [docs](/integrations/ci_cd) ). |
Expand Down
7 changes: 6 additions & 1 deletion internal/docgen/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ func CommandsInTable(f *pflag.FlagSet) string {

maxlen := 0
f.VisitAll(func(flag *pflag.Flag) {
if flag.Hidden {
// pflag.MarkDeprecated sets Hidden as a side effect, which would keep
// deprecated-but-working flags out of the reference docs along with
// their migration message. Only flags hidden on purpose (MarkHidden,
// e.g. internal aliases) are skipped; deprecated ones are documented
// below with a (DEPRECATED: ...) suffix.
if flag.Hidden && flag.Deprecated == "" {
return
}

Expand Down
22 changes: 22 additions & 0 deletions internal/docgen/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ func TestCommandsInTable(t *testing.T) {
}
}

// TestCommandsInTableHiddenFlags and TestCommandsInTableDeprecatedFlags are a
// pair: a flag hidden via MarkHidden stays out of the docs, while a flag hidden
// as a side effect of MarkDeprecated is documented with its migration message.
func TestCommandsInTableHiddenFlags(t *testing.T) {
fs := pflag.NewFlagSet("test", pflag.ContinueOnError)
fs.String("visible", "", "Visible flag")
Expand All @@ -42,6 +45,25 @@ func TestCommandsInTableHiddenFlags(t *testing.T) {
}
}

func TestCommandsInTableDeprecatedFlags(t *testing.T) {
fs := pflag.NewFlagSet("test", pflag.ContinueOnError)
fs.String("new", "", "The replacement flag")
fs.String("old", "", "The superseded flag")
// MarkDeprecated also sets Hidden, which used to keep the flag out of the docs.
_ = fs.MarkDeprecated("old", "use --new instead")

got := CommandsInTable(fs)
if !strings.Contains(got, "--old") {
t.Errorf("expected deprecated flag to be documented, got:\n%s", got)
}
if !strings.Contains(got, "(DEPRECATED: use --new instead)") {
t.Errorf("expected deprecation message, got:\n%s", got)
}
if !strings.Contains(got, "--new") {
t.Errorf("expected replacement flag, got:\n%s", got)
}
}

func TestCommandsInTableDefaultValues(t *testing.T) {
fs := pflag.NewFlagSet("test", pflag.ContinueOnError)
fs.String("dir", "/tmp", "The directory")
Expand Down
Loading