Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement puppet-metadata with various subcommands #120

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Mar 9, 2024

This implements a puppet-metadata executable which now only implements the eol command to show which operating systems in metadata are end of life.

@ekohl ekohl force-pushed the implement-commands branch from d633196 to f1b04bb Compare March 9, 2024 14:41
This implements a puppet-metadata executable which now only implements
the eol command to show which operating systems in metadata are end of
life.
@ekohl ekohl force-pushed the implement-commands branch from f1b04bb to ab4cffe Compare March 9, 2024 14:46
end

def self.commands
subclasses.to_h { |subclass| [subclass.command, subclass] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subclasses is an undefined variable:

$ bundle exec puppet-metadata
bundler: failed to load command: puppet-metadata (/home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/bin/puppet-metadata)
/home/bastelfreak/code/puppet_metadata/bin/puppet-metadata:23:in `commands': undefined local variable or method `subclasses' for BaseCommand:Class (NameError)
Did you mean?  superclass
	from /home/bastelfreak/code/puppet_metadata/bin/puppet-metadata:59:in `main'
	from /home/bastelfreak/code/puppet_metadata/bin/puppet-metadata:68:in `<top (required)>'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/bin/puppet-metadata:25:in `load'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/bin/puppet-metadata:25:in `<top (required)>'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/cli/exec.rb:58:in `load'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/cli/exec.rb:23:in `run'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/cli.rb:491:in `exec'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/cli.rb:34:in `dispatch'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/cli.rb:28:in `start'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/exe/bundle:45:in `block in <top (required)>'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /home/bastelfreak/code/puppet_metadata/.vendor/ruby/3.0.0/gems/bundler-2.4.1/exe/bundle:33:in `<top (required)>'
	from /usr/bin/bundle:25:in `load'
	from /usr/bin/bundle:25:in `<main>'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I read somewhere that subclasses was a newer Ruby feature. I guess that isn't in 3.0 yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested around and it works with Ruby 3.1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll figure out if there's a nice solution. I'd like to avoid making part of the codebase Ruby 3.1+ but the rest 2.7+.

PuppetMetadata.read(@filename)
end
rescue StandardError => e
warn "Failed to read #{filename}: #{e}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
warn "Failed to read #{filename}: #{e}"
warn "Failed to read #{@filename}: #{e}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants