nulldriver / maven-resource

Maven Repository Manager Concourse Resource
Apache License 2.0
22 stars 49 forks source link

`check` not working for when the resource is used in a `get` first. #13

Open shinmyung0 opened 7 years ago

shinmyung0 commented 7 years ago

When the resource is used in a get at the very beginning (first check request) there is nothing passed into the version.version field of the payload so the value of $version becomes empty, which breaks all the downstream logic for determining which url to use etc.

https://github.com/patrickcrocker/maven-resource/blob/master/assets/check#L31

As per the docs on implementing a resource:

  • version is a JSON object with string fields, used to uniquely identify an instance of the resource. For git this would be a commit SHA. This will be omitted from the first request, in which case the resource should return the current version (not every version since the resource's inception).

I suppose the only way to get the "current" version would be to do a curl upfront to get the latest version of the artifact that is present in the repository, but I do see how it might be a little tricky if you specify both url and snapshot_url. The way I see it, either we could determine which artifact version to check for the first check depending on which url values are present in the resource, or we could have a param.snapshot field in the get which can be a boolean to explicitly fetch a snapshot version?

Thanks for all the quick responses btw!

designed4device commented 5 years ago

I ran into this as well. Looks like it would only be a problem when you only have a snapshot url (which is the case for me). I ended up building my own image that uses the snapshot url if release is not present as a temporary workaround.