vmfloaty 1.7.0 → 1.8.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: 259a0672eabcb43fbb7fddd8205341050ab60f902e7842cb520f81bab1f139eb
4
- data.tar.gz: 22fdda03271053a921f305c6e547d09308d1d734bc77dfbd60bbbf47483e4137
3
+ metadata.gz: 5d8a0fcfd2e8fd42301c8a8c6ec14336444c5d70dda0adaed0731cbddcc90f7d
4
+ data.tar.gz: f3d5ef1252fbcb9142afba59d78f93d6cdbaaf76f11680a13c91654fbbc308fc
5
5
  SHA512:
6
- metadata.gz: 3c0ca6bc4d734b7b0712001d7bd33b8b493cdf2e588712d422383631ef9a749f8b98964ff6a8b05dd2c4c465fb0726af3af88692bc4baa94278c546461614bc4
7
- data.tar.gz: 072a4ab26891877393d3b70bc71d409b0a7dccd930bc6271fe6cf6bd7e16fe10e5fcd250b8313112afb9e8e9f25043c41d5173ad6bc0fb121d7e1f8255e74d4d
6
+ metadata.gz: 568f97d95dccec571488649670fb9fb8022ca58ec6a94c7b333d0f45d9f08ce4ff42c82cd8aef9bfc2079920b3178d333989d8422b68d2dfafe96fbaa08968c9
7
+ data.tar.gz: 7df48c34d04d7b6aaf4c6b4ac66fd845016c44519040192ddb2aa5d69f89043960d974a910cb1c8eceef6014d96f04891c71276ff5367760b0fa45ec5184aa88
data/README.md CHANGED
@@ -1,37 +1,48 @@
1
1
  # vmfloaty
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/vmfloaty.svg)](https://badge.fury.io/rb/vmfloaty)
4
- [![CI](https://github.com/puppetlabs/vmfloaty/actions/workflows/ci.yml/badge.svg)](https://github.com/puppetlabs/vmfloaty/actions/workflows/ci.yml)
4
+ [![Test](https://github.com/puppetlabs/vmfloaty/actions/workflows/test.yml/badge.svg)](https://github.com/puppetlabs/vmfloaty/actions/workflows/test.yml)
5
5
 
6
6
  A CLI helper tool for [Puppet's VMPooler](https://github.com/puppetlabs/vmpooler) to help you stay afloat.
7
7
 
8
8
  ![float image](float.jpg)
9
9
 
10
- - [Install](#install)
11
- - [Usage](#usage)
12
- - [Example workflow](#example-workflow)
13
- - [vmfloaty dotfile](#vmfloaty-dotfile)
14
- - [Basic configuration](#basic-configuration)
15
- - [Using multiple services](#using-multiple-services)
16
- - [Using backends besides VMPooler](#using-backends-besides-vmpooler)
17
- - [Valid config keys](#valid-config-keys)
18
- - [Tab Completion](#tab-completion)
19
- - [VMPooler API](#vmpooler-api)
20
- - [Using the Pooler class](#using-the-pooler-class)
21
- - [Example Projects](#example-projects)
22
- - [Contributing](#contributing)
23
- - [Code Reviews](#code-reviews)
24
- - [Releasing](#releasing)
25
- - [Special thanks](#special-thanks)
10
+ - [vmfloaty](#vmfloaty)
11
+ - [Install](#install)
12
+ - [Ruby](#ruby)
13
+ - [Docker](#docker)
14
+ - [Usage](#usage)
15
+ - [Example workflow](#example-workflow)
16
+ - [vmfloaty dotfile](#vmfloaty-dotfile)
17
+ - [Basic configuration](#basic-configuration)
18
+ - [Using multiple services](#using-multiple-services)
19
+ - [Using backends besides VMPooler](#using-backends-besides-vmpooler)
20
+ - [Valid config keys](#valid-config-keys)
21
+ - [Tab Completion](#tab-completion)
22
+ - [VMPooler API](#vmpooler-api)
23
+ - [Using the Pooler class](#using-the-pooler-class)
24
+ - [Example Projects](#example-projects)
25
+ - [Contributing](#contributing)
26
+ - [Code Reviews](#code-reviews)
27
+ - [Releasing](#releasing)
28
+ - [Special thanks](#special-thanks)
26
29
 
27
30
  ## Install
28
31
 
32
+ ### Ruby
33
+
29
34
  Grab the latest from ruby gems...
30
35
 
31
36
  ```bash
32
37
  gem install vmfloaty
33
38
  ```
34
39
 
40
+ ### Docker
41
+
42
+ Run the docker image:
43
+
44
+ `docker run -it --rm -v ~/.vmfloaty.yml:/home/floatyuser/.vmfloaty.yml ghcr.io/puppetlabs/vmfloaty --help`
45
+
35
46
  ## Usage
36
47
 
37
48
  ```plain
@@ -177,10 +188,12 @@ Please wait for multiple code owners to sign off on any notable change.
177
188
 
178
189
  ## Releasing
179
190
 
180
- Releasing is a two step process:
191
+ Follow these steps to publish a new GitHub release, build and push the gem to <https://rubygems.org>, and build and push a Docker Image to GitHub Container Registry:
181
192
 
182
- 1. Submit a release prep PR that updates `lib/vmfloaty/version.rb` to the desired new version and get that merged
183
- 2. Navigate to <https://github.com/puppetlabs/vmfloaty/actions/workflows/release.yml> --> Run workflow --> select "main" branch --> Run workflow. This will publish a GitHub release, build, and push the gem to RubyGems.
193
+ 1. Bump the "VERSION" in `lib/vmfloaty/version.rb` appropriately based on changes in `CHANGELOG.md` since the last release.
194
+ 2. Run `./release-prep` to update `Gemfile.lock` and `CHANGELOG.md`.
195
+ 3. Commit and push changes to a new branch, then open a pull request against `main` and be sure to add the "maintenance" label.
196
+ 4. After the pull request is approved and merged, then navigate to <https://github.com/puppetlabs/vmfloaty/actions/workflows/release.yml> --> Run workflow --> select "main" branch --> Run workflow. This will publish a GitHub release, build and push the gem to RubyGems, and build and push a Docker Image to GitHub Container Registry.
184
197
 
185
198
  ## Special thanks
186
199
 
@@ -150,7 +150,14 @@ class Utils
150
150
  tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" } unless host_data['tags'].nil?
151
151
  duration = "#{host_data['running']}/#{host_data['lifetime']} hours"
152
152
  metadata = [host_data['state'], host_data['template'], duration, *tag_pairs]
153
- message = "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
153
+ # For backwards compatibility with vmpooler api v1
154
+ message =
155
+ if host_data['domain']
156
+ "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
157
+ else
158
+ "- #{host_data['fqdn']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
159
+ end
160
+
154
161
  if host_data['state'] && host_data['state'] == 'destroyed'
155
162
  output_target.puts "- DESTROYED #{hostname}.#{host_data['domain']}".gsub(/^/, ' ' * indent)
156
163
  else
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Vmfloaty
4
- VERSION = '1.7.0'
4
+ VERSION = '1.8.0'
5
5
  end
@@ -280,7 +280,73 @@ describe Utils do
280
280
 
281
281
  subject { Utils.pretty_print_hosts(verbose, service, hostname, print_to_stderr) }
282
282
 
283
- describe 'with vmpooler service' do
283
+ describe 'with vmpooler api v2 service' do
284
+ let(:service) { Service.new(MockOptions.new, 'url' => url) }
285
+
286
+ let(:hostname) { 'mcpy42eqjxli9g2' }
287
+ let(:fqdn) { [hostname, 'delivery.puppetlabs.net'].join('.') }
288
+
289
+ let(:response_body) do
290
+ {
291
+ hostname => {
292
+ 'template' => 'ubuntu-1604-x86_64',
293
+ 'lifetime' => 12,
294
+ 'running' => 9.66,
295
+ 'state' => 'running',
296
+ 'ip' => '127.0.0.1',
297
+ 'fqdn' => fqdn
298
+ }
299
+ }
300
+ end
301
+
302
+ let(:default_output) { "- #{fqdn} (running, ubuntu-1604-x86_64, 9.66/12 hours)" }
303
+
304
+ it 'prints output with host fqdn, template and duration info' do
305
+ expect($stdout).to receive(:puts).with(default_output)
306
+
307
+ subject
308
+ end
309
+
310
+ context 'when tags are supplied' do
311
+ let(:hostname) { 'aiydvzpg23r415q' }
312
+ let(:response_body) do
313
+ {
314
+ hostname => {
315
+ 'template' => 'redhat-7-x86_64',
316
+ 'lifetime' => 48,
317
+ 'running' => 7.67,
318
+ 'state' => 'running',
319
+ 'tags' => {
320
+ 'user' => 'bob',
321
+ 'role' => 'agent'
322
+ },
323
+ 'ip' => '127.0.0.1',
324
+ 'fqdn' => fqdn
325
+ }
326
+ }
327
+ end
328
+
329
+ it 'prints output with host fqdn, template, duration info, and tags' do
330
+ output = "- #{fqdn} (running, redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)"
331
+
332
+ expect($stdout).to receive(:puts).with(output)
333
+
334
+ subject
335
+ end
336
+ end
337
+
338
+ context 'when print_to_stderr option is true' do
339
+ let(:print_to_stderr) { true }
340
+
341
+ it 'outputs to stderr instead of stdout' do
342
+ expect($stderr).to receive(:puts).with(default_output)
343
+
344
+ subject
345
+ end
346
+ end
347
+ end
348
+
349
+ describe 'with vmpooler api v1 service' do
284
350
  let(:service) { Service.new(MockOptions.new, 'url' => url) }
285
351
 
286
352
  let(:hostname) { 'mcpy42eqjxli9g2' }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmfloaty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cain
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-04-05 00:00:00.000000000 Z
12
+ date: 2023-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
@@ -52,7 +52,7 @@ dependencies:
52
52
  - !ruby/object:Gem::Version
53
53
  version: 1.5.1
54
54
  description: A helper tool for vmpooler to help you stay afloat
55
- email: dio-gems@puppet.com
55
+ email: info@puppet.com
56
56
  executables:
57
57
  - floaty
58
58
  extensions: []
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubygems_version: 3.2.32
108
+ rubygems_version: 3.3.26
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: CLI application to interface with vmpooler