saltstack / saltstack/salt

[FEATURE REQUEST] Nexus-Module - `version: 'latest'` broken for version-parts > 9

Open
#60,474 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

We are using something like this to download the latest artifacts from our nexus:

deploy_artefact:
  nexus.downloaded:
    - artifact:
        nexus_url: {{ salt['pillar.get']('nexus_url') }}
        repository: 'some-nexus-repo'
        artifact_id: 'some-service'
        group_id: 'de.whatever'
        packaging: 'jar'
        version: 'latest'
    - target_file: /opt/some-project.d/some-service.jar

If the maven-metadata.xml of this artifact looks like this:

<metadata modelVersion="1.1.0">
  <groupId>wonderfull.group</groupId>
  <artifactId>foo-bar</artifactId>
  <versioning>
    <latest>1.22.0-dev.30</latest>
    <release>1.22.0-dev.30</release>
    <versions>
      <version>1.8.0-dev.7</version>
      <version>1.8.0-dev.14</version>
      <version>1.10.0-dev.15</version>
      <version>1.11.0-dev.18</version>
      <version>1.13.0-dev.20</version>
      <version>1.15.0-dev.21</version>
      <version>1.16.0-dev.24</version>
      <version>1.19.0-dev.26</version>
      <version>1.20.0-dev.27</version>
      <version>1.20.0-dev.29</version>
      <version>1.22.0-dev.30</version>
    </versions>
    <lastUpdated>20210701073016</lastUpdated>
  </versioning>
</metadata>

'latest' will evaluate to '1.8.0-dev.7' because of this line:
https://github.com/saltstack/salt/blob/971dfb43fbf19d6d2e662dd83ff244485f254bda/salt/modules/nexus.py#L558
This is just a string-compare and not a semantic-version comparison.

I think it would make sense to use a library like semver or semantic-version for the comparison.

saltmaster $> salt --version-report

Salt Version:
          Salt: 3002.2

Dependency Versions:
          cffi: 1.13.2
      cherrypy: Not Installed
      dateutil: 2.7.3
    docker-py: Not Installed
        gitdb: Not Installed
    gitpython: Not Installed
        Jinja2: 2.10.1
      libgit2: 0.28.4
      M2Crypto: 0.35.2
          Mako: Not Installed
      msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
    pycparser: 2.17
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: 0.28.2
        Python: 3.6.13 (default, Mar 10 2021, 18:30:35) [GCC]
  python-gnupg: Not Installed
        PyYAML: 5.3.1
        PyZMQ: 17.0.0
        smmap: Not Installed
      timelib: Not Installed
      Tornado: 4.5.3
          ZMQ: 4.2.3

System Versions:
          dist: sles 15.2 
        locale: UTF-8
      machine: x86_64
      release: 5.3.18-24.67-default
        system: Linux
      version: SLES 15.2 

Sonatype Nexus Repository Manager in Version OSS 3.30.1-01

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 in salt/modules/nexus.py around line 558 and reproduce the version selection with the provided maven-metadata.xml example. Review the proposed semver and semantic-version libraries, then verify that version: 'latest' selects the highest semantic version rather than the lexicographically first version.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.