Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check step fails when previous version doesn't exist anymore #8

Closed
lunikon opened this issue Feb 5, 2018 · 4 comments
Closed

Check step fails when previous version doesn't exist anymore #8

lunikon opened this issue Feb 5, 2018 · 4 comments

Comments

@lunikon
Copy link

lunikon commented Feb 5, 2018

I use this resource to download files from an external FTP server of a business partner, so we do not control the content/versions ourselves. They typically only leave the latest version of the file on the server and delete any previous ones.

Due to this, the FTP resources fails with an error like this:

resource script '/opt/resource/check []' failed: exit status 1

stderr:
connecting to ftp server
logging in
changing to directory 
Traceback (most recent call last):
  File "/opt/resource/check", line 227, in <module>
    print(FTPResource().run(os.path.basename(__file__), sys.stdin.read(), sys.argv[1:]))
  File "/opt/resource/check", line 73, in run
    output = self.cmd_check(version=data.get('version', {}))
  File "/opt/resource/check", line 133, in cmd_check
    new_versions = versions[versions.index(current_version):]
ValueError: {'version': 'X.Y.Z'} is not in list

I'm no Python expert, but I assume the issue is because the current version is not in the hash anymore and hence the look-up fails.

In such a case, would it be possible to just return the latest version? Or does that go against the contract for the check script?

@aequitas
Copy link
Owner

aequitas commented Feb 5, 2018

I could probably add an option to explicitly only expect one version. Would that work?

@lunikon
Copy link
Author

lunikon commented Feb 5, 2018

I checked the documentation real quick and it says (see https://concourse.ci/implementing-resources.html):

A resource type's check script is invoked to detect new versions of the resource. It is given the configured source and current version on stdin, and must print the array of new versions, in chronological order, to stdout, including the requested version if it's still valid.

Note the emphasized part: I would interpret this as such that the correct behavior would be to return a list of versions in any case. The requested version should only be part of the list when it is still valid, so it not being valid anymore seems to be a well-defined case.

Consequently, I don't think making this a special case (and option to only expect a single version, for example) would be the right way to go.

@lunikon
Copy link
Author

lunikon commented Mar 1, 2018

Any news on this?

@aequitas
Copy link
Owner

aequitas commented Jun 28, 2018

Should be fixed now: #9, sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants