Skip to content

Commit

Permalink
Merge pull request #142 from bastelfreak/setfiles
Browse files Browse the repository at this point in the history
Add script to display supported setfiles
  • Loading branch information
bastelfreak authored Jul 5, 2024
2 parents 537092b + b6f0faa commit 5c728d5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,25 @@ The metadata object has several different methods that we can call
[7] pry(main)>
```

## List supported setfiles

When running beaker on the CLI, you can specify a specific setfile. `puppet_metadata` provides `bin/setfiles` to list all setfiles:

```
$ bundle exec setfiles
Skipping EOL operating system Debian 10
Skipping EOL operating system Ubuntu 18.04
BEAKER_SETFILE="centos9-64{hostname=centos9-64-puppet8.example.com}"
BEAKER_SETFILE="centos9-64{hostname=centos9-64-puppet7.example.com}"
BEAKER_SETFILE="debian11-64{hostname=debian11-64-puppet8.example.com}"
BEAKER_SETFILE="debian11-64{hostname=debian11-64-puppet7.example.com}"
BEAKER_SETFILE="ubuntu2004-64{hostname=ubuntu2004-64-puppet8.example.com}"
BEAKER_SETFILE="ubuntu2004-64{hostname=ubuntu2004-64-puppet7.example.com}"
```

As an argument you can provide a path to a metadata.json. If none provided, it assumes that there's a metadata.json in the same directory where you run the command.
To make copy and paste easier, each setfile string is prefixed so it can directly be used as environment variable.

## Transfer Notice

This plugin was originally authored by [Ewoud Kohl van Wijngaarden](https://github.com/ekohl).
Expand Down
28 changes: 28 additions & 0 deletions bin/setfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env ruby

# frozen_string_literal: true

require 'json'
require 'puppet_metadata'

filename = ARGV[0]
filename = 'metadata.json' if filename.nil? || filename.empty?

begin
metadata = PuppetMetadata.read(filename)
rescue StandardError => e
warn "Failed to read #{filename}: #{e}"
exit 2
end

options = {
beaker_pidfile_workaround: false,
domain: 'example.com',
minimum_major_puppet_version: nil,
beaker_fact: nil,
beaker_hosts: nil,
}

metadata.github_actions(options).outputs[:puppet_beaker_test_matrix].each do |os|
puts "BEAKER_SETFILE=\"#{os[:env]['BEAKER_SETFILE']}\""
end
2 changes: 1 addition & 1 deletion puppet_metadata.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = Gem::Requirement.new('>= 2.7', '< 4')

s.executables << 'metadata2gha'
s.executables = ['metadata2gha', 'setfiles']
s.files = Dir['lib/**/*.rb']
s.extra_rdoc_files = ['README.md']
s.rdoc_options << '--main' << 'README.md'
Expand Down

0 comments on commit 5c728d5

Please sign in to comment.