aequitas / concourse-ftp-resource

Concourse resource to interact with FTP servers.
https://hub.docker.com/r/aequitas/ftp-resource/
MIT License
3 stars 6 forks source link

Resource doesn't work with SemVer versions with pre-release components #2

Closed iSynaptic closed 6 years ago

iSynaptic commented 7 years ago

The check script fails with trying to parse version numbers that have SemVer compatible version numbers with pre-release components. For example, it will fail to parse "1.0.0-rc.1" as a valid version number because of the "-rc.1" part. I believe this is because it is relying on distutils.version.StrictVersion, which supports a version encoding scheme different than SemVer. The example error is as follows:

Traceback (most recent call last):
  File "/opt/resource/check", line 226, in <module>
    print(FTPResource().run(os.path.basename(__file__), sys.stdin.read(), sys.argv[1:]))
  File "/opt/resource/check", line 72, in run
    output = self.cmd_check(version=data.get('version', {}))
  File "/opt/resource/check", line 123, in cmd_check
    versions = self._versions_to_output(self._matching_versions(self.listdir()))
  File "/opt/resource/check", line 202, in _versions_to_output
    versions.sort(key=lambda x: StrictVersion(x[self.version_key]))
  File "/opt/resource/check", line 202, in <lambda>
    versions.sort(key=lambda x: StrictVersion(x[self.version_key]))
  File "/usr/local/lib/python3.5/distutils/version.py", line 40, in __init__
    self.parse(vstring)
  File "/usr/local/lib/python3.5/distutils/version.py", line 137, in parse
    raise ValueError("invalid version number '%s'" % vstring)
ValueError: invalid version number '1.0.0-rc.1'
aequitas commented 6 years ago

fixed in #7

aequitas commented 6 years ago

Sorry for the delay, I have not been paying attention to this repo.