-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storage): add boot to config model
- Loading branch information
1 parent
5cf0904
commit 9d8129f
Showing
10 changed files
with
395 additions
and
7 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
60 changes: 60 additions & 0 deletions
60
service/lib/agama/storage/config_conversions/from_model_conversions/boot.rb
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,60 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) [2024] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "agama/storage/config_conversions/from_model_conversions/base" | ||
require "agama/storage/config_conversions/from_model_conversions/boot_device" | ||
require "agama/storage/configs/boot" | ||
|
||
module Agama | ||
module Storage | ||
module ConfigConversions | ||
module FromModelConversions | ||
# Boot conversion from model according to the JSON schema. | ||
class Boot < Base | ||
private | ||
|
||
# @see Base | ||
# @return [Configs::Boot] | ||
def default_config | ||
Configs::Boot.new | ||
end | ||
|
||
# @see Base#conversions | ||
# @return [Hash] | ||
def conversions | ||
{ | ||
configure: model_json[:configure], | ||
device: convert_device | ||
} | ||
end | ||
|
||
# @return [Configs::BootDevice, nil] | ||
def convert_device | ||
boot_device_model = model_json[:device] | ||
return if boot_device_model.nil? | ||
|
||
FromModelConversions::BootDevice.new(boot_device_model).convert | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
51 changes: 51 additions & 0 deletions
51
service/lib/agama/storage/config_conversions/from_model_conversions/boot_device.rb
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,51 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) [2024] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "agama/storage/config_conversions/from_model_conversions/base" | ||
require "agama/storage/configs/boot_device" | ||
|
||
module Agama | ||
module Storage | ||
module ConfigConversions | ||
module FromModelConversions | ||
# Boot device conversion from model according to the JSON schema. | ||
class BootDevice < Base | ||
private | ||
|
||
# @see Base | ||
# @return [Configs::Boot] | ||
def default_config | ||
Configs::BootDevice.new | ||
end | ||
|
||
# @see Base#conversions | ||
# @return [Hash] | ||
def conversions | ||
{ | ||
default: model_json[:default], | ||
device_alias: model_json[:value] | ||
} | ||
end | ||
end | ||
end | ||
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
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
57 changes: 57 additions & 0 deletions
57
service/lib/agama/storage/config_conversions/to_model_conversions/boot.rb
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,57 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) [2024] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "agama/storage/config_conversions/to_model_conversions/base" | ||
require "agama/storage/config_conversions/to_model_conversions/boot_device" | ||
|
||
module Agama | ||
module Storage | ||
module ConfigConversions | ||
module ToModelConversions | ||
# Boot config conversion to model according to the JSON schema. | ||
class Boot < Base | ||
# @param config [Storage::Boot] | ||
def initialize(config) | ||
super() | ||
@config = config | ||
end | ||
|
||
private | ||
|
||
# @see Base#conversions | ||
def conversions | ||
{ | ||
configure: config.configure?, | ||
device: convert_device | ||
} | ||
end | ||
|
||
# @return [Hash] | ||
def convert_device | ||
return unless config.configure? | ||
|
||
ToModelConversions::BootDevice.new(config.device).convert | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
49 changes: 49 additions & 0 deletions
49
service/lib/agama/storage/config_conversions/to_model_conversions/boot_device.rb
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,49 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) [2024] SUSE LLC | ||
# | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it | ||
# under the terms of version 2 of the GNU General Public License as published | ||
# by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
# more details. | ||
# | ||
# You should have received a copy of the GNU General Public License along | ||
# with this program; if not, contact SUSE LLC. | ||
# | ||
# To contact SUSE LLC about this file by physical or electronic mail, you may | ||
# find current contact information at www.suse.com. | ||
|
||
require "agama/storage/config_conversions/to_model_conversions/base" | ||
|
||
module Agama | ||
module Storage | ||
module ConfigConversions | ||
module ToModelConversions | ||
# Boot device config conversion to model according to the JSON schema. | ||
class BootDevice < Base | ||
# @param config [Storage::BootDevice] | ||
def initialize(config) | ||
super() | ||
@config = config | ||
end | ||
|
||
private | ||
|
||
# @see Base#conversions | ||
def conversions | ||
{ | ||
default: config.default?, | ||
value: config.device_alias | ||
} | ||
end | ||
end | ||
end | ||
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
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
Oops, something went wrong.