Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! fixup! Make provider upgrad…
Browse files Browse the repository at this point in the history
…able; Add logic to correctly switch between channels
  • Loading branch information
root-expert committed Sep 11, 2024
1 parent 7cd084b commit 1468c9a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/puppet/provider/package/snap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def self.instances
Puppet.info('called instances')
@installed_snaps ||= installed_snaps
Puppet.info(@installed_snaps)
Puppet.info("installed_snaps = #{@installed_snaps})
@installed_snaps.map do |snap|
new(name: snap['name'], ensure: snap['tracking-channel'], provider: 'snap')
end
Expand All @@ -28,7 +28,7 @@ def self.instances
def query
Puppet.info('called query')
installed = self.class.instances.find { |it| it.name == @resource['name'] }
Puppet.info(installed)
Puppet.info("installed #{installed}")
{ ensure: installed[:ensure], name: @resource[:name] } if installed
end
Expand All @@ -37,7 +37,7 @@ def install
current_ensure = query&.dig(:ensure)
current_ensure ||= :absent
Puppet.info(current_ensure)
Puppet.info("current_ensure = #{current_ensure}")
# Refresh the snap if we changed the channel
if current_ensure != @resource[:ensure] && current_ensure != :absent
Puppet.info('modify snap')
Expand Down Expand Up @@ -66,11 +66,13 @@ def latest
self.class.parse_channel(@resource[:install_options])
end

Puppet.info(channel)
Puppet.info("channel = #{channel}")
selected_channel = res['result'].first&.dig('channels', channel)
Puppet.info(selected_channel)
Puppet.info("selected_channel = #{selected_channel}")
raise Puppet::Error, "No version in channel #{channel}" unless selected_channel

Puppet.info('Evaluating version')
Puppet.info("version = #{selected_channel['version']}")
# Return version
selected_channel['version']
end
Expand Down

0 comments on commit 1468c9a

Please sign in to comment.