New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hashipack

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hashipack

  • 0.1.9
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Hashipack

Gem Version Ruby Code Style

Hashipack is a Ruby client for Hashicorp's Packer.

It allows building images and provides live status updates about the progress, as well as the resulting artifacts.

Installation

Install the gem and add to the application's Gemfile by executing:

bundle add hashipack

If bundler is not being used to manage dependencies, install the gem by executing:

gem install hashipack

And require it in your program:

require 'hashipack'

Usage

Create a client:

client = Hashipack::Client.new

Build an image by providing the filename of the template:

template = 'myimage.pkr.hcl'
result = client.build(template)

If the template and the assets are in a different folder:

Dir.chdir('./app/templates') do
  template = 'myimage.pkr.hcl'
  result = client.build(template)
end

Subscribe to log messages and print them as they arrive:

print_message = -> (message) { puts message }
result = client.build(template, on_output: print_message)

# This would print something like
# ...
# ==> myvm.hcloud.example: Shutting down server...
# ==> myvm.hcloud.example: Creating snapshot ...
# ==> myvm.hcloud.example: This can take some time
# ...

In addition to the template, you can also provide a lambda that is called when the builder progresses. You need to define an estimated build duration in seconds so hashipack can calculate the progress.

print_message = -> (message) { puts message }
print_progress = -> (progress) { puts progress }
result = client.build(template, on_output: print_message, on_progress: print_progress, estimated_duration: 300)

The result contains an array of artifacts that were generated during the build:

print result
# => [#<hashipack::Artifact @builder_id="hcloud.builder", @id="131872234", @string="A snapshot was created: 'packer-1697561712'">]

This usually includes the following fields:

FieldValueExample
builder_idThe plugin name"hcloud.builder"
idThe platforms native artifact id"131872234", which is the ID of the image on Hetzner Cloud
stringThe completion message by Packer"A snapshot was created: 'packer-1697561712'"

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/code-fabrik/hashipack.

FAQs

Package last updated on 08 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc