openfga / openfga/cli

Clarify or improve globbing support for `fga model test`

Open
#605 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
102
Forks
49
Avg merge
1d 1h
Merged PRs (30d)
16

Description

The glob support for the --tests option in fga model test uses the Go filepath.Glob, which uses filepath.Match under the hood to match the glob pattern.

The means that we're missing support for ** in the glob pattern (https://github.com/golang/go/issues/11862) as the Go API is intended to mirror the C std lib rather than the bash globbing that some might expect.

** is especially useful as it would allow matching any number of path segments meaning that in a structure like in the test fixtures:

  • ls ./tests/fixtures/**/*.fga.yaml resolves both the basic-store.fga.yaml and relative-path/relative-path-store.fga.yaml
  • fga model test --tests "./tests/fixtures/**/*.fga.yaml" will only resolve relative-path-store.fga.yaml

Given that it might be expected for the globbing to match the behaviour of bash, this might lead to folks accidentally not running their entire tests if they use a tool like ls to help determine the globbing pattern used.

We should either:

  • Document this limitation
  • Improve the globbing to match what is most likely expected

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the implementation of the --tests option in fga model test and compare its filepath.Glob behavior with the fixture patterns under tests/fixtures. Decide whether the intended outcome is documenting the ** limitation or supporting recursive matching, then verify the result against both basic-store.fga.yaml and relative-path/relative-path-store.fga.yaml.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.