-
Notifications
You must be signed in to change notification settings - Fork 127
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
d/image: add most_recent filter to support multiple matches #82
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,8 @@ resource "scaleway_server" "base" { | |
|
||
* `name` - (Optional) Exact name of desired Image | ||
|
||
* `most_recent` - (Optional) Return most recent image if multiple exist | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably worth suffixing with "this cannot be used with the |
||
|
||
## Attributes Reference | ||
|
||
`id` is set to the ID of the found Image. In addition, the following attributes | ||
|
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.
If we use
most_recent
+name_filter
withUbuntu
, it will return the most recent image among all (Xenial
,Bionic
, ...).Is not it better to check before if all the names are identical ?
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.
this would not return the most recent ubuntu release, but the most recently build ubuntu release; mighy be different!
The linked issue is different tho: the names are identical, but the IDs are not. The issue of identical names with different ids can not be resolved currently.
Do you see a better option to solve this, @xunleii?
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.
(yep, sorry, I meant the most recent build and not the most recent release when I've said
it will return the most recent image
)For me, it's a great option to solve this problem, but it can sometimes behave unexpectedly; as mentioned above, if we use the
most_recent
andname_filter = "Ubuntu"
options at the same time, the resulting image will beUbuntu Xenial
orUbuntu Bionic
, or whatever, depending on the most recent build date (and doesn't return"The query returned more than one result."
as expected).This can be easily solved by checking if in
images
, all names are the same. If so, we can select the most recent, otherwise simply return"The query returned more than one result."
.What do you think about this idea, @nicolai86 ?
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.
I agree that
name_filter
withmost_recent
is most likely a bad combination, but I'm not sure it deserves special handling at this point. What do you think about disallowing the combination altogether and defering a decision until we have more data about this use case?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.
I think it's a good idea.
Thanks for this review :)
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.
Thank you for the good feedback!