Skip to content

bug: kosli snapshot ecs help examples use invalid regex *-prod-* #1079

Description

@dangrondahl

What happened?

Two examples in kosli snapshot ecs --help use "*-prod-*" as a regex pattern (cmd/kosli/snapshotECS.go:74 and :86). The --*-regex flags are compiled as Go RE2 regexes (internal/filters/resourceFilter.go), and a leading * is not valid:

error parsing regexp: missing argument to repetition operator: `*`

Anyone copying the example gets a failed snapshot, and only after the AWS API calls have already run (the error surfaces from ShouldInclude via internal/aws/aws.go:716).

Steps to reproduce

  1. kosli snapshot ecs my-env --services-regex "*-prod-*" ...
  2. Same for --exclude-services-regex "*-prod-*".

Fix

Use ".*-prod-.*" in both examples.

The remaining regex examples ("my-cluster-*", "backend-*" on lines 53, 62, 71, 83) do compile, but they read as globs: -* means "zero or more hyphens", and matching is unanchored, so they effectively mean "contains backend". Worth tightening so the examples teach regex rather than glob.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions