mirror of
https://github.com/puppetlabs/vmfloaty.git
synced 2026-05-31 07:25:21 -04:00
Bump faraday from ~> 1.5 to ~> 2 (#256)
* Bump faraday from ~> 1.5 to ~> 2 Updates the basic-auth middleware call to the Faraday 2 form (`request :authorization, :basic, ...`). Faraday 2.x requires Ruby >= 3.0, so drop Ruby 2.7 from the CI matrix and pin `required_ruby_version = '>= 3.0'` in the gemspec. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Remove ensure_label workflow The reusable workflow it referenced (puppetlabs/release-engineering-repo-standards/.github/workflows/ensure_label.yml@v1) no longer exists. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * Add CLAUDE.md Documents common dev/test/release commands and the Service/backend architecture for future Claude Code sessions in this repo. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
6b6d6f73cd
commit
731ee3f014
6 changed files with 112 additions and 74 deletions
8
.github/workflows/ensure_label.yml
vendored
8
.github/workflows/ensure_label.yml
vendored
|
|
@ -1,8 +0,0 @@
|
||||||
name: Ensure label
|
|
||||||
|
|
||||||
on: pull_request
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
ensure_label:
|
|
||||||
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/ensure_label.yml@v1
|
|
||||||
secrets: inherit
|
|
||||||
1
.github/workflows/test.yml
vendored
1
.github/workflows/test.yml
vendored
|
|
@ -18,7 +18,6 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
ruby-version:
|
ruby-version:
|
||||||
- '2.7'
|
|
||||||
- '3.0'
|
- '3.0'
|
||||||
- '3.1'
|
- '3.1'
|
||||||
- '3.2'
|
- '3.2'
|
||||||
|
|
|
||||||
52
CLAUDE.md
Normal file
52
CLAUDE.md
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||||
|
|
||||||
|
## Project
|
||||||
|
|
||||||
|
`vmfloaty` is a Ruby CLI gem (`floaty` executable) that wraps Puppet's VMPooler and a few related VM-leasing backends. The gem is installed system-wide; for local development the executable is `bin/floaty`.
|
||||||
|
|
||||||
|
## Common commands
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bundle install # install deps
|
||||||
|
bundle exec rake # default task: rspec
|
||||||
|
bundle exec rake spec # run all tests
|
||||||
|
bundle exec rake rubocop # lint
|
||||||
|
bundle exec rspec spec/vmfloaty/utils_spec.rb # single file
|
||||||
|
bundle exec rspec spec/vmfloaty/utils_spec.rb -e 'name' # single example by description
|
||||||
|
bundle exec bin/floaty <subcommand> --help # run the CLI from the working tree
|
||||||
|
```
|
||||||
|
|
||||||
|
CI runs the spec suite against Ruby 2.7, 3.0, 3.1, 3.2 (`.github/workflows/test.yml`); keep changes compatible across that range. Coverage is collected via SimpleCov (HTML + lcov to `coverage/`). HTTP in tests is stubbed with `webmock`.
|
||||||
|
|
||||||
|
## Releasing
|
||||||
|
|
||||||
|
1. Bump `Vmfloaty::VERSION` in `lib/vmfloaty/version.rb`.
|
||||||
|
2. Run `./release-prep` — uses Docker to refresh `Gemfile.lock` (in the same Ruby image as `Dockerfile`) and regenerate `CHANGELOG.md` via `github_changelog_generator` (requires `CHANGELOG_GITHUB_TOKEN`).
|
||||||
|
3. PR to `main` with the `maintenance` label.
|
||||||
|
4. After merge, manually run the `release.yml` workflow in the GitHub Actions UI — that publishes the GitHub release, RubyGems gem, and GHCR image.
|
||||||
|
|
||||||
|
## Architecture
|
||||||
|
|
||||||
|
The CLI is one big Commander program in `lib/vmfloaty.rb` — every subcommand (`get`, `delete`, `list`, `modify`, `query`, `revert`, `service`, `snapshot`, `ssh`, `status`, `summary`, `token`, `completion`) is a `command :foo do |c| … end` block in `Vmfloaty#run`. New subcommands go there.
|
||||||
|
|
||||||
|
The key abstraction is `Service` (`lib/vmfloaty/service.rb`):
|
||||||
|
|
||||||
|
- Each command builds `Service.new(options, config)`.
|
||||||
|
- `Service` resolves the per-invocation config via `Utils.get_service_config` (CLI flags > selected service from `~/.vmfloaty.yml` > top-level fallbacks) and picks a **backend class** from `config['type']` via `Utils.get_service_object`.
|
||||||
|
- Backend classes are `Pooler` (VMPooler, `lib/vmfloaty/pooler.rb`), `ABS` (`abs.rb`), and `NonstandardPooler` (`nonstandard_pooler.rb`). They expose **class methods** (`retrieve`, `list`, `query`, `modify`, `delete`, `status`, `summary`, `snapshot`, `revert`, `disk`, `wait_for_request`, …); `Service` forwards via `method_missing` to whichever backend is active.
|
||||||
|
- `Service#maybe_use_vmpooler` — several operations (`modify`, `summary`, `snapshot`, `revert`, `disk`) don't exist on ABS. When the active backend is `ABS`, `Service` transparently swaps itself to `Pooler` using the `vmpooler_fallback` service named in the ABS config. If you add a backend-specific method, decide whether it needs this fallback.
|
||||||
|
|
||||||
|
Auth is split: `Auth` (`auth.rb`) owns token get/delete/status against VMPooler-style endpoints; `Service` calls into `Auth` and caches the token on `@config`. ABS does not have its own token endpoint and uses the fallback VMPooler for token operations.
|
||||||
|
|
||||||
|
`Utils` (`utils.rb`) is the shared toolbox: argument parsing (`generate_os_hash` parses `os=N` CLI args), response normalization (`standardize_hostnames` reconciles the three different response shapes from VMPooler v1, VMPooler v2, NonstandardPooler, and ABS — see the comment block at the top of that method), pretty-printing (`format_host_output`, `pretty_print_status`, `pretty_print_hosts`), and config resolution. Backend response shapes diverge a lot; when adding a backend or changing a command's output, update `standardize_hostnames` and the relevant pretty-printer together.
|
||||||
|
|
||||||
|
`Http.get_conn` (`http.rb`) is the single Faraday entry point — every backend uses it so verbose logging behaves consistently. `FloatyLogger` (`logger.rb`) is the project's logger; prefer it over `puts`/`STDERR` for status/error output (data destined for stdout consumption stays on `puts`/`JSON.pretty_generate`).
|
||||||
|
|
||||||
|
User config lives at `~/.vmfloaty.yml`. It can be a single flat service or a map of named services under `services:` (with top-level keys as fallback defaults). `floaty service types` and `floaty service examples` are the source of truth for valid `type:` values and example configs — keep them updated when adding a backend.
|
||||||
|
|
||||||
|
## Testing notes
|
||||||
|
|
||||||
|
- `spec/spec_helper.rb` defines `MockOptions` (a `Commander::Command::Options` subclass that accepts a hash) and a `get_headers` helper that constructs the exact headers Faraday sends — use them when stubbing requests with webmock.
|
||||||
|
- Specs are organized one file per `lib/vmfloaty/*.rb`; mirror that when adding a new module.
|
||||||
120
Gemfile.lock
120
Gemfile.lock
|
|
@ -3,110 +3,104 @@ PATH
|
||||||
specs:
|
specs:
|
||||||
vmfloaty (1.8.1)
|
vmfloaty (1.8.1)
|
||||||
commander (>= 4.4.3, < 4.7.0)
|
commander (>= 4.4.3, < 4.7.0)
|
||||||
faraday (~> 1.5, >= 1.5.1)
|
faraday (~> 2)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
addressable (2.8.6)
|
addressable (2.9.0)
|
||||||
public_suffix (>= 2.0.2, < 6.0)
|
public_suffix (>= 2.0.2, < 8.0)
|
||||||
ast (2.4.2)
|
ast (2.4.3)
|
||||||
bigdecimal (3.1.8)
|
bigdecimal (4.1.2)
|
||||||
coderay (1.1.3)
|
coderay (1.1.3)
|
||||||
commander (4.6.0)
|
commander (4.6.0)
|
||||||
highline (~> 2.0.0)
|
highline (~> 2.0.0)
|
||||||
crack (1.0.0)
|
crack (1.0.1)
|
||||||
bigdecimal
|
bigdecimal
|
||||||
rexml
|
rexml
|
||||||
diff-lcs (1.5.1)
|
diff-lcs (1.6.2)
|
||||||
docile (1.4.0)
|
docile (1.4.1)
|
||||||
faraday (1.10.3)
|
faraday (2.14.1)
|
||||||
faraday-em_http (~> 1.0)
|
faraday-net_http (>= 2.0, < 3.5)
|
||||||
faraday-em_synchrony (~> 1.0)
|
json
|
||||||
faraday-excon (~> 1.1)
|
logger
|
||||||
faraday-httpclient (~> 1.0)
|
faraday-net_http (3.4.2)
|
||||||
faraday-multipart (~> 1.0)
|
net-http (~> 0.5)
|
||||||
faraday-net_http (~> 1.0)
|
hashdiff (1.2.1)
|
||||||
faraday-net_http_persistent (~> 1.0)
|
|
||||||
faraday-patron (~> 1.0)
|
|
||||||
faraday-rack (~> 1.0)
|
|
||||||
faraday-retry (~> 1.0)
|
|
||||||
ruby2_keywords (>= 0.0.4)
|
|
||||||
faraday-em_http (1.0.0)
|
|
||||||
faraday-em_synchrony (1.0.0)
|
|
||||||
faraday-excon (1.1.0)
|
|
||||||
faraday-httpclient (1.0.1)
|
|
||||||
faraday-multipart (1.0.4)
|
|
||||||
multipart-post (~> 2)
|
|
||||||
faraday-net_http (1.0.1)
|
|
||||||
faraday-net_http_persistent (1.2.0)
|
|
||||||
faraday-patron (1.0.0)
|
|
||||||
faraday-rack (1.0.0)
|
|
||||||
faraday-retry (1.0.3)
|
|
||||||
hashdiff (1.1.0)
|
|
||||||
highline (2.0.3)
|
highline (2.0.3)
|
||||||
json (2.7.2)
|
io-console (0.8.2)
|
||||||
language_server-protocol (3.17.0.3)
|
json (2.19.4)
|
||||||
method_source (1.0.0)
|
language_server-protocol (3.17.0.5)
|
||||||
multipart-post (2.3.0)
|
lint_roller (1.1.0)
|
||||||
parallel (1.26.3)
|
logger (1.7.0)
|
||||||
parser (3.3.5.0)
|
method_source (1.1.0)
|
||||||
|
net-http (0.9.1)
|
||||||
|
uri (>= 0.11.1)
|
||||||
|
parallel (1.28.0)
|
||||||
|
parser (3.3.11.1)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
racc
|
racc
|
||||||
pry (0.14.2)
|
prism (1.9.0)
|
||||||
|
pry (0.16.0)
|
||||||
coderay (~> 1.1)
|
coderay (~> 1.1)
|
||||||
method_source (~> 1.0)
|
method_source (~> 1.0)
|
||||||
public_suffix (5.0.5)
|
reline (>= 0.6.0)
|
||||||
|
public_suffix (6.0.2)
|
||||||
racc (1.8.1)
|
racc (1.8.1)
|
||||||
rainbow (3.1.1)
|
rainbow (3.1.1)
|
||||||
rake (13.2.1)
|
rake (13.4.2)
|
||||||
rb-readline (0.5.5)
|
rb-readline (0.5.5)
|
||||||
regexp_parser (2.9.2)
|
regexp_parser (2.12.0)
|
||||||
rexml (3.3.6)
|
reline (0.6.3)
|
||||||
strscan
|
io-console (~> 0.5)
|
||||||
rspec (3.13.0)
|
rexml (3.4.4)
|
||||||
|
rspec (3.13.2)
|
||||||
rspec-core (~> 3.13.0)
|
rspec-core (~> 3.13.0)
|
||||||
rspec-expectations (~> 3.13.0)
|
rspec-expectations (~> 3.13.0)
|
||||||
rspec-mocks (~> 3.13.0)
|
rspec-mocks (~> 3.13.0)
|
||||||
rspec-core (3.13.0)
|
rspec-core (3.13.6)
|
||||||
rspec-support (~> 3.13.0)
|
rspec-support (~> 3.13.0)
|
||||||
rspec-expectations (3.13.0)
|
rspec-expectations (3.13.5)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.13.0)
|
rspec-support (~> 3.13.0)
|
||||||
rspec-mocks (3.13.0)
|
rspec-mocks (3.13.8)
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
diff-lcs (>= 1.2.0, < 2.0)
|
||||||
rspec-support (~> 3.13.0)
|
rspec-support (~> 3.13.0)
|
||||||
rspec-support (3.13.0)
|
rspec-support (3.13.7)
|
||||||
rubocop (1.66.1)
|
rubocop (1.86.1)
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
language_server-protocol (>= 3.17.0)
|
language_server-protocol (~> 3.17.0.2)
|
||||||
parallel (~> 1.10)
|
lint_roller (~> 1.1.0)
|
||||||
|
parallel (>= 1.10)
|
||||||
parser (>= 3.3.0.2)
|
parser (>= 3.3.0.2)
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
regexp_parser (>= 2.4, < 3.0)
|
regexp_parser (>= 2.9.3, < 3.0)
|
||||||
rubocop-ast (>= 1.32.2, < 2.0)
|
rubocop-ast (>= 1.49.0, < 2.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 2.4.0, < 3.0)
|
unicode-display_width (>= 2.4.0, < 4.0)
|
||||||
rubocop-ast (1.32.3)
|
rubocop-ast (1.49.1)
|
||||||
parser (>= 3.3.1.0)
|
parser (>= 3.3.7.2)
|
||||||
|
prism (~> 1.7)
|
||||||
ruby-progressbar (1.13.0)
|
ruby-progressbar (1.13.0)
|
||||||
ruby2_keywords (0.0.5)
|
|
||||||
simplecov (0.22.0)
|
simplecov (0.22.0)
|
||||||
docile (~> 1.1)
|
docile (~> 1.1)
|
||||||
simplecov-html (~> 0.11)
|
simplecov-html (~> 0.11)
|
||||||
simplecov_json_formatter (~> 0.1)
|
simplecov_json_formatter (~> 0.1)
|
||||||
simplecov-html (0.13.1)
|
simplecov-html (0.13.2)
|
||||||
simplecov-lcov (0.8.0)
|
simplecov-lcov (0.8.0)
|
||||||
simplecov_json_formatter (0.1.4)
|
simplecov_json_formatter (0.1.4)
|
||||||
strscan (3.1.0)
|
unicode-display_width (3.2.0)
|
||||||
unicode-display_width (2.5.0)
|
unicode-emoji (~> 4.1)
|
||||||
webmock (3.23.1)
|
unicode-emoji (4.2.0)
|
||||||
|
uri (1.1.1)
|
||||||
|
webmock (3.26.2)
|
||||||
addressable (>= 2.8.0)
|
addressable (>= 2.8.0)
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
hashdiff (>= 0.4.0, < 2.0.0)
|
hashdiff (>= 0.4.0, < 2.0.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
aarch64-linux
|
aarch64-linux
|
||||||
|
x86_64-darwin-22
|
||||||
x86_64-linux
|
x86_64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
|
@ -122,4 +116,4 @@ DEPENDENCIES
|
||||||
webmock (~> 3.23)
|
webmock (~> 3.23)
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.4.8
|
2.5.15
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class Http
|
||||||
|
|
||||||
Faraday.new(url: url, ssl: { verify: false }) do |faraday|
|
Faraday.new(url: url, ssl: { verify: false }) do |faraday|
|
||||||
faraday.request :url_encoded
|
faraday.request :url_encoded
|
||||||
faraday.request :basic_auth, user, password
|
faraday.request :authorization, :basic, user, password
|
||||||
faraday.response :logger if verbose
|
faraday.response :logger if verbose
|
||||||
faraday.adapter Faraday.default_adapter
|
faraday.adapter Faraday.default_adapter
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ Gem::Specification.new do |s|
|
||||||
s.files = Dir['LICENSE', 'README.md', 'lib/**/*', 'extras/**/*']
|
s.files = Dir['LICENSE', 'README.md', 'lib/**/*', 'extras/**/*']
|
||||||
s.test_files = Dir['spec/**/*']
|
s.test_files = Dir['spec/**/*']
|
||||||
s.require_path = 'lib'
|
s.require_path = 'lib'
|
||||||
|
s.required_ruby_version = '>= 3.0'
|
||||||
|
|
||||||
s.add_dependency 'commander', '>= 4.4.3', '< 4.7.0'
|
s.add_dependency 'commander', '>= 4.4.3', '< 4.7.0'
|
||||||
s.add_dependency 'faraday', '~> 1.5', '>= 1.5.1'
|
s.add_dependency 'faraday', '~> 2'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue