-
Notifications
You must be signed in to change notification settings - Fork 32
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
Codify implicit defaults for start and stop #52
Conversation
Signed-off-by: Owen Farrell <[email protected]>
136a629
to
245bab2
Compare
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'm having a hard time reasoning about this default value - it looks like it's set to a "time of day" of 0
, which is equivalent to 12:00AM
(i.e. 0
seconds into the day). So having a "start" and "stop" of 0 implies that the only version that can possibly be returned is 12:00AM
each day.
But then the resource just returns the current time. I could see this meaning "the start/stop has elapsed, so we should emit a timestamp," but that doesn't seem to be consistent with how the resource behaves when given start
and stop
and checking outside of the configured range:
❯ echo '{"source":{"start":"3AM","stop":"4AM"}}' | docker run -i concourse/time-resource /opt/resource/check
[]
I see what you're saying, but I think that's a side effect of the fact that Without making other changes, a default start to Using your scenario above: if you were to set both the |
One clarification.... this PR makes the above statement true by changing a |
@owenfarrell I'm actually just confused as to what default behavior this intends to implement and how it would be used. Looking at the code, it configures a default start and stop of 0, which seems like it would make it unable to return anything. In my original comment I suggested that this would be because it would have to check at exactly 12AM, but now that you've pointed out that stop is exclusive, it's should be impossible to satisfy. What does this configuration mean now?: resources:
- name: ?
type: time
source: {} I can't really think of any logical assumption for this, so having defaults feels odd. It looks like the tests suggest it should return the current timestamp, but that would leave the version history entirely subject to whenever checks are run, which doesn't seem "proper" - and I'm having a hard time squaring that test with my assumption that it'd be impossible to return anything at all. Am I missing something? 🤔 |
Signed-off-by: Owen Farrell <[email protected]>
245bab2
to
4a55693
Compare
Signed-off-by: Owen Farrell <[email protected]>
4a55693
to
2a36eca
Compare
For the time being, I'm going to ignore the
As of v1.2.2,
The part that I struggle with in the current implementation is that
When I dug in to this, I came to the same realization that you did - you can't explicitly define a This PR resolves both of those inconsistencies. So while these changes don't provide a ton of benefit to end users, these changes simplify the implementation of #53. A lot. Rather than lump in a new constant with other, more complex enhancements, I thought it would be better to carve out these changes in to a separate PR to demonstrate that they are backwards compatible for all existing, valid configurations. |
Now that I've squinted my eyes and thought real hard, I think I can see that this PR is sort of 're-interpreting' the configuration in the following way:
If that's the idea, it makes sense that we can remove the validation check, but I think this warrants a change to the README to document these defaults. I wrote the darn thing and it took this entire discussion for me to see it this way. 😅 |
My instinct was to leave some validation in place - if you define a But it sounds like you're suggesting a complete removal of the |
Sorry, no, just what's already been removed by this PR. Initially I wasn't a fan of its removal; an empty configuration was never meant to be valid, and any behavior that resulted from removing the validation was purely incidental. I wanted to make sure that by removing the validation we've made its behavior intentional and something that can be clearly documented in the README. I was having a hard time figuring out what that intentional behavior would be, but I think I figured out what you're going for in #52 (comment) - is my interpretation accurate? |
Signed-off-by: Owen Farrell <[email protected]>
Okay, cool.
Yeah, I think you're spot on. Your comments about how the resource behaves with and without the I just pushed a commit to the README - the way I thought about Aside - I tweaked the verbiage around |
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.
Much clearer now! Thanks for updating the rest of the README, it's a lot clearer. Just one small question/suggestion and we're good to go.
``` | ||
start: 6:00 AM | ||
stop: 6:00 AM | ||
``` |
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 is the detail I was missing that made everything make sense. It's a little strange to specify the same value for both, since the value itself doesn't matter, but it at least intuitively makes sense with the 12AM default.
Just for the sake of argument, it seems like it could be technically valid to specify start
without stop
and vice versa.
This would mean "every 10 minutes from 7PM to the end of the day":
interval: 10m
start: 7PM
And this would mean "every 10 minutes from the start of the day until 9AM":
interval: 10m
stop: 9AM
Is that right?
Not arguing for allowing it necessarily, just checking my logic.
In any case it might be worth mentioning that when not specified they both default to the same value, 12AM, and that that's how the resource achieves the "1 version per day" behavior when nothing is specified.
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 for the sake of argument, it seems like it could be technically valid to specify start without stop and vice versa.
Yeah, that's why I got a bit confused by your comment about tossing the validation logic. You could throw out all the validation logic if you really want to.
This would mean "every 10 minutes from 7PM to the end of the day":
And this would mean "every 10 minutes from the start of the day until 9AM":
Is that right?
👍 Nailed it
Just pushed another README update to try to clarify the start
/stop
defaults. Hopefully that helps (and doesn't confuse things even more).
Signed-off-by: Owen Farrell <[email protected]>
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.
Looks good to me - merging, thanks!
No description provided.