Add -n and -m to recipes/upgrade #291

Merged
cas merged 5 commits from cr_upgrade_noninnteractive into main 2023-04-27 16:46:01 +00:00
Member

Support the no-input flag and the machine-readable-output flag in the recipe upgrade command.

Support the no-input flag and the machine-readable-output flag in the `recipe upgrade` command.
cas added 4 commits 2023-04-13 16:35:25 +00:00
recipe/upgrade: Add non-interactive mode.
All checks were successful
continuous-integration/drone/push Build is passing
2a82936caa
Add support for -n which just outputs the list of compatible tags for each image.
recipe/upgrade: Refactor upgradability list to make output easier
All checks were successful
continuous-integration/drone/push Build is passing
fd7efa7daf
For future, we can print the struct as JSON.
Add machine output for recipe/upgrade
All checks were successful
continuous-integration/drone/push Build is passing
2fb490c8b3
- Normal faff related to calling external libraries with structs thnx go
- Ouputs json now
Make -m imply -n in recipe/upgrade
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
196905526a
3wordchant requested review from 3wordchant 2023-04-13 16:39:29 +00:00
3wordchant approved these changes 2023-04-13 16:40:33 +00:00
decentral1se reviewed 2023-04-14 11:44:31 +00:00
decentral1se left a comment
Owner

Nice one, thanks! Some minor comments.

Nice one, thanks! Some minor comments.
@ -27,6 +28,13 @@ type imgPin struct {
version tagcmp.Tag
}
type anUpgrade struct {
Owner

Missing doc string? E.g.

// anUpgrade represents ...
Missing doc string? E.g. ```go // anUpgrade represents ... ```
cas marked this conversation as resolved
@ -249,0 +261,4 @@
Service: service.Name,
Image: image,
Tag: tag.String(),
UpgradeTags: make([]string, len(compatibleStrings[1:])),
Owner

Maybe sticking len(compatibleStrings[1:]) in a named variable will be more readable since it is used twice. The 1:... is sure to not stack trace since there is always 1 entry in it? We could comment that out also.

Maybe sticking `len(compatibleStrings[1:])` in a named variable will be more readable since it is used twice. The `1:...` is sure to not stack trace since there is always 1 entry in it? We could comment that out also.
Author
Member

The len() is less useful than the slice, I've made that change.

The `len()` is less useful than the slice, I've made that change.
cas marked this conversation as resolved
@ -252,0 +278,4 @@
} else {
prompt := &survey.Select{
Message: msg,
Help: "enter / return to confirm, choose 'skip' to not upgrade this tag, vim mode is enabled",
Owner

Should we make this a const somewhere? Think it's getting re-used in several places now.

Should we make this a `const` somewhere? Think it's getting re-used in several places now.
Author
Member

We should do but I don't want to muddle this in with the change.

We should do but I don't want to muddle this in with the change.
cas marked this conversation as resolved
@ -268,0 +308,4 @@
jsonstring, err := json.Marshal(upgradeList)
if err != nil {
logrus.Fatal(err)
} else {
Owner

This is a dangling else, it can be dropped?

This is a dangling else, it can be dropped?
Author
Member

yep! done

yep! done
cas marked this conversation as resolved
@ -268,0 +312,4 @@
fmt.Println(string(jsonstring))
}
} else {
Owner

For readability, this else could be also dropped if you return earlier in the above block. Up to you.

For readability, this `else` could be also dropped if you `return` earlier in the above block. Up to you.
Author
Member

Yep, does looks cleaner. Done.

Yep, does looks cleaner. Done.
cas marked this conversation as resolved
cas added 1 commit 2023-04-27 16:44:08 +00:00
Add some minor tweaks to machine readable pathway in recipe upgrade
Some checks failed
continuous-integration/drone/pr Build is failing
continuous-integration/drone/push Build is passing
7c55325c13
cas merged commit c5d9d88359 into main 2023-04-27 16:45:59 +00:00
cas deleted branch cr_upgrade_noninnteractive 2023-04-27 16:46:20 +00:00
Sign in to join this conversation.
No description provided.