-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,3 @@ | ||
|
||
require "yast" | ||
|
||
include Yast::I18n | ||
textdomain "caasp" | ||
|
||
# so far the Kubic dialog is the same as in CaaSP, | ||
# just with different title and defaults | ||
require "y2caasp/clients/admin_role_dialog" | ||
|
||
dialog = Y2Caasp::AdminRoleDialog.new( | ||
# TRANSLATORS: kubeadm is a tool for creating Kubernetes clusters, | ||
# do not translate that name | ||
title: _("kubeadm node configuration"), | ||
# propose random pool server in range 0..3 if not set via DHCP | ||
ntp_fallback: "#{rand(4)}.opensuse.pool.ntp.org" | ||
) | ||
dialog.run | ||
require "y2caasp/clients/kubeadm_role_dialog" | ||
Y2Caasp::KubeadmRoleDialog.new.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require "yast" | ||
|
||
# so far the Kubic dialog is the same as in CaaSP, | ||
# just with different title and defaults | ||
require "y2caasp/clients/admin_role_dialog" | ||
|
||
module Y2Caasp | ||
# This library provides a simple dialog for setting | ||
# the kubeadm role specific settings: | ||
# - the NTP server names | ||
class KubeadmRoleDialog < AdminRoleDialog | ||
def initialize | ||
textdomain "caasp" | ||
|
||
super | ||
end | ||
|
||
# | ||
# The dialog title | ||
# | ||
# @return [String ] the title | ||
# | ||
def title | ||
# TRANSLATORS: dialog title | ||
_("kubeadm node configuration") | ||
end | ||
|
||
protected | ||
|
||
def ntp_fallback | ||
# propose random pool server in range 0..3 if not set via DHCP | ||
"#{rand(4)}.opensuse.pool.ntp.org" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#! /usr/bin/env rspec | ||
|
||
require_relative "../../../test_helper.rb" | ||
require_relative "role_dialog_examples" | ||
require "cwm/rspec" | ||
|
||
require "y2caasp/clients/kubeadm_role_dialog.rb" | ||
|
||
Yast.import "CWM" | ||
Yast.import "Lan" | ||
Yast.import "Wizard" | ||
|
||
describe ::Y2Caasp::KubeadmRoleDialog do | ||
describe "#run" do | ||
let(:ntp_servers) { [] } | ||
|
||
before do | ||
allow(Yast::Wizard).to receive(:CreateDialog) | ||
allow(Yast::Wizard).to receive(:CloseDialog) | ||
allow(Yast::CWM).to receive(:show).and_return(:next) | ||
allow(Yast::Lan).to receive(:ReadWithCacheNoGUI) | ||
allow(Yast::LanItems).to receive(:dhcp_ntp_servers).and_return({}) | ||
end | ||
|
||
include_examples "CWM::Dialog" | ||
include_examples "NTP from DHCP" | ||
|
||
context "when no NTP server is detected via DHCP" do | ||
it "proposes to use a random openSUSE pool server" do | ||
expect(Y2Caasp::Widgets::NtpServer).to receive(:new) do |s| | ||
expect(s.first).to match(/\A[0-3]\.opensuse\.pool\.ntp\.org\z/) | ||
end.and_call_original | ||
subject.run | ||
end | ||
end | ||
|
||
end | ||
end |