cli icon indicating copy to clipboard operation
cli copied to clipboard

feat: uses moby to generate human friendly name for store

Open gabrielbussolo opened this issue 2 years ago • 4 comments

Description

This PR uses the moby (docker reference) names generator to give name to stores.

Previously, the --name flag was enforced by a check on the createStoreWithModel function, ensuring that the storeName would never be empty and preventing the generation of a name. As a result, attempting to create a store without specifying a name resulted in an error:

fga store create
Error: required flag(s) "name" not set

To address this issue, the verification for the --name flag was removed.

It aims to close #115 issue

A new dependency has been introduced to the project. If adding a new dependency is undesirable, it is possible to incorporate the relevant code directly into this codebase since it is a simple piece of code. :)

References

#115

Review Checklist

  • [x] I have clicked on "allow edits by maintainers".
  • [ ] I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • [x] The correct base branch is being used, if not main
  • [ ] I have added tests to validate that the change in functionality is working as expected

gabrielbussolo avatar Aug 05 '23 22:08 gabrielbussolo

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: gabrielbussolo / name: Gabriel Bussolo (2f30a96e86738feb7f91b37d9de9584d66f2b00d)

Hey @gabrielbussolo!

I like this idea, but I'm not sure how useful it would be.

We tweaked the fga store create --model model.fga|.json command to use the file name as the default store name:

$ fga store create --model Model.fga

{
  "store": {
    "created_at":"2023-08-07T18:13:20.996575Z",
    "id":"01H78K87F4526MCW0173B59T3V",
    "name":"Model",
    "updated_at":"2023-08-07T18:13:20.996575Z"
  },
  "model": {
    "authorization_model_id":"01H78K87F9Y39TPX07D7AFM4Z6"
  }
}

What's the use case that you are thinking of?

aaguiarz avatar Aug 08 '23 19:08 aaguiarz

Hey @gabrielbussolo!

I like this idea, but I'm not sure how useful it would be.

We tweaked the fga store create --model model.fga|.json command to use the file name as the default store name:

$ fga store create --model Model.fga

{
  "store": {
    "created_at":"2023-08-07T18:13:20.996575Z",
    "id":"01H78K87F4526MCW0173B59T3V",
    "name":"Model",
    "updated_at":"2023-08-07T18:13:20.996575Z"
  },
  "model": {
    "authorization_model_id":"01H78K87F9Y39TPX07D7AFM4Z6"
  }
}

What's the use case that you are thinking of?

hey @aaguiarz !

well tbh im not so sure of how much this feature can help (im still learning the project), i noticed it on this discussion https://github.com/openfga/cli/issues/115#issuecomment-1656973663 the suggestion, and the issue remained open, so my main goal was to close it.

but my take of it is with that we can just cli store create to have:

{
  "store": {
    "created_at":"2023-08-10T12:49:56.691648Z",
    "id":"01H7FQY6YEPMRAGGEZTW2CCEQX",
    "name":"sleepy_jang",
    "updated_at":"2023-08-10T12:49:56.691648Z"
  }
}

model not required before hand and neither name.

gabrielbussolo avatar Aug 10 '23 12:08 gabrielbussolo

This still relevant @rhamzeh @aaguiarz ? If it's not anymore, we can close this PR and the issue.

gabrielbussolo avatar Sep 28 '23 07:09 gabrielbussolo