-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New strategy for SpaceMaker #1337
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7579aba
Introduce SpaceMakerActions
ancorgs 7483834
Extract SpaceMaker-related settings to a separate class
ancorgs 8a1beab
SpaceMakerActions::BiggerResizeStrategy
ancorgs af0193f
Update copyright date of recently modified files
ancorgs 0a60196
Version and changelog
ancorgs 802b15d
Remove pointless code
ancorgs File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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,100 @@ | ||
# Copyright (c) [2023] 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 "yast" | ||
require "y2storage/equal_by_instance_variables" | ||
|
||
module Y2Storage | ||
# Class to encapsulate all the GuidedProposal settings related to the process of making space | ||
# to allocate the new operating system | ||
class ProposalSpaceSettings | ||
include EqualByInstanceVariables | ||
|
||
# @see .delete_modes | ||
# TODO: enum? | ||
DELETE_MODES = [:none, :all, :ondemand].freeze | ||
private_constant :DELETE_MODES | ||
|
||
# @return [Array<String>] list of possible delete strategies | ||
def self.delete_modes | ||
DELETE_MODES | ||
end | ||
|
||
# @return [Boolean] whether to resize Windows systems if needed | ||
attr_accessor :resize_windows | ||
|
||
# What to do regarding removal of existing partitions hosting a Windows system. | ||
# | ||
# Options: | ||
# | ||
# * :none Never delete a Windows partition. | ||
# * :ondemand Delete Windows partitions as needed by the proposal. | ||
# * :all Delete all Windows partitions, even if not needed. | ||
# | ||
# @raise ArgumentError if any other value is assigned | ||
# | ||
# @return [Symbol] | ||
attr_accessor :windows_delete_mode | ||
|
||
# @return [Symbol] what to do regarding removal of existing Linux | ||
# partitions. See {DiskAnalyzer} for the definition of "Linux partitions". | ||
# @see #windows_delete_mode for the possible values and exceptions | ||
attr_accessor :linux_delete_mode | ||
|
||
# @return [Symbol] what to do regarding removal of existing partitions that | ||
# don't fit in #windows_delete_mode or #linux_delete_mode. | ||
# @see #windows_delete_mode for the possible values and exceptions | ||
attr_accessor :other_delete_mode | ||
|
||
# Whether the delete mode of the partitions and the resize option for windows can be | ||
# configured. When this option is set to `false`, the {#windows_delete_mode}, {#linux_delete_mode}, | ||
# {#other_delete_mode} and {#resize_windows} options cannot be modified by the user. | ||
# | ||
# @return [Boolean] | ||
attr_accessor :delete_resize_configurable | ||
|
||
# Whether the settings disable deletion of a given type of partitions | ||
# | ||
# @see #windows_delete_mode | ||
# @see #linux_delete_mode | ||
# @see #other_delete_mode | ||
# | ||
# @param type [#to_s] :linux, :windows or :other | ||
# @return [Boolean] | ||
def delete_forbidden(type) | ||
send(:"#{type}_delete_mode") == :none | ||
end | ||
|
||
alias_method :delete_forbidden?, :delete_forbidden | ||
|
||
# Whether the settings enforce deletion of a given type of partitions | ||
# | ||
# @see #windows_delete_mode | ||
# @see #linux_delete_mode | ||
# @see #other_delete_mode | ||
# | ||
# @param type [#to_s] :linux, :windows or :other | ||
# @return [Boolean] | ||
def delete_forced(type) | ||
send(:"#{type}_delete_mode") == :all | ||
end | ||
|
||
alias_method :delete_forced?, :delete_forced | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just as note, we have the
Equatable
mixin for custom comparison: https://github.com/yast/yast-yast2/blob/master/library/general/src/lib/yast2/equatable.rbThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well,
EqualByInstanceVariables
is used forProposalSettings
. And this class is basically a subset of those settings extracted to a separate object for clarity. So it makes sense to be consistent with the container class and use the same mechanism.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, only mentioning to promote it for other cases :)