KDEJewellers / aptly-api

Ruby client library for the Aptly API
http://www.rubydoc.info/github/KDEJewellers/aptly-api
GNU Lesser General Public License v3.0
4 stars 0 forks source link

Aptly::PublishedRepository needs a get class method #9

Open warmfusion opened 7 years ago

warmfusion commented 7 years ago

I've been using the API to publish to local repositories, but have found that I need to trigger an update on the published repositories that those locals are incorporated into.

Unfortunatly, there isn't a Aptly::PublishedRepository.get( name ) method which means, while I know the name of the published repository, I need to instead use the following iterator to find any published repositories using my LocalRepo as a source;


    @logger.info("Applying staged packages into #{config[:server]}/#{config[:prefix]} #{config[:distro]}")
    pub_repo = Aptly::PublishedRepository.list.each{ |x|
          next unless x.Sources.select { |s| s.Name == config[:repo] } .length > 0
          @logger.debug(" Updating Repo:  #{config[:server]}/#{x.Prefix} #{x.Distribution} ")
          x.update
    }```

I believe a class method needs to be added to the PublishedRepository class to allow named repos to be obtained directly.
hsitter commented 7 years ago

Aptly::Repository.get('foobar').published_in.each(&:update!) does that, no?

warmfusion commented 7 years ago

Ah, quite possibly, however there is still the case of needing/wanting to access a named repo directly?

hsitter commented 7 years ago

Published repositories have no name, Repositories/Snapshots/etc have. Which is what the snippet I posted does.

So, even if we built a Aptly::PublishedRepository.by_repo_name('foobar') helper that'd internally still call that snippet I posted. I think this ultimately is just a question how you think about it, and I appreciate that it seems a bit counter-intuitive how Aptly does it.

@shadeslayer what's your stance on this?

shadeslayer commented 7 years ago

@apachelogger IMO if there's more demand for such a call, or Aptly's API starts supporting this, then it might make sense to implement it.