Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Nov 29, 2024
1 parent 812ce5f commit 57e69a1
Show file tree
Hide file tree
Showing 7 changed files with 822 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def conversions
# @return [Configs::FilesystemType, nil]
def convert_type
filesystem_model = model_json[:filesystem]
return if !filesystem_model || filesystem_model[:default]
return if filesystem_model.nil?

FromModelConversions::FilesystemType.new(filesystem_model).convert
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def default_config
# @return [Hash]
def conversions
{
default: false,
default: filesystem_model[:default],
fs_type: convert_type,
btrfs: convert_btrfs
}
Expand All @@ -53,6 +53,8 @@ def conversions
# @return [Y2Storage::Filesystems::Type, nil]
def convert_type
value = filesystem_model[:type]
return unless value

Y2Storage::Filesystems::Type.find(value.to_sym)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def default_config
# @return [Hash]
def conversions
{
default: false,
default: size_model[:default],
min: convert_min_size,
max: convert_max_size
}
Expand All @@ -57,10 +57,10 @@ def convert_min_size
disk_size(value)
end

# @return [Y2Storage::DiskSize, nil]
# @return [Y2Storage::DiskSize]
def convert_max_size
value = size_model[:max]
return unless value
return Y2Storage::DiskSize.unlimited unless value

disk_size(value)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module FromModelConversions
module WithFilesystem
# @return [Configs::Filesystem, nil]
def convert_filesystem
return unless model_json[:mountPath] || model_json[:filesystem]

FromModelConversions::Filesystem.new(model_json).convert
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def convert_size
return Configs::Size.new_for_shrink_if_needed if model_json[:resizeIfNeeded]

size_model = model_json[:size]
return if size_model.nil? || size_model[:default]
return if size_model.nil?

FromModelConversions::Size.new(size_model).convert
end
Expand Down
4 changes: 3 additions & 1 deletion service/lib/agama/storage/configs/size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "y2storage/disk_size"

module Agama
module Storage
module Configs
Expand All @@ -30,7 +32,7 @@ class Size
def self.new_for_shrink_if_needed
new.tap do |config|
config.default = false
config.min = 0
config.min = Y2Storage::DiskSize.zero
end
end

Expand Down
Loading

0 comments on commit 57e69a1

Please sign in to comment.