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

Add support for k3s completion subcommand #10

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ GIT
PATH
remote: .
specs:
vagrant-k3s (0.1.8)
vagrant-k3s (0.2.0)

GEM
remote: https://rubygems.org/
Expand Down
6 changes: 6 additions & 0 deletions lib/vagrant-k3s/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class Config < Vagrant.plugin(2, :config)
# @return [Boolean]
attr_accessor :skip_start

# Defaults to false
# @return [Boolean]
attr_accessor :skip_complete

# # INSTALL_K3S_BIN_DIR
# # @return [String]
# attr_accessor :install_bin_dir
Expand Down Expand Up @@ -109,6 +113,7 @@ def initialize
@env_path = UNSET_VALUE
@installer_url = UNSET_VALUE
@skip_start = UNSET_VALUE
@skip_complete = UNSET_VALUE
end

def finalize!
Expand All @@ -123,6 +128,7 @@ def finalize!
@env_path = DEFAULT_ENV_PATH if @env_path == UNSET_VALUE
@installer_url = DEFAULT_INSTALLER_URL if @installer_url == UNSET_VALUE
@skip_start = false if @skip_start == UNSET_VALUE
@skip_complete = false if @skip_complete == UNSET_VALUE

if @args && args_valid?
@args = @args.is_a?(Array) ? @args.map { |a| a.to_s } : @args.to_s
Expand Down
12 changes: 12 additions & 0 deletions lib/vagrant-k3s/provisioner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ def provision
outputs.values.map(&:close)
end

if not config.skip_complete
outputs, handler = build_outputs
begin
@machine.ui.info 'Enabling K3s autocompletion ...'
@machine.communicate.sudo("k3s completion -i bash", error_key: :ssh_bad_exit_status_muted, &handler)
rescue Vagrant::Errors::VagrantError => e
@machine.ui.detail "#{e.extra_data[:stderr].chomp}", :color => :yellow
ensure
outputs.values.map(&:close)
end
end

begin
exe = "k3s"
@machine.ui.info 'Checking the K3s version ...'
Expand Down
2 changes: 1 addition & 1 deletion lib/vagrant-k3s/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module VagrantPlugins
module K3s
VERSION = '0.1.9'
VERSION = '0.2.0'
end
end
Loading