vagrant-k3s 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d2a85776f2cf4d2367a228349cdeafa4215bb87cdeb96cbebb06cd3a0968c8f
4
- data.tar.gz: 0406a611774102a75a197c9efb63dbeb857ac15956b1f6fdfd16d683097af03e
3
+ metadata.gz: ae9d2997564c4d9a4a5806b118f26d76ebcc811056a9ca0b20409a00350b94ca
4
+ data.tar.gz: 859e3267612b2d433574d92cfc3402f1ff5aade8ff2f8bed43f04a05238b1013
5
5
  SHA512:
6
- metadata.gz: 67e98632bb1ad253d3445dedc0c03dc922369080f1e0f0fcfcb91852c673b34f1312e06c22fee28fb44385c56c71c83d1edfefdda2043a35cfd97a81077cda07
7
- data.tar.gz: 1546227d3f5062961579e48cab178fc139e2b670cfa9b53f437b5f52e590c0187257a091628c39e9c3bb5402444dded190ef2e0f3da7618ceba3d8003eb2570b
6
+ metadata.gz: c94413c475822b32003b9947fee8bd4ca6ee952866ab947745c6786dfec06a173143d995c2142140116b1d0705900cfa3760724d6956c9c4f8d48b50ec90b128
7
+ data.tar.gz: ee403d1d28344f9c840cee4e820da0705f4937436522d6822e4d3f3529b2cd56a3c04c7556dc60dd46115de408a2b75fab875b1db3524c3b9bf95abcf665ba96
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vagrant-k3s (0.4.0)
4
+ vagrant-k3s (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -75,6 +75,40 @@ Vagrant.configure("2") do |config|
75
75
  # default => `/etc/rancher/k3s/config.yaml`
76
76
  k3s.config_path = '/etc/rancher/k3s/config.yaml'
77
77
 
78
+ # registries: private registry configuration content in yaml
79
+ # see https://docs.k3s.io/installation/private-registry
80
+ # type => String || Hash
81
+ k3s.registries = {
82
+ :mirrors => {
83
+ 'docker.io' => {
84
+ :endpoint => %w[https://registry.example.com:5000]
85
+ }
86
+ }
87
+ }
88
+ # or
89
+ k3s.registries = <<~YAML
90
+ mirrors:
91
+ docker.io:
92
+ endpoint:
93
+ - https://registry.example.com:5000
94
+ configs:
95
+ registry.example.com:5000:
96
+ auth:
97
+ username: user
98
+ password: secret
99
+ YAML
100
+ # registries_mode: registries file permissions
101
+ # type => String
102
+ # default => `0600`
103
+ k3s.registries_mode = '0600' # default
104
+ k3s.registries_owner = 'root:root' # default
105
+
106
+ # registries_path: where to write the registries yaml.
107
+ # if you override this be sure to let k3s know, e.g.
108
+ # k3s.config = { 'private-registry' => '/some/other/registries.yaml' }
109
+ # default => `/etc/rancher/k3s/registries.yaml`
110
+ k3s.registries_path = '/etc/rancher/k3s/registries.yaml'
111
+
78
112
  # skip_start: install but don't start K3s
79
113
  # type => Boolean
80
114
  # default => false
@@ -12,6 +12,9 @@ module VagrantPlugins
12
12
  DEFAULT_ENV_OWNER = DEFAULT_FILE_OWNER
13
13
  DEFAULT_ENV_PATH = '/etc/rancher/k3s/install.env'
14
14
  DEFAULT_INSTALLER_URL = 'https://get.k3s.io'
15
+ DEFAULT_REGISTRIES_MODE = DEFAULT_FILE_MODE
16
+ DEFAULT_REGISTRIES_OWNER = DEFAULT_FILE_OWNER
17
+ DEFAULT_REGISTRIES_PATH = '/etc/rancher/k3s/registries.yaml'
15
18
 
16
19
  # string or array
17
20
  # @return [Array<String>]
@@ -53,6 +56,22 @@ module VagrantPlugins
53
56
  # @return [String]
54
57
  attr_accessor :installer_url
55
58
 
59
+ # string (.yaml) or hash
60
+ # @return [Hash]
61
+ attr_accessor :registries
62
+
63
+ # Defaults to `0600`
64
+ # @return [String]
65
+ attr_accessor :registries_mode
66
+
67
+ # Defaults to `root:root`
68
+ # @return [String]
69
+ attr_accessor :registries_owner
70
+
71
+ # Defaults to `/etc/rancher/k3s/registries.yaml`
72
+ # @return [String]
73
+ attr_accessor :registries_path
74
+
56
75
  # Defaults to false
57
76
  # @return [Boolean]
58
77
  attr_accessor :skip_start
@@ -112,6 +131,10 @@ module VagrantPlugins
112
131
  @env_owner = UNSET_VALUE
113
132
  @env_path = UNSET_VALUE
114
133
  @installer_url = UNSET_VALUE
134
+ @registries = UNSET_VALUE
135
+ @registries_mode = UNSET_VALUE
136
+ @registries_owner = UNSET_VALUE
137
+ @registries_path = UNSET_VALUE
115
138
  @skip_start = UNSET_VALUE
116
139
  @skip_complete = UNSET_VALUE
117
140
  end
@@ -127,6 +150,10 @@ module VagrantPlugins
127
150
  @env_owner = DEFAULT_ENV_OWNER if @env_owner == UNSET_VALUE
128
151
  @env_path = DEFAULT_ENV_PATH if @env_path == UNSET_VALUE
129
152
  @installer_url = DEFAULT_INSTALLER_URL if @installer_url == UNSET_VALUE
153
+ @registries = "" if @registries == UNSET_VALUE
154
+ @registries_mode = @registries_mode == UNSET_VALUE ? DEFAULT_REGISTRIES_MODE : @registries_mode.to_s
155
+ @registries_owner = @registries_owner == UNSET_VALUE ? DEFAULT_REGISTRIES_OWNER : @registries_owner.to_s
156
+ @registries_path = @registries_path == UNSET_VALUE ? DEFAULT_REGISTRIES_PATH : @registries_path.to_s
130
157
  @skip_start = false if @skip_start == UNSET_VALUE
131
158
  @skip_complete = false if @skip_complete == UNSET_VALUE
132
159
 
@@ -150,6 +177,10 @@ module VagrantPlugins
150
177
  errors << "K3s provisioner `env` must be an array, hash, or string."
151
178
  end
152
179
 
180
+ unless registries_valid?
181
+ errors << "K3s provisioner `registries` must be a hash or string (yaml)."
182
+ end
183
+
153
184
  { "k3s provisioner" => errors }
154
185
  end
155
186
 
@@ -173,6 +204,13 @@ module VagrantPlugins
173
204
  false
174
205
  end
175
206
 
207
+ def registries_valid?
208
+ return true unless registries
209
+ return true if registries.is_a?(String)
210
+ return true if registries.is_a?(Hash)
211
+ false
212
+ end
213
+
176
214
  def env_valid?
177
215
  return true unless env
178
216
  return true if env.is_a?(String)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'vagrant'
4
4
  require 'vagrant/errors'
5
+ require 'json'
5
6
  require 'yaml'
6
7
 
7
8
  module VagrantPlugins
@@ -36,6 +37,10 @@ module VagrantPlugins
36
37
  cfg_yaml = config.config.is_a?(String) ? config.config : config.config.transform_keys(&:to_s).to_yaml
37
38
  file_upload "k3s-config.yaml", cfg_file, cfg_yaml
38
39
 
40
+ reg_file = config.registries_path.to_s
41
+ reg_yaml = config.registries.is_a?(String) ? config.registries : JSON.parse(config.registries.to_json).to_yaml
42
+ file_upload "k3s-registries.yaml", reg_file, reg_yaml
43
+
39
44
  env_file = config.env_path.to_s
40
45
  env_text = ""
41
46
  if config.env.is_a?(String)
@@ -62,6 +67,8 @@ module VagrantPlugins
62
67
  chmod #{config.config_mode} #{config.config_path}
63
68
  chown #{config.env_owner} #{config.env_path}
64
69
  chmod #{config.env_mode} #{config.env_path}
70
+ chown #{config.registries_owner} #{config.registries_path}
71
+ chmod #{config.registries_mode} #{config.registries_path}
65
72
  set -o allexport
66
73
  source #{config.env_path}
67
74
  set +o allexport
@@ -2,6 +2,6 @@
2
2
 
3
3
  module VagrantPlugins
4
4
  module K3s
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-k3s
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Nola
8
8
  - Jacob Blain Christen
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-09-18 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Manage k3s installations on Vagrant guests.
14
14
  email:
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  - !ruby/object:Gem::Version
62
62
  version: 3.0.0
63
63
  requirements: []
64
- rubygems_version: 3.6.3
64
+ rubygems_version: 3.6.7
65
65
  specification_version: 4
66
66
  summary: Manage k3s installations on Vagrant guests.
67
67
  test_files: []