getv 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 853e816de90adcfaac9c59f8b12819af4abf2d12db77bf43c3cc4fd74033ae34
4
- data.tar.gz: e99c28ae47b5d735c35d01b4d057d9dff33e67d767d4eab1af0611b3ea8431c4
3
+ metadata.gz: d49b33dd0cac92da670d6e87cd932f4fbd60b6cb5d1db7f9ea2448a295f1f9b5
4
+ data.tar.gz: c8d460259782dbd03a353f79e7be1cee0d1e1f65124f06e04084931bcd880fad
5
5
  SHA512:
6
- metadata.gz: c87577b970b42e41c006f36ecf9ad9b1bec1b21838eb2daecf189502ccd5eda7f659544488f5f8613bd95bf59c939d595b2353a01cdd22890aae47525e012576
7
- data.tar.gz: c1227dddae53f9f8352ba70e5a3aa5bd5a157a1dd35e0c5c92803d63aedf1f72e035a301aa3702d8475f9ac4f4837d6557454be30e351dff55c57cf32e8e6129
6
+ metadata.gz: ef3b8cdbf5e974ff3c1663f3ec46eabc8b894aaea5e5f082ac5aa4c6d82d4c7e2ff3134cbc4e56f0da4fafe7eafb483eb0241d611b8d6b65370e50e8a66a86c8
7
+ data.tar.gz: b641600ab4ba600a5b337b06036c7779c9d89520cd11a5c4a38c1665073d082b7cd056120e417c8acf597ba2bb773798f8cd53c230635191208e89133f0d674d
data/README.md CHANGED
@@ -39,15 +39,16 @@ SYNOPSIS
39
39
 
40
40
 
41
41
  VERSION
42
- 1.5.0
42
+ 1.7.0
43
43
 
44
44
 
45
45
 
46
46
  GLOBAL OPTIONS
47
- --help - Show this message
48
- -j, --json - Output in json
49
- -l, --latest - Latest version
50
- --version - Display the program version
47
+ --help - Show this message
48
+ -j, --json - Output in json
49
+ -l, --latest - Latest version
50
+ -p, --proxy=arg - Web proxy (default: none)
51
+ --version - Display the program version
51
52
 
52
53
 
53
54
 
@@ -58,6 +59,7 @@ COMMANDS
58
59
  github_commit - Get package versions from GitHub commits
59
60
  github_release - Get package versions from GitHub releases
60
61
  github_tag - Get package versions from GitHub tags
62
+ helm - Get package versions from a Helm chart repository
61
63
  help - Shows a list of commands or help for one command
62
64
  index - Get package versions from web page of links
63
65
  npm - Get package versions from npm at registry.npmjs.org
@@ -70,7 +72,7 @@ Show the latest available version of the `getv` gem:
70
72
 
71
73
  ```console
72
74
  $ getv --latest gem getv
73
- 1.5.0
75
+ 1.7.0
74
76
  ```
75
77
 
76
78
  Show all `dep` GitHub release versions in JSON:
data/exe/getv CHANGED
@@ -196,6 +196,34 @@ class App # rubocop:disable Metrics/ClassLength
196
196
  end
197
197
  end
198
198
 
199
+ desc 'Get package versions from a Helm chart repository'
200
+ arg_name 'package_name'
201
+ command :helm do |c|
202
+ defaults = (Getv::Package.new 'name', type: c.name.to_s).opts
203
+ c.flag %i[select_search], desc: 'Regex version selection search', default_value: defaults[:select_search]
204
+ c.flag %i[select_replace], desc: 'Regex version selection replace', default_value: defaults[:select_replace]
205
+ c.flag %i[reject], desc: 'Regex version rejection', default_value: defaults[:reject]
206
+ c.switch %i[invalid_versions], desc: 'Include invalid semantic versions', negatable: false, default_value: false
207
+ c.flag %i[semantic_select], desc: 'Semantic version selection (comma delimited)',
208
+ default_value: defaults[:semantic_select]
209
+ c.flag %i[chart], desc: 'Chart name', default_value: 'package_name'
210
+ c.flag %i[url], desc: 'URL', default_value: defaults[:url]
211
+ c.flag %i[user], desc: 'Username', default_value: defaults[:user]
212
+ c.flag %i[password], desc: 'Password', default_value: defaults[:password]
213
+ c.action do |global_options, options, args|
214
+ help_now! unless args.size == 1
215
+
216
+ opts = global_options.merge(options)
217
+ opts = opts.slice :select_search, :select_replace, :reject, :semantic_only, :semantic_select, :chart, :url,
218
+ :user, :password, :proxy
219
+ opts = opts.delete_if { |k, v| v.nil? || v == c.flags[k].default_value }
220
+ opts[:semantic_only] = !options[:invalid_versions]
221
+ opts[:semantic_select] = opts[:semantic_select].split(',') unless opts.fetch(:semantic_select, nil).nil?
222
+ package = Getv::Package.new args[0], { type: c.name.to_s }.merge(opts)
223
+ Getv::Cli.output(package, latest: global_options[:latest], json: global_options[:json])
224
+ end
225
+ end
226
+
199
227
  desc 'Get package versions from web page of links'
200
228
  arg_name 'package_name'
201
229
  command :index do |c|
data/lib/getv/package.rb CHANGED
@@ -56,6 +56,8 @@ module Getv
56
56
  else
57
57
  { owner: name, repo: name }.merge(opts)
58
58
  end
59
+ when 'helm'
60
+ opts = { chart: name, url: nil, user: nil, password: nil }.merge(opts)
59
61
  when 'index'
60
62
  opts = { link: 'content' }.merge(opts)
61
63
  when 'npm'
@@ -103,9 +105,14 @@ module Getv
103
105
 
104
106
  private
105
107
 
106
- def get(url)
108
+ def get(url) # rubocop:disable Metrics/AbcSize
107
109
  require 'rest-client'
108
- RestClient::Request.execute(method: :get, url: url, proxy: opts[:proxy]).body
110
+ if opts[:user] && opts[:password]
111
+ RestClient::Request.execute(method: :get, url: url, proxy: opts[:proxy], user: opts[:user],
112
+ password: opts[:password]).body
113
+ else
114
+ RestClient::Request.execute(method: :get, url: url, proxy: opts[:proxy]).body
115
+ end
109
116
  end
110
117
 
111
118
  def versions_using_docker # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
@@ -160,6 +167,11 @@ module Getv
160
167
  end
161
168
  end
162
169
 
170
+ def versions_using_helm
171
+ require 'yaml'
172
+ YAML.safe_load(get("#{opts[:url]}/index.yaml")).fetch('entries', {}).fetch(name, []).map { |e| e['version'] }
173
+ end
174
+
163
175
  def versions_using_index
164
176
  require 'nokogiri'
165
177
  Nokogiri::HTML(get(opts[:url])).css('a').map do |a|
data/lib/getv/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Getv
4
- VERSION = '1.6.1'
4
+ VERSION = '1.7.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - harbottle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-31 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli