Lerentis / terraform-provider-gitea

Terraform Provider for your Gitea Instance
https://registry.terraform.io/providers/Lerentis/gitea/latest
MIT License
22 stars 11 forks source link

Team import doesn't set the organisation #35

Closed lyz-code closed 1 year ago

lyz-code commented 1 year ago

Describe the bug When importing a team the required organisation field is not set. So when you try to do a plan the resource gets replaced as it's trying to change from "" to the value you want to set.

To Reproduce Steps to reproduce the behavior:

  1. Import a team
  2. Do a terraform plan

Expected behavior When importing an organisation team, the organisation field should be set in the state.

Log Output If applicable, add logs to help explain your problem.

Additional Data Important for reproducability.

lyz-code commented 1 year ago

It seems that the team members are not imported either, this is not that bad because in the first apply they are overwritten

Lerentis commented 1 year ago

Hi @lyz-code ,

i can confirm your observation and in theory the fix for it should be easy, but there seems to be a bug in the gitea api where a GET /teams/{id} returns null for the organization field...

{
  "id": 13,
  "name": "test_team",
  "description": "test team of test org",
  "organization": null,
  "includes_all_repositories": true,
  "permission": "admin",
  "units": [
    "repo.releases",
    "repo.projects",
    "repo.packages",
    "repo.pulls",
    "repo.wiki",
    "repo.ext_wiki",
    "repo.code",
    "repo.issues",
    "repo.ext_issues"
  ],
  "units_map": {
    "repo.code": "admin",
    "repo.ext_issues": "admin",
    "repo.ext_wiki": "admin",
    "repo.issues": "admin",
    "repo.packages": "admin",
    "repo.projects": "admin",
    "repo.pulls": "admin",
    "repo.releases": "admin",
    "repo.wiki": "admin"
  },
  "can_create_org_repo": true
}

this needs to be fixed upstream i fear

Lerentis commented 1 year ago

Reported upstream here: https://github.com/go-gitea/gitea/issues/24734

if you would like to add anything to my description feel free to add your comment there 😃

lyz-code commented 1 year ago

Thank you for taking care of it, and damn they are fast fixing bugs!

Lerentis commented 1 year ago

indeed 😃 now just need to wait until this is released and i need to check the version where the fix is present in order to not break the functionality for older gitea releases. will update this issue when i release the fix. thanks again for the report

Lerentis commented 1 year ago

missed the gitea release but it should now be fixed and released as v0.14.1