seqeralabs / seqera-kit

Python implementation and field-tool for automated pipeline launching through Tower CLI (beta)
Apache License 2.0
25 stars 6 forks source link

[bug] wrong duplicate detection #126

Open alvaromartmart opened 6 months ago

alvaromartmart commented 6 months ago

I noticed this issue trying to create two different teams:

teams:
  - name: "launchers"
    organization: "myorg"
    description: "Users with launcher permissions"
    overwrite: true
    members:
      - launcher@myorg.io
  - name: "viewers"
    organization: "myorg"
    description: "Users with viewer permissions"
    overwrite: true
    members:
      - viewer@myorg.io

Trying to run this through seqerakit resulted in the error "Duplicate 'name' specified in config file for teams: None".

I suspect what might be the reason:

https://github.com/seqeralabs/seqera-kit/blob/b09822083a798673c0331a0e30dc1c96766e342a/seqerakit/helper.py#L40-L44

I assume that's why it results as None, which is evaluated for uniqueness.

It's very likely that this issue affects other entities.

[!warning] Moreover, maybe the name is not enough to check for uniqueness. E.g. I might want to define two workspaces with the same name but in different organizations.

ejseqera commented 5 months ago

Thanks for reporting @alvaromartmart, I've pushed a fix in #127 that should resolve this. As you rightly suggested, there was an issue in how we check for the value of the name key or --name arg that returned None for when constructing arguments for teams.

Testing with your above example:

$ seqerakit teams.yml --dryrun
DEBUG:root:DRYRUN: Running command tw teams add --name launchers --organization myorg --description 'Users with launcher permissions'
DEBUG:root:DRYRUN: Running command tw teams members --team launchers --organization myorg add --member launcher@myorg.io
DEBUG:root:DRYRUN: Running command tw teams add --name viewers --organization myorg --description 'Users with viewer permissions'
DEBUG:root:DRYRUN: Running command tw teams members --team viewers --organization myorg add --member viewer@myorg.io

Do you think in addition to checking for name, we should check for workspace for uniqueness? Most resources can't be duplicated within a workspace, but can within an organization, right?

ejseqera commented 4 months ago

Largely fixed in #127 but will leave this discussion open to make this more reliable in the future