diff --git a/.dockerignore b/.dockerignore index 6174523..eaf3712 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,10 +3,7 @@ **/*.md **/*example **/Dockerfile* -Gemfile.lock -Rakefile coverage -spec examples scripts vendor diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE index 0259cfe..5b0d10e 100644 --- a/.github/PULL_REQUEST_TEMPLATE +++ b/.github/PULL_REQUEST_TEMPLATE @@ -15,8 +15,3 @@ FIXME - [ ] Tests - [ ] Documentation -## Reviewers - -@puppetlabs/dio -@highb -@briancain diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c8f8016..90d6dfd 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,6 +3,17 @@ updates: - package-ecosystem: bundler directory: "/" schedule: - interval: daily - time: "13:00" + interval: weekly + open-pull-requests-limit: 10 + +- package-ecosystem: docker + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly open-pull-requests-limit: 10 diff --git a/.github/workflows/auto_release_prep.yml b/.github/workflows/auto_release_prep.yml new file mode 100644 index 0000000..19380e9 --- /dev/null +++ b/.github/workflows/auto_release_prep.yml @@ -0,0 +1,12 @@ +name: Automated release prep + +on: + workflow_dispatch: + +jobs: + auto_release_prep: + uses: puppetlabs/release-engineering-repo-standards/.github/workflows/auto_release_prep.yml@v1 + secrets: inherit + with: + project-type: ruby + version-file-path: lib/vmfloaty/version.rb diff --git a/.github/workflows/dependabot_merge.yml b/.github/workflows/dependabot_merge.yml new file mode 100644 index 0000000..75b9cea --- /dev/null +++ b/.github/workflows/dependabot_merge.yml @@ -0,0 +1,8 @@ +name: Dependabot auto-merge + +on: pull_request + +jobs: + dependabot_merge: + uses: puppetlabs/release-engineering-repo-standards/.github/workflows/dependabot_merge.yml@v1 + secrets: inherit diff --git a/.github/workflows/ensure_label.yml b/.github/workflows/ensure_label.yml new file mode 100644 index 0000000..50a5fa8 --- /dev/null +++ b/.github/workflows/ensure_label.yml @@ -0,0 +1,8 @@ +name: Ensure label + +on: pull_request + +jobs: + ensure_label: + uses: puppetlabs/release-engineering-repo-standards/.github/workflows/ensure_label.yml@v1 + secrets: inherit diff --git a/.github/workflows/gempush.yml b/.github/workflows/gempush.yml deleted file mode 100644 index 0d8a445..0000000 --- a/.github/workflows/gempush.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Ruby Gem - -on: - push: - tags: - - 'v*.*.*' - -jobs: - build: - name: Build + Publish - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Set up Ruby 2.6 - uses: actions/setup-ruby@v1 - with: - version: 2.6.x - - - name: Publish to RubyGems - run: | - mkdir -p $HOME/.gem - touch $HOME/.gem/credentials - chmod 0600 $HOME/.gem/credentials - printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials - gem build *.gemspec - gem push *.gem - env: - GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..d79ed5f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,118 @@ +name: Tag Release & Push Gem & Docker + +on: workflow_dispatch + +permissions: + contents: write + issues: read + pull-requests: read + packages: write + +jobs: + release: + name: Validate Docs, Tag, and Docker Push + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.ref }} + clean: true + fetch-depth: 0 + + - name: Get New Version + id: nv + run: | + version=$(grep VERSION lib/vmfloaty/version.rb |rev |cut -d "'" -f2 |rev) + echo "version=$version" >> $GITHUB_OUTPUT + echo "Found version $version from lib/vmfloaty/version.rb" + + - name: Get Current Version + uses: actions/github-script@v7 + id: cv + with: + script: | + const { data: response } = await github.rest.repos.getLatestRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + }) + console.log(`The latest release is ${response.tag_name}`) + return response.tag_name + result-encoding: string + + - name: Generate Changelog + uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2 + with: + args: >- + --future-release ${{ steps.nv.outputs.version }} + env: + CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Validate Changelog + run : | + set -e + if output=$(git status --porcelain) && [ ! -z "$output" ]; then + echo "Here is the current git status:" + git status + echo + echo "The following changes were detected:" + git --no-pager diff + echo "Uncommitted PRs found in the changelog. Please submit a release prep PR of changes after running './release-prep ${{ steps.nv.outputs.version }}'" + exit 1 + fi + + - name: Generate Release Notes + uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2 + with: + args: >- + --since-tag ${{ steps.cv.outputs.result }} + --future-release ${{ steps.nv.outputs.version }} + --output release-notes.md + env: + CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Tag Release + uses: ncipollo/release-action@v1 + with: + tag: ${{ steps.nv.outputs.version }} + token: ${{ secrets.GITHUB_TOKEN }} + bodyfile: release-notes.md + draft: false + prerelease: false + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + tags: | + ghcr.io/${{ github.repository }}:${{ steps.nv.outputs.version }} + ghcr.io/${{ github.repository }}:latest + + - name: Set up Ruby 3.2 + uses: actions/setup-ruby@v1 + with: + version: 3.2.x + + - name: Build gem + run: gem build *.gemspec + + - name: Publish gem + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + gem push *.gem + env: + GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}} diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..ba273f5 --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,39 @@ +name: Security +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + scan: + name: Mend Scanning + runs-on: ubuntu-latest + steps: + - name: checkout repo content + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + # setup a package lock if one doesn't exist, otherwise do nothing + - name: check lock + run: '[ -f "Gemfile.lock" ] && echo "package lock file exists, skipping" || bundle lock' + # install java + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' # See 'Supported distributions' for available options + java-version: '17' + # download mend + - name: download_mend + run: curl -o wss-unified-agent.jar https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar + - name: run mend + run: java -jar wss-unified-agent.jar + env: + WS_APIKEY: ${{ secrets.MEND_API_KEY }} + WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent + WS_USERKEY: ${{ secrets.MEND_TOKEN }} + WS_PRODUCTNAME: RE + WS_PROJECTNAME: ${{ github.event.repository.name }} diff --git a/.github/workflows/ci.yml b/.github/workflows/test.yml similarity index 84% rename from .github/workflows/ci.yml rename to .github/workflows/test.yml index 42edd97..8562713 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby -name: CI +name: Test on: pull_request: @@ -13,18 +13,18 @@ on: - main jobs: - test: - + spec: runs-on: ubuntu-latest strategy: matrix: ruby-version: - - '2.6' - '2.7' - '3.0' + - '3.1' + - '3.2' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Ruby # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, # change this to (see https://github.com/ruby/setup-ruby#versioning): @@ -36,18 +36,19 @@ jobs: - name: Run tests run: bundle exec rake spec - name: Coveralls - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: run-${{ matrix.ruby-version }} parallel: true finish: - needs: test + needs: spec + if: ${{ always() }} runs-on: ubuntu-latest steps: - name: Coveralls Finished - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.github_token }} - parallel-finished: true \ No newline at end of file + parallel-finished: true diff --git a/.github_changelog_generator b/.github_changelog_generator new file mode 100644 index 0000000..02a0c7c --- /dev/null +++ b/.github_changelog_generator @@ -0,0 +1,3 @@ +project=vmfloaty +user=puppetlabs +exclude_labels=maintenance diff --git a/.gitignore b/.gitignore index 5102fb1..76a21bc 100644 --- a/.gitignore +++ b/.gitignore @@ -25,9 +25,10 @@ build/ /vendor/ /lib/bundler/man/ +.dccache + # for a library or gem, you might want to ignore these files since the code is # intended to run in multiple environments; otherwise, check them in: -Gemfile.lock .ruby-version .ruby-gemset diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ff7c73f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,340 @@ +# Changelog + +## [1.8.1](https://github.com/puppetlabs/vmfloaty/tree/1.8.1) (2023-08-07) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/1.8.0...1.8.1) + +**Fixed bugs:** + +- status and summary broken for pooler service after v3 [\#185](https://github.com/puppetlabs/vmfloaty/issues/185) +- \(RE-15687\) Use relative path for pooler status and summary [\#186](https://github.com/puppetlabs/vmfloaty/pull/186) ([yachub](https://github.com/yachub)) + +**Merged pull requests:** + +- Bump rubocop from 1.54.2 to 1.55.1 [\#183](https://github.com/puppetlabs/vmfloaty/pull/183) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump rubocop from 1.52.0 to 1.54.2 [\#182](https://github.com/puppetlabs/vmfloaty/pull/182) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump rubocop from 1.51.0 to 1.52.0 [\#177](https://github.com/puppetlabs/vmfloaty/pull/177) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump rubocop from 1.50.2 to 1.51.0 [\#176](https://github.com/puppetlabs/vmfloaty/pull/176) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump rubocop from 1.49.0 to 1.50.2 [\#174](https://github.com/puppetlabs/vmfloaty/pull/174) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Bump rubocop from 1.48.1 to 1.49.0 [\#173](https://github.com/puppetlabs/vmfloaty/pull/173) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Update simplecov requirement from ~\> 0.21.2 to ~\> 0.22.0 [\#167](https://github.com/puppetlabs/vmfloaty/pull/167) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Update rspec requirement from ~\> 3.11.0 to ~\> 3.12.0 [\#166](https://github.com/puppetlabs/vmfloaty/pull/166) ([dependabot[bot]](https://github.com/apps/dependabot)) + +## [1.8.0](https://github.com/puppetlabs/vmfloaty/tree/1.8.0) (2023-03-21) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/1.7.0...1.8.0) + +**Implemented enhancements:** + +- Docker, Actions, and Docs Updates [\#170](https://github.com/puppetlabs/vmfloaty/pull/170) ([yachub](https://github.com/yachub)) + +**Fixed bugs:** + +- Fix `floaty list --active` for vmpooler api v2 [\#169](https://github.com/puppetlabs/vmfloaty/pull/169) ([yachub](https://github.com/yachub)) + +**Merged pull requests:** + +- \(RE-15111\) Migrate Synk to Mend [\#168](https://github.com/puppetlabs/vmfloaty/pull/168) ([yachub](https://github.com/yachub)) +- \(RE-14811\) Move codeowners from DIO to RE [\#165](https://github.com/puppetlabs/vmfloaty/pull/165) ([yachub](https://github.com/yachub)) +- Add Snyk action and Move to RE org [\#164](https://github.com/puppetlabs/vmfloaty/pull/164) ([yachub](https://github.com/yachub)) +- Add release-engineering to codeowners [\#163](https://github.com/puppetlabs/vmfloaty/pull/163) ([yachub](https://github.com/yachub)) + +## [1.7.0](https://github.com/puppetlabs/vmfloaty/tree/1.7.0) (2022-04-05) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.6.0...1.7.0) + +**Implemented enhancements:** + +- \(maint\) Add Ruby 3.1 to test matrix + dockerfile and drop EOL Ruby 2.6 [\#159](https://github.com/puppetlabs/vmfloaty/pull/159) ([yachub](https://github.com/yachub)) +- \(DIO-3101\) Add VMPooler API v2 Support [\#158](https://github.com/puppetlabs/vmfloaty/pull/158) ([yachub](https://github.com/yachub)) + +**Fixed bugs:** + +- \(maint\) Remove colorize usage from `floaty status` [\#160](https://github.com/puppetlabs/vmfloaty/pull/160) ([yachub](https://github.com/yachub)) + +**Merged pull requests:** + +- v1.7.0 release prep [\#162](https://github.com/puppetlabs/vmfloaty/pull/162) ([yachub](https://github.com/yachub)) +- \(maint\) removing previous maintainers [\#157](https://github.com/puppetlabs/vmfloaty/pull/157) ([binford2k](https://github.com/binford2k)) +- Update rspec requirement from ~\> 3.10.0 to ~\> 3.11.0 [\#155](https://github.com/puppetlabs/vmfloaty/pull/155) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Docs on contributing and releasing [\#152](https://github.com/puppetlabs/vmfloaty/pull/152) ([genebean](https://github.com/genebean)) + +## [v1.6.0](https://github.com/puppetlabs/vmfloaty/tree/v1.6.0) (2022-02-16) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.5.0...v1.6.0) + +**Merged pull requests:** + +- \(DIO-2700\) Vmfloaty should not use the Colorize gem [\#156](https://github.com/puppetlabs/vmfloaty/pull/156) ([sbeaulie](https://github.com/sbeaulie)) +- \(maint\) Fix up nspooler list active bug [\#154](https://github.com/puppetlabs/vmfloaty/pull/154) ([cthorn42](https://github.com/cthorn42)) +- Minor cleanup to the readme [\#151](https://github.com/puppetlabs/vmfloaty/pull/151) ([genebean](https://github.com/genebean)) +- Release prep for 1.5.0 [\#150](https://github.com/puppetlabs/vmfloaty/pull/150) ([genebean](https://github.com/genebean)) + +## [v1.5.0](https://github.com/puppetlabs/vmfloaty/tree/v1.5.0) (2021-10-12) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.4.0...v1.5.0) + +**Merged pull requests:** + +- DIO 2412- Ondemand and Priority flag added to SSH command [\#149](https://github.com/puppetlabs/vmfloaty/pull/149) ([tanisha-payne](https://github.com/tanisha-payne)) +- \(DIO-2135\) Update docker FROM image to ruby 3.0.2 [\#148](https://github.com/puppetlabs/vmfloaty/pull/148) ([sbeaulie](https://github.com/sbeaulie)) +- Migrate CI to GitHub Actions [\#147](https://github.com/puppetlabs/vmfloaty/pull/147) ([genebean](https://github.com/genebean)) +- v1.4.0 release prep [\#146](https://github.com/puppetlabs/vmfloaty/pull/146) ([genebean](https://github.com/genebean)) + +## [v1.4.0](https://github.com/puppetlabs/vmfloaty/tree/v1.4.0) (2021-07-16) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.3.0...v1.4.0) + +**Merged pull requests:** + +- \(maint\) Use latest Faraday/webmock, update specs [\#145](https://github.com/puppetlabs/vmfloaty/pull/145) ([nmburgan](https://github.com/nmburgan)) +- Update commander requirement from \>= 4.4.3, \< 4.6.0 to \>= 4.4.3, \< 4.7.0 [\#140](https://github.com/puppetlabs/vmfloaty/pull/140) ([dependabot[bot]](https://github.com/apps/dependabot)) +- Release prep for v1.3.0 [\#137](https://github.com/puppetlabs/vmfloaty/pull/137) ([sbeaulie](https://github.com/sbeaulie)) +- Run the rubocop auto\_correct [\#135](https://github.com/puppetlabs/vmfloaty/pull/135) ([sbeaulie](https://github.com/sbeaulie)) + +## [v1.3.0](https://github.com/puppetlabs/vmfloaty/tree/v1.3.0) (2021-03-03) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.2.0...v1.3.0) + +**Merged pull requests:** + +- \(DIO-1522\) Show the VM state \(running, destroyed\) and colorize in red… [\#134](https://github.com/puppetlabs/vmfloaty/pull/134) ([sbeaulie](https://github.com/sbeaulie)) +- Release prep for 1.2.0 [\#132](https://github.com/puppetlabs/vmfloaty/pull/132) ([genebean](https://github.com/genebean)) +- Update rubocop requirement from ~\> 0.52 to ~\> 1.6 [\#124](https://github.com/puppetlabs/vmfloaty/pull/124) ([dependabot[bot]](https://github.com/apps/dependabot)) + +## [v1.2.0](https://github.com/puppetlabs/vmfloaty/tree/v1.2.0) (2021-02-11) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.1.1...v1.2.0) + +**Merged pull requests:** + +- \(DIO-908\) Floaty can now report the status of ABS requests [\#131](https://github.com/puppetlabs/vmfloaty/pull/131) ([sbeaulie](https://github.com/sbeaulie)) +- Update rspec requirement from ~\> 3.9.0 to ~\> 3.10.0 [\#116](https://github.com/puppetlabs/vmfloaty/pull/116) ([dependabot[bot]](https://github.com/apps/dependabot)) + +## [v1.1.1](https://github.com/puppetlabs/vmfloaty/tree/v1.1.1) (2020-10-16) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.1.0...v1.1.1) + +**Merged pull requests:** + +- V1.1.1 [\#112](https://github.com/puppetlabs/vmfloaty/pull/112) ([sbeaulie](https://github.com/sbeaulie)) + +## [v1.1.0](https://github.com/puppetlabs/vmfloaty/tree/v1.1.0) (2020-10-09) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.0.0...v1.1.0) + +**Merged pull requests:** + +- \(maint\) Add more uniqueness to jobid and useful termination message [\#107](https://github.com/puppetlabs/vmfloaty/pull/107) ([sbeaulie](https://github.com/sbeaulie)) +- \(maint\) Fix bug with detecting ABS service [\#106](https://github.com/puppetlabs/vmfloaty/pull/106) ([sbeaulie](https://github.com/sbeaulie)) +- \(maint\) Don't require config file for list --active [\#105](https://github.com/puppetlabs/vmfloaty/pull/105) ([sbeaulie](https://github.com/sbeaulie)) +- \(maint\) Don't require configuration file for get [\#104](https://github.com/puppetlabs/vmfloaty/pull/104) ([nwolfe](https://github.com/nwolfe)) +- \(maint\) Add vmpooler\_fallback to the get service check [\#103](https://github.com/puppetlabs/vmfloaty/pull/103) ([cthorn42](https://github.com/cthorn42)) +- Update completion scripts for `service` subcommands [\#102](https://github.com/puppetlabs/vmfloaty/pull/102) ([scotje](https://github.com/scotje)) +- Bump to version 1.0.0 [\#100](https://github.com/puppetlabs/vmfloaty/pull/100) ([genebean](https://github.com/genebean)) + +## [v1.0.0](https://github.com/puppetlabs/vmfloaty/tree/v1.0.0) (2020-09-22) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/0.11.1...v1.0.0) + +**Merged pull requests:** + +- \(maint\) Fix for ABS PR\#306 that includes json responses [\#99](https://github.com/puppetlabs/vmfloaty/pull/99) ([sbeaulie](https://github.com/sbeaulie)) +- \(maint\) Support any vmpooler for ABS via vmpooler\_fallback [\#98](https://github.com/puppetlabs/vmfloaty/pull/98) ([sbeaulie](https://github.com/sbeaulie)) +- \(DIO-991\) Add service command [\#97](https://github.com/puppetlabs/vmfloaty/pull/97) ([genebean](https://github.com/genebean)) +- \( DIO-911\) Include job\_id in ABS --json output [\#96](https://github.com/puppetlabs/vmfloaty/pull/96) ([sbeaulie](https://github.com/sbeaulie)) +- ABS enables fallback to vmpooler for some scenarios [\#94](https://github.com/puppetlabs/vmfloaty/pull/94) ([sbeaulie](https://github.com/sbeaulie)) +- WIP \(DIO-911\) Include job\_id in ABS --json output [\#92](https://github.com/puppetlabs/vmfloaty/pull/92) ([nwolfe](https://github.com/nwolfe)) +- \(maint\) Remove warning about missing configuration file [\#91](https://github.com/puppetlabs/vmfloaty/pull/91) ([nwolfe](https://github.com/nwolfe)) +- Add tab completion script for zsh and fix bash completion for ABS services [\#90](https://github.com/puppetlabs/vmfloaty/pull/90) ([scotje](https://github.com/scotje)) + +## [0.11.1](https://github.com/puppetlabs/vmfloaty/tree/0.11.1) (2020-08-20) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/0.10.0...0.11.1) + +**Merged pull requests:** + +- Update version for 0.11.1 release [\#89](https://github.com/puppetlabs/vmfloaty/pull/89) ([mattkirby](https://github.com/mattkirby)) +- \(maint\) Fix using ABS service without a .vmfloaty.yml file [\#88](https://github.com/puppetlabs/vmfloaty/pull/88) ([cthorn42](https://github.com/cthorn42)) +- Fix the argument list for nonstandardpooler [\#87](https://github.com/puppetlabs/vmfloaty/pull/87) ([jarretlavallee](https://github.com/jarretlavallee)) +- Json output for delete/list + better ABS error handling [\#86](https://github.com/puppetlabs/vmfloaty/pull/86) ([mcdonaldseanp](https://github.com/mcdonaldseanp)) +- Bump version for 0.11.0 release [\#85](https://github.com/puppetlabs/vmfloaty/pull/85) ([mattkirby](https://github.com/mattkirby)) +- Print all non-success output to STDERR [\#84](https://github.com/puppetlabs/vmfloaty/pull/84) ([austb](https://github.com/austb)) +- Update travis.yml [\#83](https://github.com/puppetlabs/vmfloaty/pull/83) ([rooneyshuman](https://github.com/rooneyshuman)) +- Bump version to 0.10.0 for release [\#82](https://github.com/puppetlabs/vmfloaty/pull/82) ([mattkirby](https://github.com/mattkirby)) + +## [0.10.0](https://github.com/puppetlabs/vmfloaty/tree/0.10.0) (2020-08-04) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.9.2-retag-for-gh-actions-for-real...0.10.0) + +**Merged pull requests:** + +- Update Dependabot config file [\#78](https://github.com/puppetlabs/vmfloaty/pull/78) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Update rspec requirement from ~\> 3.5.0 to ~\> 3.9.0 [\#75](https://github.com/puppetlabs/vmfloaty/pull/75) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Update commander requirement from ~\> 4.4.3 to \>= 4.4.3, \< 4.6.0 [\#73](https://github.com/puppetlabs/vmfloaty/pull/73) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview)) +- Fix formatting of CODEOWNERS [\#71](https://github.com/puppetlabs/vmfloaty/pull/71) ([genebean](https://github.com/genebean)) +- Add Dependabot and Coveralls [\#70](https://github.com/puppetlabs/vmfloaty/pull/70) ([genebean](https://github.com/genebean)) +- Update docs [\#69](https://github.com/puppetlabs/vmfloaty/pull/69) ([genebean](https://github.com/genebean)) +- Remove old maintainer note [\#68](https://github.com/puppetlabs/vmfloaty/pull/68) ([briancain](https://github.com/briancain)) +- Add support for vmpooler on demand provisioning [\#67](https://github.com/puppetlabs/vmfloaty/pull/67) ([mattkirby](https://github.com/mattkirby)) + +## [v0.9.2-retag-for-gh-actions-for-real](https://github.com/puppetlabs/vmfloaty/tree/v0.9.2-retag-for-gh-actions-for-real) (2020-02-05) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.9.2...v0.9.2-retag-for-gh-actions-for-real) + +**Merged pull requests:** + +- Update gempush action to remove GPR publish [\#66](https://github.com/puppetlabs/vmfloaty/pull/66) ([highb](https://github.com/highb)) + +## [v0.9.2](https://github.com/puppetlabs/vmfloaty/tree/v0.9.2) (2020-02-05) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.9.2-retag-for-gh-actions...v0.9.2) + +## [v0.9.2-retag-for-gh-actions](https://github.com/puppetlabs/vmfloaty/tree/v0.9.2-retag-for-gh-actions) (2020-02-05) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.9.0...v0.9.2-retag-for-gh-actions) + +**Merged pull requests:** + +- Bump version.rb to 0.9.2 for release [\#65](https://github.com/puppetlabs/vmfloaty/pull/65) ([highb](https://github.com/highb)) +- Create gempush.yml Github Action [\#64](https://github.com/puppetlabs/vmfloaty/pull/64) ([highb](https://github.com/highb)) +- Bump faraday dependency for Ruby 2.7 compatibility [\#62](https://github.com/puppetlabs/vmfloaty/pull/62) ([nicklewis](https://github.com/nicklewis)) +- SSH Command respects ABS now and tests should fail if the API changes… [\#61](https://github.com/puppetlabs/vmfloaty/pull/61) ([mikkergimenez](https://github.com/mikkergimenez)) +- \(QENG-7604\) Add support for Job IDs to ABS delete [\#60](https://github.com/puppetlabs/vmfloaty/pull/60) ([highb](https://github.com/highb)) +- Bump version.rb to 0.9.1 [\#59](https://github.com/puppetlabs/vmfloaty/pull/59) ([highb](https://github.com/highb)) +- Fix error with delete command for vmpooler and nspooler [\#58](https://github.com/puppetlabs/vmfloaty/pull/58) ([mikkergimenez](https://github.com/mikkergimenez)) + +## [v0.9.0](https://github.com/puppetlabs/vmfloaty/tree/v0.9.0) (2019-12-17) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.8.2...v0.9.0) + +**Implemented enhancements:** + +- Add abs vm get [\#53](https://github.com/puppetlabs/vmfloaty/pull/53) ([mikkergimenez](https://github.com/mikkergimenez)) + +**Fixed bugs:** + +- vmfloaty reports an error on latest API version output [\#48](https://github.com/puppetlabs/vmfloaty/issues/48) + +**Merged pull requests:** + +- ABS will sometimes return null values in the /status/queue endpoint [\#57](https://github.com/puppetlabs/vmfloaty/pull/57) ([mikkergimenez](https://github.com/mikkergimenez)) +- Minor version bump to 0.9.0 [\#56](https://github.com/puppetlabs/vmfloaty/pull/56) ([highb](https://github.com/highb)) +- Update pooler provider to throw an exception if the API returns non-OK [\#55](https://github.com/puppetlabs/vmfloaty/pull/55) ([highb](https://github.com/highb)) +- Update Faraday to 0.15, remove unnecessary headers [\#54](https://github.com/puppetlabs/vmfloaty/pull/54) ([highb](https://github.com/highb)) +- change urls in docs to use example.net/.com [\#50](https://github.com/puppetlabs/vmfloaty/pull/50) ([steveax](https://github.com/steveax)) +- Rubocop cleanup [\#49](https://github.com/puppetlabs/vmfloaty/pull/49) ([rodjek](https://github.com/rodjek)) + +## [v0.8.2](https://github.com/puppetlabs/vmfloaty/tree/v0.8.2) (2018-01-05) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.8.1...v0.8.2) + +**Merged pull requests:** + +- 🎂🎂🎂 Add --json option for `floaty get` [\#47](https://github.com/puppetlabs/vmfloaty/pull/47) ([nicklewis](https://github.com/nicklewis)) + +## [v0.8.1](https://github.com/puppetlabs/vmfloaty/tree/v0.8.1) (2017-10-24) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.8.0...v0.8.1) + +**Merged pull requests:** + +- Bump commander version to clear up deprecation warnings [\#46](https://github.com/puppetlabs/vmfloaty/pull/46) ([highb](https://github.com/highb)) + +## [v0.8.0](https://github.com/puppetlabs/vmfloaty/tree/v0.8.0) (2017-10-13) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.9...v0.8.0) + +**Closed issues:** + +- don't automatically call system pager for help screens [\#20](https://github.com/puppetlabs/vmfloaty/issues/20) + +**Merged pull requests:** + +- Add configuration for multiple pooler services and integration with nspooler [\#45](https://github.com/puppetlabs/vmfloaty/pull/45) ([caseywilliams](https://github.com/caseywilliams)) + +## [v0.7.9](https://github.com/puppetlabs/vmfloaty/tree/v0.7.9) (2017-07-31) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.8...v0.7.9) + +**Closed issues:** + +- Handle when vmfloaty cannot reach vmpooler [\#39](https://github.com/puppetlabs/vmfloaty/issues/39) + +**Merged pull requests:** + +- Add basic bash completion script and framework for others [\#44](https://github.com/puppetlabs/vmfloaty/pull/44) ([scotje](https://github.com/scotje)) +- Developersdevelopersdevelopers [\#43](https://github.com/puppetlabs/vmfloaty/pull/43) ([mckern](https://github.com/mckern)) + +## [v0.7.8](https://github.com/puppetlabs/vmfloaty/tree/v0.7.8) (2016-12-20) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.7...v0.7.8) + +## [v0.7.7](https://github.com/puppetlabs/vmfloaty/tree/v0.7.7) (2016-12-14) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.6...v0.7.7) + +## [v0.7.6](https://github.com/puppetlabs/vmfloaty/tree/v0.7.6) (2016-12-09) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.5...v0.7.6) + +**Closed issues:** + +- Improve the help text for floaty commands [\#41](https://github.com/puppetlabs/vmfloaty/issues/41) +- Require force flag for pool requests larger than 5? [\#40](https://github.com/puppetlabs/vmfloaty/issues/40) + +## [v0.7.5](https://github.com/puppetlabs/vmfloaty/tree/v0.7.5) (2016-12-06) + +[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/1f86113243eb2e898b21c29892c05477e3487d2d...v0.7.5) + +**Implemented enhancements:** + +- Improve how to specify number of vms in get request [\#8](https://github.com/puppetlabs/vmfloaty/issues/8) +- Improve output from commands [\#3](https://github.com/puppetlabs/vmfloaty/issues/3) + +**Fixed bugs:** + +- floaty snapshot fails to authenticate [\#4](https://github.com/puppetlabs/vmfloaty/issues/4) + +**Closed issues:** + +- floaty snapshot should warn users about how long it takes to get snapshot [\#37](https://github.com/puppetlabs/vmfloaty/issues/37) +- floaty modify should allow to make changes on more than one machine [\#36](https://github.com/puppetlabs/vmfloaty/issues/36) +- Pooler.modify raises exception if Token is nil [\#34](https://github.com/puppetlabs/vmfloaty/issues/34) +- Improve error handling in Pooler and Auth classes [\#33](https://github.com/puppetlabs/vmfloaty/issues/33) +- Handle vmpooler responses when token is invalid in Pooler class [\#32](https://github.com/puppetlabs/vmfloaty/issues/32) +- Misuse of 'floaty revert ...' seems to create a new snapshot [\#31](https://github.com/puppetlabs/vmfloaty/issues/31) +- Test [\#30](https://github.com/puppetlabs/vmfloaty/issues/30) +- Don't system exit in Auth class [\#29](https://github.com/puppetlabs/vmfloaty/issues/29) +- Add flag to auto-ssh into a newly created \(single\) VM [\#28](https://github.com/puppetlabs/vmfloaty/issues/28) +- Handle vmpooler URL key that doesn't have 'https' [\#27](https://github.com/puppetlabs/vmfloaty/issues/27) +- Abstract vmfloaty cli related errors to command class rather than pooler class [\#26](https://github.com/puppetlabs/vmfloaty/issues/26) +- Don't puts results in `delete` method in Pooler library [\#25](https://github.com/puppetlabs/vmfloaty/issues/25) +- Improve `get` output [\#24](https://github.com/puppetlabs/vmfloaty/issues/24) +- specs don't work [\#22](https://github.com/puppetlabs/vmfloaty/issues/22) +- Add ability to get additional disk space for a running vm [\#19](https://github.com/puppetlabs/vmfloaty/issues/19) +- Have a force option for `delete --all` [\#17](https://github.com/puppetlabs/vmfloaty/issues/17) +- Stop printing json response in library methods [\#14](https://github.com/puppetlabs/vmfloaty/issues/14) +- Stop system exiting in library methods [\#13](https://github.com/puppetlabs/vmfloaty/issues/13) +- List active vms for a given token [\#12](https://github.com/puppetlabs/vmfloaty/issues/12) +- Provide a way to clean up vms obtained by a token [\#11](https://github.com/puppetlabs/vmfloaty/issues/11) +- Allow spaces when passing in vms for commands [\#10](https://github.com/puppetlabs/vmfloaty/issues/10) +- Write Tests for Pooler class [\#9](https://github.com/puppetlabs/vmfloaty/issues/9) +- Document all valid config file keys [\#7](https://github.com/puppetlabs/vmfloaty/issues/7) +- Write up simple "introduction" to using the tool [\#6](https://github.com/puppetlabs/vmfloaty/issues/6) +- Document how to use Pooler class for ruby scripts [\#5](https://github.com/puppetlabs/vmfloaty/issues/5) +- Convert vmfloaty to use latest pooler API [\#1](https://github.com/puppetlabs/vmfloaty/issues/1) + +**Merged pull requests:** + +- Show the status of pools with `floaty status` [\#38](https://github.com/puppetlabs/vmfloaty/pull/38) ([nicklewis](https://github.com/nicklewis)) +- Show tag values in `list --active` [\#23](https://github.com/puppetlabs/vmfloaty/pull/23) ([justinstoller](https://github.com/justinstoller)) +- \(\#19\) Update vmfloaty to expect /api/v1 in URL for disk endpoint [\#21](https://github.com/puppetlabs/vmfloaty/pull/21) ([briancain](https://github.com/briancain)) +- \(\#17\) Add a force option for delete --all [\#18](https://github.com/puppetlabs/vmfloaty/pull/18) ([briancain](https://github.com/briancain)) +- \(\#12\) List active vms for a given token [\#16](https://github.com/puppetlabs/vmfloaty/pull/16) ([briancain](https://github.com/briancain)) +- Cleanup vmfloaty library and command processor [\#15](https://github.com/puppetlabs/vmfloaty/pull/15) ([briancain](https://github.com/briancain)) +- \(\#1\) Update with commander [\#2](https://github.com/puppetlabs/vmfloaty/pull/2) ([briancain](https://github.com/briancain)) + + + +\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/CODEOWNERS b/CODEOWNERS index 321cebf..e8dffe5 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1,3 +1,3 @@ # Set the default code owners -* @puppetlabs/dio @briancain @highb +* @puppetlabs/release-engineering diff --git a/Dockerfile b/Dockerfile index ceaa74e..5c8fd0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,23 @@ -FROM ruby:3.0.1-slim-buster +FROM ruby:3.3.5-slim-bullseye -COPY ./ ./ +LABEL org.opencontainers.image.authors="@puppetlabs/release-engineering" +LABEL org.opencontainers.image.title="vmfloaty" +LABEL org.opencontainers.image.source=https://github.com/puppetlabs/vmfloaty +LABEL org.opencontainers.image.description="A CLI helper tool for VMPooler" -RUN apt-get update && apt-get install -y less -RUN gem install bundler && bundle install && gem build vmfloaty.gemspec && gem install vmfloaty*.gem +RUN apt-get update -qq && apt-get install -y build-essential less make openssh-client + +RUN groupadd --gid 1000 floatygroup \ + && useradd --uid 1000 --gid 1000 -m floatyuser + +USER floatyuser + +WORKDIR /home/floatyuser/app +COPY --chown=floatyuser:floatygroup . . + +RUN gem install bundler \ + && bundle install \ + && gem build vmfloaty.gemspec \ + && gem install vmfloaty*.gem + +ENTRYPOINT [ "floaty" ] diff --git a/Gemfile b/Gemfile index 6e26d2a..7f70b2e 100644 --- a/Gemfile +++ b/Gemfile @@ -7,12 +7,12 @@ gemspec gem 'rake', require: false group :test do - gem 'simplecov', '~> 0.21.2' - gem 'simplecov-html', '~> 0.12.3' + gem 'simplecov', '~> 0.22.0' + gem 'simplecov-html', '~> 0.13.1' gem 'simplecov-lcov', '~> 0.8.0' gem 'pry' gem 'rb-readline' - gem 'rspec', '~> 3.10.0' - gem 'rubocop', '~> 1.6' - gem 'webmock', '~> 3.13' + gem 'rspec', '~> 3.13.0' + gem 'rubocop', '~> 1.66' + gem 'webmock', '~> 3.23' end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..7d27ddd --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,125 @@ +PATH + remote: . + specs: + vmfloaty (1.8.1) + commander (>= 4.4.3, < 4.7.0) + faraday (~> 1.5, >= 1.5.1) + +GEM + remote: https://rubygems.org/ + specs: + addressable (2.8.6) + public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) + bigdecimal (3.1.8) + coderay (1.1.3) + commander (4.6.0) + highline (~> 2.0.0) + crack (1.0.0) + bigdecimal + rexml + diff-lcs (1.5.1) + docile (1.4.0) + faraday (1.10.3) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + 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) + json (2.7.2) + language_server-protocol (3.17.0.3) + method_source (1.0.0) + multipart-post (2.3.0) + parallel (1.26.3) + parser (3.3.5.0) + ast (~> 2.4.1) + racc + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + public_suffix (5.0.5) + racc (1.8.1) + rainbow (3.1.1) + rake (13.2.1) + rb-readline (0.5.5) + regexp_parser (2.9.2) + rexml (3.3.6) + strscan + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.0) + rubocop (1.66.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) + ruby-progressbar (1.13.0) + ruby2_keywords (0.0.5) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.1) + simplecov-lcov (0.8.0) + simplecov_json_formatter (0.1.4) + strscan (3.1.0) + unicode-display_width (2.5.0) + webmock (3.23.1) + addressable (>= 2.8.0) + crack (>= 0.3.2) + hashdiff (>= 0.4.0, < 2.0.0) + +PLATFORMS + aarch64-linux + x86_64-linux + +DEPENDENCIES + pry + rake + rb-readline + rspec (~> 3.13.0) + rubocop (~> 1.66) + simplecov (~> 0.22.0) + simplecov-html (~> 0.13.1) + simplecov-lcov (~> 0.8.0) + vmfloaty! + webmock (~> 3.23) + +BUNDLED WITH + 2.4.8 diff --git a/README.md b/README.md index 4c60f87..dfc22f9 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,48 @@ # vmfloaty [![Gem Version](https://badge.fury.io/rb/vmfloaty.svg)](https://badge.fury.io/rb/vmfloaty) -[![CI](https://github.com/puppetlabs/vmfloaty/actions/workflows/ci.yml/badge.svg)](https://github.com/puppetlabs/vmfloaty/actions/workflows/ci.yml) +[![Test](https://github.com/puppetlabs/vmfloaty/actions/workflows/test.yml/badge.svg)](https://github.com/puppetlabs/vmfloaty/actions/workflows/test.yml) A CLI helper tool for [Puppet's VMPooler](https://github.com/puppetlabs/vmpooler) to help you stay afloat. ![float image](float.jpg) -- [Install](#install) -- [Usage](#usage) - - [Example workflow](#example-workflow) - - [vmfloaty dotfile](#vmfloaty-dotfile) - - [Basic configuration](#basic-configuration) - - [Using multiple services](#using-multiple-services) - - [Using backends besides VMPooler](#using-backends-besides-vmpooler) - - [Valid config keys](#valid-config-keys) - - [Tab Completion](#tab-completion) -- [VMPooler API](#vmpooler-api) -- [Using the Pooler class](#using-the-pooler-class) - - [Example Projects](#example-projects) -- [Special thanks](#special-thanks) +- [vmfloaty](#vmfloaty) + - [Install](#install) + - [Ruby](#ruby) + - [Docker](#docker) + - [Usage](#usage) + - [Example workflow](#example-workflow) + - [vmfloaty dotfile](#vmfloaty-dotfile) + - [Basic configuration](#basic-configuration) + - [Using multiple services](#using-multiple-services) + - [Using backends besides VMPooler](#using-backends-besides-vmpooler) + - [Valid config keys](#valid-config-keys) + - [Tab Completion](#tab-completion) + - [VMPooler API](#vmpooler-api) + - [Using the Pooler class](#using-the-pooler-class) + - [Example Projects](#example-projects) + - [Contributing](#contributing) + - [Code Reviews](#code-reviews) + - [Releasing](#releasing) + - [Special thanks](#special-thanks) ## Install +### Ruby + Grab the latest from ruby gems... ```bash gem install vmfloaty ``` +### Docker + +Run the docker image: + +`docker run -it --rm -v ~/.vmfloaty.yml:/home/floatyuser/.vmfloaty.yml ghcr.io/puppetlabs/vmfloaty --help` + ## Usage ```plain @@ -164,6 +178,23 @@ vmfloaty providers a `Pooler` class that gives users the ability to make request - [Brian Cain: vagrant-vmpooler](https://github.com/briancain/vagrant-vmpooler) - Use Vagrant to manage your vmpooler instances +## Contributing + +PR's are welcome! We always love to see how others think this tool can be made better. + +### Code Reviews + +Please wait for multiple code owners to sign off on any notable change. + +## Releasing + +Follow these steps to publish a new GitHub release, build and push the gem to , and build and push a Docker Image to GitHub Container Registry: + +1. Bump the "VERSION" in `lib/vmfloaty/version.rb` appropriately based on changes in `CHANGELOG.md` since the last release. +2. Run `./release-prep` to update `Gemfile.lock` and `CHANGELOG.md`. +3. Commit and push changes to a new branch, then open a pull request against `main` and be sure to add the "maintenance" label. +4. After the pull request is approved and merged, then navigate to --> 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. + ## Special thanks Special thanks to [Brian Cain](https://github.com/briancain) as he is the original author of vmfloaty! Vast amounts of this code exist thanks to his efforts. diff --git a/lib/vmfloaty.rb b/lib/vmfloaty.rb index 237632b..3c6bbec 100644 --- a/lib/vmfloaty.rb +++ b/lib/vmfloaty.rb @@ -484,7 +484,7 @@ class Vmfloaty FloatyLogger.info "Can't ssh to multiple hosts; Using #{host_os} only..." if args.length > 1 - service.ssh(verbose, host_os, use_token) + service.ssh(verbose, host_os, use_token, options.ondemand) exit 0 end end diff --git a/lib/vmfloaty/pooler.rb b/lib/vmfloaty/pooler.rb index 855e604..9d47407 100644 --- a/lib/vmfloaty/pooler.rb +++ b/lib/vmfloaty/pooler.rb @@ -146,14 +146,14 @@ class Pooler def self.status(verbose, url) conn = Http.get_conn(verbose, url) - response = conn.get '/status' + response = conn.get 'status' JSON.parse(response.body) end def self.summary(verbose, url) conn = Http.get_conn(verbose, url) - response = conn.get '/summary' + response = conn.get 'summary' JSON.parse(response.body) end diff --git a/lib/vmfloaty/service.rb b/lib/vmfloaty/service.rb index 05904a1..a9e59ba 100644 --- a/lib/vmfloaty/service.rb +++ b/lib/vmfloaty/service.rb @@ -87,7 +87,7 @@ class Service @service_object.wait_for_request verbose, requestid, url end - def ssh(verbose, host_os, use_token = true) + def ssh(verbose, host_os, use_token = true, ondemand = nil) token_value = nil if use_token begin @@ -97,7 +97,7 @@ class Service FloatyLogger.info 'Could not get token... requesting vm without a token anyway...' end end - Ssh.ssh(verbose, self, host_os, token_value) + Ssh.ssh(verbose, self, host_os, token_value, ondemand) end def query(verbose, hostname) diff --git a/lib/vmfloaty/ssh.rb b/lib/vmfloaty/ssh.rb index f100b8b..582adea 100644 --- a/lib/vmfloaty/ssh.rb +++ b/lib/vmfloaty/ssh.rb @@ -14,27 +14,45 @@ class Ssh nil end - def self.command_string(verbose, service, host_os, use_token) + def self.command_string(verbose, service, host_os, use_token, ondemand = nil) ssh_path = which('ssh') raise 'Could not determine path to ssh' unless ssh_path - - os_types = {} + os_types = Utils.generate_os_hash([host_os]) os_types[host_os] = 1 - response = service.retrieve(verbose, os_types, use_token) + response = service.retrieve(verbose, os_types, use_token, ondemand) raise "Could not get vm from #{service.type}:\n #{response}" unless response['ok'] user = /win/.match?(host_os) ? 'Administrator' : 'root' - hostname = response[host_os]['hostname'] - hostname = response[host_os]['hostname'][0] if response[host_os]['hostname'].is_a?(Array) - hostname = "#{hostname}.#{response['domain']}" unless hostname.end_with?('puppetlabs.net') + if ondemand + requestid = response['request_id'] + service.wait_for_request(verbose, requestid) + hosts = service.check_ondemandvm(verbose, requestid, service.url) + if hosts['domain'].nil? + hostname = hosts[host_os]['hostname'] + hostname = hosts[host_os]['hostname'][0] if hosts[host_os]['hostname'].is_a?(Array) + else + # Provides backwards compatibility with VMPooler API v1 + hostname = "#{hosts[host_os]['hostname']}.#{hosts['domain']}" + hostname = "#{hosts[host_os]['hostname'][0]}.#{hosts['domain']}" if hosts[host_os]['hostname'].is_a?(Array) + end + else + if response['domain'].nil? + hostname = response[host_os]['hostname'] + hostname = response[host_os]['hostname'][0] if response[host_os]['hostname'].is_a?(Array) + else + # Provides backwards compatibility with VMPooler API v1 + hostname = "#{response[host_os]['hostname']}.#{response['domain']}" + hostname = "#{response[host_os]['hostname'][0]}.#{response['domain']}" if response[host_os]['hostname'].is_a?(Array) + end + end "#{ssh_path} #{user}@#{hostname}" end - def self.ssh(verbose, service, host_os, use_token) - cmd = command_string(verbose, service, host_os, use_token) + def self.ssh(verbose, service, host_os, use_token, ondemand) + cmd = command_string(verbose, service, host_os, use_token, ondemand) # TODO: Should this respect more ssh settings? Can it be configured # by users ssh config and does this respect those settings? Kernel.exec(cmd) diff --git a/lib/vmfloaty/utils.rb b/lib/vmfloaty/utils.rb index a24d7c5..b393acf 100644 --- a/lib/vmfloaty/utils.rb +++ b/lib/vmfloaty/utils.rb @@ -9,7 +9,7 @@ class Utils # TODO: Takes the json response body from an HTTP GET # request and "pretty prints" it def self.standardize_hostnames(response_body) - # vmpooler response body example when `floaty get` arguments are `ubuntu-1610-x86_64=2 centos-7-x86_64`: + # vmpooler api v1 response body example when `floaty get` arguments are `ubuntu-1610-x86_64=2 centos-7-x86_64`: # { # "ok": true, # "domain": "delivery.mycompany.net", @@ -21,6 +21,17 @@ class Utils # } # } + # vmpooler api v2 response body example when `floaty get` arguments are `ubuntu-1610-x86_64=2 centos-7-x86_64`: + # { + # "ok": true, + # "ubuntu-1610-x86_64": { + # "hostname": ["gdoy8q3nckuob0i.pooler.example.com", "ctnktsd0u11p9tm.pooler.example.com"] + # }, + # "centos-7-x86_64": { + # "hostname": "dlgietfmgeegry2.pooler.example.com" + # } + # } + # nonstandard pooler response body example when `floaty get` arguments are `solaris-11-sparc=2 ubuntu-16.04-power8`: # { # "ok": true, @@ -98,7 +109,11 @@ class Utils puts abs_hostnames.join("\n") when 'Pooler' - puts "#{hostname}.#{host_data['domain']}" + if host_data['domain'].nil? + puts hostname + else + puts "#{hostname}.#{host_data['domain']}" + end when 'NonstandardPooler' puts host_data['fqdn'] else @@ -135,7 +150,14 @@ class Utils tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" } unless host_data['tags'].nil? duration = "#{host_data['running']}/#{host_data['lifetime']} hours" metadata = [host_data['state'], host_data['template'], duration, *tag_pairs] - message = "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent) + # For backwards compatibility with vmpooler api v1 + message = + if host_data['domain'] + "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent) + else + "- #{host_data['fqdn']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent) + end + if host_data['state'] && host_data['state'] == 'destroyed' output_target.puts "- DESTROYED #{hostname}.#{host_data['domain']}".gsub(/^/, ' ' * indent) else @@ -197,9 +219,9 @@ class Utils pending = pool['pending'] missing = max - ready - pending char = 'o' - puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}" + puts "#{name.ljust(width)} #{(char * ready)}#{(char * pending)}#{(char * missing)}" rescue StandardError => e - FloatyLogger.error "#{name.ljust(width)} #{e.red}" + FloatyLogger.error "#{name.ljust(width)} #{e}" end puts message when 'NonstandardPooler' @@ -214,13 +236,13 @@ class Utils pending = pool['pending'] || 0 # not available for nspooler missing = max - ready - pending char = 'o' - puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}" + puts "#{name.ljust(width)} #{(char * ready)}#{(char * pending)}#{(char * missing)}" rescue StandardError => e - FloatyLogger.error "#{name.ljust(width)} #{e.red}" + FloatyLogger.error "#{name.ljust(width)} #{e}" end when 'ABS' FloatyLogger.error 'ABS Not OK' unless status_response - puts 'ABS is OK'.green if status_response + puts 'ABS is OK' if status_response else raise "Invalid service type #{service.type}" end diff --git a/lib/vmfloaty/version.rb b/lib/vmfloaty/version.rb index 119c4c5..aab63a3 100644 --- a/lib/vmfloaty/version.rb +++ b/lib/vmfloaty/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class Vmfloaty - VERSION = '1.6.0' + VERSION = '1.8.1' end diff --git a/release-prep b/release-prep new file mode 100755 index 0000000..82ee104 --- /dev/null +++ b/release-prep @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# bundle install +docker run -t --rm \ + -v $(pwd):/app \ + $(grep ^FROM ./Dockerfile |cut -d ' ' -f2) \ + /bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends build-essential make openssh-client && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"' + +# Update Changelog +docker run -t --rm -e CHANGELOG_GITHUB_TOKEN -v $(pwd):/usr/local/src/your-app \ + githubchangeloggenerator/github-changelog-generator:1.16.2 \ + github_changelog_generator --future-release $(grep VERSION lib/vmfloaty/version.rb |rev |cut -d "'" -f2 |rev) diff --git a/spec/vmfloaty/ssh_spec.rb b/spec/vmfloaty/ssh_spec.rb index c16bb30..ec5fd4e 100644 --- a/spec/vmfloaty/ssh_spec.rb +++ b/spec/vmfloaty/ssh_spec.rb @@ -4,24 +4,35 @@ require 'spec_helper' require 'vmfloaty/ssh' class ServiceStub - def retrieve(_verbose, os_types, _use_token) + def retrieve(_verbose, os_types, _use_token, ondemand) if os_types.keys[0] == 'abs_host_string' return { os_types.keys[0] => { 'hostname' => ['abs-hostname.delivery.puppetlabs.net'] }, 'ok' => true } - end - { - os_types.keys[0] => { 'hostname' => 'vmpooler-hostname' }, - 'domain' => 'delivery.puppetlabs.net', - 'ok' => true - } + elsif os_types.keys[0] == 'vmpooler_api_v2_host_string' + return { + os_types.keys[0] => { 'hostname' => ['vmpooler-v2-hostname.delivery.puppetlabs.net'] }, + 'ok' => true + } + + else + return { + os_types.keys[0] => { 'hostname' => 'vmpooler-v1-hostname' }, + 'domain' => 'delivery.puppetlabs.net', + 'ok' => true + } + end end def type return 'abs' if os_types == 'abs_host_string' - return 'vmpooler' if os_types == 'vmpooler_host_string' + return 'vmpooler' if os_types == 'vmpooler_api_v1_host_string' || os_types == 'vmpooler_api_v2_host_string' + end + + def wait_for_request(verbose, requestid) + return true end end @@ -29,21 +40,73 @@ describe Ssh do before :each do end - it 'gets a hostname string for abs' do - verbose = false - service = ServiceStub.new - host_os = 'abs_host_string' - use_token = false - cmd = Ssh.command_string(verbose, service, host_os, use_token) - expect(cmd).to match(/ssh root@abs-hostname.delivery.puppetlabs.net/) + context "for pooled requests" do + it 'gets a hostname string for abs' do + verbose = false + service = ServiceStub.new + host_os = 'abs_host_string' + use_token = false + cmd = Ssh.command_string(verbose, service, host_os, use_token) + expect(cmd).to match(/ssh root@abs-hostname.delivery.puppetlabs.net/) + end + + it 'gets a hostname string for vmpooler api v1' do + verbose = true + service = ServiceStub.new + host_os = 'vmpooler_api_v1_host_string' + use_token = false + cmd = Ssh.command_string(verbose, service, host_os, use_token) + expect(cmd).to match(/ssh root@vmpooler-v1-hostname.delivery.puppetlabs.net/) + end + + it 'gets a hostname string for vmpooler api v2' do + verbose = false + service = ServiceStub.new + host_os = 'vmpooler_api_v2_host_string' + use_token = false + cmd = Ssh.command_string(verbose, service, host_os, use_token) + expect(cmd).to match(/ssh root@vmpooler-v2-hostname.delivery.puppetlabs.net/) + end end - it 'gets a hostname string for vmpooler' do - verbose = false - service = ServiceStub.new - host_os = 'vmpooler_host_string' - use_token = false - cmd = Ssh.command_string(verbose, service, host_os, use_token) - expect(cmd).to match(/ssh root@vmpooler-hostname.delivery.puppetlabs.net/) + context "for ondemand requests" do + let(:service) { ServiceStub.new } + let(:url) { 'http://pooler.example.com' } + + it 'gets a hostname string for abs' do + verbose = false + host_os = 'abs_host_string' + use_token = false + ondemand = true + response = {'abs_host_string' => { 'hostname' => ['abs-hostname.delivery.puppetlabs.net']}} + allow(service).to receive(:url) + allow(service).to receive(:check_ondemandvm).and_return(response) + cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand) + expect(cmd).to match(/ssh root@abs-hostname.delivery.puppetlabs.net/) + end + + it 'gets a hostname string for abs' do + verbose = false + host_os = 'vmpooler_api_v1_host_string' + use_token = false + ondemand = true + response = {'vmpooler_api_v1_host_string' => { 'hostname' => ['vmpooler_api_v1_host_string.delivery.puppetlabs.net']}} + allow(service).to receive(:url) + allow(service).to receive(:check_ondemandvm).and_return(response) + cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand) + expect(cmd).to match(/ssh root@vmpooler_api_v1_host_string.delivery.puppetlabs.net/) + end + + it 'gets a hostname string for abs' do + verbose = false + host_os = 'vmpooler_api_v2_host_string' + use_token = false + ondemand = true + response = {'vmpooler_api_v2_host_string' => { 'hostname' => ['vmpooler_api_v2_host_string.delivery.puppetlabs.net']}} + allow(service).to receive(:url) + allow(service).to receive(:check_ondemandvm).and_return(response) + cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand) + expect(cmd).to match(/ssh root@vmpooler_api_v2_host_string.delivery.puppetlabs.net/) + end end end diff --git a/spec/vmfloaty/utils_spec.rb b/spec/vmfloaty/utils_spec.rb index a567b0c..37d2537 100644 --- a/spec/vmfloaty/utils_spec.rb +++ b/spec/vmfloaty/utils_spec.rb @@ -13,7 +13,7 @@ end describe Utils do describe '#standardize_hostnames' do before :each do - @vmpooler_response_body = '{ + @vmpooler_api_v1_response_body = '{ "ok": true, "domain": "delivery.mycompany.net", "ubuntu-1610-x86_64": { @@ -23,6 +23,15 @@ describe Utils do "hostname": "dlgietfmgeegry2" } }' + @vmpooler_api_v2_response_body = '{ + "ok": true, + "ubuntu-1610-x86_64": { + "hostname": ["gdoy8q3nckuob0i.delivery.mycompany.net", "ctnktsd0u11p9tm.delivery.mycompany.net"] + }, + "centos-7-x86_64": { + "hostname": "dlgietfmgeegry2.delivery.mycompany.net" + } + }' @nonstandard_response_body = '{ "ok": true, "solaris-10-sparc": { @@ -34,8 +43,15 @@ describe Utils do }' end - it 'formats a result from vmpooler into a hash of os to hostnames' do - result = Utils.standardize_hostnames(JSON.parse(@vmpooler_response_body)) + it 'formats a result from vmpooler v1 api into a hash of os to hostnames' do + result = Utils.standardize_hostnames(JSON.parse(@vmpooler_api_v1_response_body)) + expect(result).to eq('centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'], + 'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net', + 'ctnktsd0u11p9tm.delivery.mycompany.net']) + end + + it 'formats a result from vmpooler v2 api into a hash of os to hostnames' do + result = Utils.standardize_hostnames(JSON.parse(@vmpooler_api_v2_response_body)) expect(result).to eq('centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'], 'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net', 'ctnktsd0u11p9tm.delivery.mycompany.net']) @@ -264,7 +280,73 @@ describe Utils do subject { Utils.pretty_print_hosts(verbose, service, hostname, print_to_stderr) } - describe 'with vmpooler service' do + describe 'with vmpooler api v2 service' do + let(:service) { Service.new(MockOptions.new, 'url' => url) } + + let(:hostname) { 'mcpy42eqjxli9g2' } + let(:fqdn) { [hostname, 'delivery.puppetlabs.net'].join('.') } + + let(:response_body) do + { + hostname => { + 'template' => 'ubuntu-1604-x86_64', + 'lifetime' => 12, + 'running' => 9.66, + 'state' => 'running', + 'ip' => '127.0.0.1', + 'fqdn' => fqdn + } + } + end + + let(:default_output) { "- #{fqdn} (running, ubuntu-1604-x86_64, 9.66/12 hours)" } + + it 'prints output with host fqdn, template and duration info' do + expect($stdout).to receive(:puts).with(default_output) + + subject + end + + context 'when tags are supplied' do + let(:hostname) { 'aiydvzpg23r415q' } + let(:response_body) do + { + hostname => { + 'template' => 'redhat-7-x86_64', + 'lifetime' => 48, + 'running' => 7.67, + 'state' => 'running', + 'tags' => { + 'user' => 'bob', + 'role' => 'agent' + }, + 'ip' => '127.0.0.1', + 'fqdn' => fqdn + } + } + end + + it 'prints output with host fqdn, template, duration info, and tags' do + output = "- #{fqdn} (running, redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)" + + expect($stdout).to receive(:puts).with(output) + + subject + end + end + + context 'when print_to_stderr option is true' do + let(:print_to_stderr) { true } + + it 'outputs to stderr instead of stdout' do + expect($stderr).to receive(:puts).with(default_output) + + subject + end + end + end + + describe 'with vmpooler api v1 service' do let(:service) { Service.new(MockOptions.new, 'url' => url) } let(:hostname) { 'mcpy42eqjxli9g2' } diff --git a/vmfloaty.gemspec b/vmfloaty.gemspec index 5b15eff..184247b 100644 --- a/vmfloaty.gemspec +++ b/vmfloaty.gemspec @@ -10,10 +10,7 @@ Gem::Specification.new do |s| 'Brian Cain', 'Puppet' ] - s.email = [ - 'brianccain@gmail.com', - 'dio-gems@puppet.com' - ] + s.email = 'info@puppet.com' s.license = 'Apache-2.0' s.homepage = 'https://github.com/puppetlabs/vmfloaty' s.description = 'A helper tool for vmpooler to help you stay afloat'