terraform-provider-nexus icon indicating copy to clipboard operation
terraform-provider-nexus copied to clipboard

Order of repositories in docker repository group is not respected

Open xgcssch opened this issue 2 years ago • 8 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Community Note

  • Please vote on this issue by adding a :thumbsup: reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

1.3.7

Nexus Provider Version

1.21.2

Nexus Version

3.37.3

Affected Resource(s)/Data Source(s)

nexus_repository_docker_group

Terraform Configuration Files

resource "nexus_repository_docker_hosted" docker-hosted-repos-rfrg {
  name   = "docker-h-rfrg"
  online = true
  docker {
    force_basic_auth = false
    v1_enabled       = false
    https_port       = 5001
  }
  storage {
    blob_store_name                = "TransientData"
    strict_content_type_validation = true
  }
}

resource "nexus_repository_docker_hosted" docker-hosted-repos-rint {
  name   = "docker-h-rint"
  online = true
  docker {
    force_basic_auth = false
    v1_enabled       = false
    https_port       = 5002
  }
  storage {
    blob_store_name                = "TransientData"
    strict_content_type_validation = true
  }
}

resource "nexus_repository_docker_hosted" docker-hosted-repos-rewt {
  name   = "docker-h-rewt"
  online = true
  docker {
    force_basic_auth = false
    v1_enabled       = false
    https_port       = 5003
  }
  storage {
    blob_store_name                = "TransientData"
    strict_content_type_validation = true
  }
}

resource "nexus_repository_docker_group" docker-group-repos {
  name   = "docker-g-rewt"
  online = true
  docker {
    force_basic_auth = false
    v1_enabled       = false
    https_port       = 5023
  }
  group {
        member_names     = [
          nexus_repository_docker_hosted.docker-hosted-repos-rewt.name,
          nexus_repository_docker_hosted.docker-hosted-repos-rint.name,
          nexus_repository_docker_hosted.docker-hosted-repos-rfrg.name,
          ]
  }
  storage {
    blob_store_name                = "TransientData"
    strict_content_type_validation = true
  }
}

Debug Output/Panic Output

omitted

Expected Behaviour

Final order in Nexus after applying

docker-h-rewt
docker-h-rint
docker-h-rfrg

Actual Behaviour

Final order in Nexus after applying

docker-h-rint
docker-h-rfrg
docker-h-rewt

Funny: in the Terraform difference output the order is different too:

  # nexus_repository_docker_group.docker-group-repos will be created
  + resource "nexus_repository_docker_group" "docker-group-repos" {
      + id     = (known after apply)
      + name   = "docker-g-rewt"
      + online = true

      + docker {
          + force_basic_auth = false
          + https_port       = 5023
          + v1_enabled       = false
        }

      + group {
          + member_names = [
              + "docker-h-rewt",
              + "docker-h-rfrg",
              + "docker-h-rint",
            ]
        }

      + storage {
          + blob_store_name                = "TransientData"
          + strict_content_type_validation = true
        }
    }

Steps to Reproduce

terraform apply

References

#25 or #140

xgcssch avatar Jan 23 '23 09:01 xgcssch

It's the same bug for the other type of groups, like npm and maven.

bkolanko avatar Nov 29 '23 13:11 bkolanko

I can confirm that this problem still exists. Looking into it.

joeyaurel avatar Jan 11 '24 23:01 joeyaurel

I´ve checked this and the issue seems to be in this schema attribute since TypeSet is used to represent an unordered collection of items. Terraform doc reference: https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-types#typeset

We would need to use TypeList to preserver the order I believe

Edu-DevOps avatar Jan 13 '24 22:01 Edu-DevOps

The problem still exists in the latest provider version

salakonrad avatar Feb 01 '24 09:02 salakonrad

I can confirm that the problem still exists in version 2.1.0 of the datadriver, and this also affects ALL kind of groups (not just docker). The underlying issue was well pointed out in the comments above: The datadriver implementation uses a set, not a list, and therefore the ordered input gets reshuffled along the way.

Environment (although irrelevant due to the nature of this bug): Terraform 1.7.1 and Nexus RM Pro 3.62.0-01.

sonykus avatar Feb 12 '24 12:02 sonykus

first, it is only fixed for docker groups

anmoel avatar Mar 04 '24 16:03 anmoel

we will implement the same way for all repository types if someone can approve that the problem is fixed in version https://github.com/datadrivers/terraform-provider-nexus/releases/tag/v2.2.0

anmoel avatar Mar 04 '24 16:03 anmoel

The merged PR applies to the base repository schema so it applied to all repository types.

This is working as expected for an npm repo:

  • I applied the terraform
  • I logged into my instance and altered the group member order using the GUI
  • I reapplied the terraform
  • The GUI shows that my manual order change was reverted and the ordering is now as desired

oliverisaac avatar Mar 04 '24 17:03 oliverisaac