Skip to content
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

feat: update plugin to check for a minimum required version #121

Merged
merged 20 commits into from
Jan 8, 2024

Conversation

zucchinidev
Copy link
Contributor

Checklist:

@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/186780945

The labels on this github issue will be updated when the story is started.

internal/config/config.go Outdated Show resolved Hide resolved
internal/config/config_test.go Outdated Show resolved Hide resolved
internal/config/config_test.go Outdated Show resolved Hide resolved
internal/config/config_test.go Outdated Show resolved Hide resolved
internal/config/flags.go Outdated Show resolved Hide resolved
if err != nil {
return err
}
return performCheckUpToDate(instances, log)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't actually check that anything is up to date, so change to a more meaningful name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blgm Thank you very much for reviewing the code.

After analyzing the alternatives, I preferred removing the method instead of changing the name of a dummy method. It turned out that the code is now more readable, but I had to repeat the dryRun method call in the switch cases case cfg.MinVersionRequired != "" and cfg.FailIfNotUpToDate. In my opinion, this will help us in understanding the logic and in the next refactor, where we could improve the dryRun functionality. The logging strategy seems inconsistent. For example, in performDryRun, it logs upgrade failures for each service instance, which might be misleading as it's just a dry run.

Due to the fact that we have already documented the `check-up-to-date` flag,
we would prefer to maintain the name to avoid changes in our documentation
and to prevent any potential impact on customers from our change.

[#186528305](https://www.pivotaltracker.com/story/show/186528305)
By centralizing the validation, we avoid incorrect usages of the method
and repetition of the check if the version is an empty value. We also
return a string which allows us to assign the value directly to the
configuration property.

[#186528305](https://www.pivotaltracker.com/story/show/186528305)
The method `performCheckUpToDate` is intended to execute an
action when there are instances not up-to-date. It turned out
that the method was a dummy method with minimal functionality.
The name of the method was causing problems in understanding
the logic. We prefer to remove it now and perform a refactor
later to improve the modularity of the code.

[#186528305](https://www.pivotaltracker.com/story/show/186528305)
@zucchinidev zucchinidev requested a review from blgm January 5, 2024 13:12
@@ -27,42 +28,34 @@ func ParseConfig(conn CLIConnection, args []string) (Config, error) {
flagSet.IntVar(&cfg.ParallelUpgrades, parallelFlag, parallelDefault, parallelDescription)
flagSet.BoolVar(&cfg.HTTPLogging, httpLoggingFlag, httpLoggingDefault, httpLoggingDescription)
flagSet.BoolVar(&cfg.DryRun, dryRunFlag, dryRunDefault, dryRunDescription)
flagSet.BoolVar(&cfg.CheckUpToDate, checkUpToDateFlag, checkUpToDateDefault, checkUpToDateDescription)
flagSet.BoolVar(&cfg.CheckUpToDate, checkUpToDateFlag, checkUpToDateDefault, checkToDateDescription)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: checkToDateDescription -> checkUpToDateDescription

@zucchinidev zucchinidev merged commit 049c011 into main Jan 8, 2024
6 checks passed
@zucchinidev zucchinidev changed the title feat: update plugin to check for a minimum version required feat: update plugin to check for a minimum required version Jan 8, 2024
@zucchinidev zucchinidev deleted the check_instances_up_to_date_186528305 branch January 8, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

3 participants