Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Sep 5, 2024
1 parent 8b24968 commit e2aa713
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 22 deletions.
15 changes: 4 additions & 11 deletions service/lib/agama/storage/configs/drive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
# find current contact information at www.suse.com.

require "agama/storage/configs/search"
require "agama/storage/configs/with_alias"
require "agama/storage/configs/with_search"

module Agama
module Storage
module Configs
# Section of the configuration representing a device that is expected to exist in the target
# system and that can be used as a regular disk.
class Drive
# @return [Search]
attr_accessor :search
include WithAlias
include WithSearch

# @return [Encryption, nil]
attr_accessor :encryption
Expand All @@ -49,15 +51,6 @@ def initialize
@search = Search.new
end

# Assigned device according to the search.
#
# @see Y2Storage::Proposal::AgamaSearcher
#
# @return [Y2Storage::Device, nil]
def found_device
search.device
end

# Whether the drive definition contains partition definitions
#
# @return [Boolean]
Expand Down
15 changes: 4 additions & 11 deletions service/lib/agama/storage/configs/partition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
# find current contact information at www.suse.com.

require "agama/storage/configs/size"
require "agama/storage/configs/with_search"
require "agama/storage/configs/with_alias"

module Agama
module Storage
module Configs
# Section of the configuration representing a partition
class Partition
# @return [Search, nil]
attr_accessor :search
include WithAlias
include WithSearch

# @return [Boolean]
attr_accessor :delete
Expand All @@ -54,15 +56,6 @@ def initialize
@delete = false
@delete_if_needed = false
end

# Assigned device according to the search.
#
# @see Y2Storage::Proposal::AgamaSearcher
#
# @return [Y2Storage::Device, nil]
def found_device
search&.device
end
end
end
end
Expand Down
39 changes: 39 additions & 0 deletions service/lib/agama/storage/configs/with_alias.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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.

module Agama
module Storage
module Configs
# Mixin for configs with alias.
module WithAlias
# @return [String, nil]
attr_accessor :alias

# Whether the config has the given alias.
#
# @return [Boolean]
def alias?(value)
self.alias == value
end
end
end
end
end
41 changes: 41 additions & 0 deletions service/lib/agama/storage/configs/with_search.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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.

module Agama
module Storage
module Configs
# Mixin for configs with search.
module WithSearch
# @return [Search, nil]
attr_accessor :search

# Assigned device according to the search.
#
# @see Y2Storage::Proposal::AgamaSearcher
#
# @return [Y2Storage::Device, nil]
def found_device
search&.device
end
end
end
end
end

0 comments on commit e2aa713

Please sign in to comment.