Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: cli: prettify schedule when printing output#1440

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 5 commits intomainfromcj/gh-1431/cli-sched-output
May 16, 2022

Conversation

johnstcn
Copy link
Member

@johnstcnjohnstcn commentedMay 13, 2022
edited
Loading

Ref:#1431 (comment)

This PR does the following:

  • Adds methods toschedule.Schedule to show the raw cron string and timezone
  • Uses these methods to clean up output ofauto(start|stop) show orls
  • (From PR comment) DefaultsCRON_TZ=UTC if not provided

@johnstcnjohnstcn requested a review froma teamMay 13, 2022 20:53
@johnstcnjohnstcn self-assigned thisMay 13, 2022
@codecov
Copy link

codecovbot commentedMay 13, 2022
edited
Loading

Codecov Report

Merging#1440 (037b348) intomain (50ad2f8) willincrease coverage by0.01%.
The diff coverage is86.04%.

@@            Coverage Diff             @@##             main    #1440      +/-   ##==========================================+ Coverage   67.10%   67.12%   +0.01%==========================================  Files         291      291                Lines       19527    19557      +30       Branches      258      258              ==========================================+ Hits        13104    13127      +23- Misses       5073     5081       +8+ Partials     1350     1349       -1
FlagCoverage Δ
unittest-go-macos-latest54.36% <86.04%> (+0.06%)⬆️
unittest-go-postgres-65.61% <86.04%> (+0.10%)⬆️
unittest-go-ubuntu-latest56.63% <86.04%> (+0.08%)⬆️
unittest-go-windows-202252.74% <86.04%> (+0.08%)⬆️
unittest-js74.73% <ø> (ø)
Impacted FilesCoverage Δ
cli/list.go45.61% <25.00%> (-0.82%)⬇️
cli/autostart.go68.54% <100.00%> (+2.16%)⬆️
cli/autostop.go68.54% <100.00%> (+2.16%)⬆️
coderd/autobuild/schedule/schedule.go93.33% <100.00%> (+2.42%)⬆️
cli/cliui/provisionerjob.go76.42% <0.00%> (-2.15%)⬇️
provisionerd/provisionerd.go76.43% <0.00%> (-1.08%)⬇️
peer/conn.go81.08% <0.00%> (-0.74%)⬇️
agent/agent.go65.90% <0.00%> (-0.62%)⬇️
coderd/provisionerdaemons.go64.32% <0.00%> (+1.00%)⬆️
... and2 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update50ad2f8...037b348. Read thecomment docs.

@@ -49,9 +49,18 @@ func Weekly(spec string) (*Schedule, error) {
return nil, xerrors.Errorf("expected *cron.SpecSchedule but got %T", specSched)
}

tz := "UTC"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is a bit brittle. The CLI will always pass a schedule string that starts withCRON_TZ=, but if someone sets a schedule through the API, it could be any valid string that the parser will accept. And if the schedule doesn't include a timezone, it will be interpreted using the server's timezone, which could be different from UTC.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Good point. DefaultingCRON_TZ=UTC is probably the simplest way here.

Comment on lines 54 to 57
if strings.HasPrefix(raw, "CRON_TZ=") {
tz = strings.TrimPrefix(strings.Fields(raw)[0], "CRON_TZ=")
cron = strings.Join(strings.Fields(raw)[1:], " ")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It really bothers me that we have to do this using direct string manipulation instead of just looking at the parsed schedule, but it doesn't seem like this cron library provides a better way 😞

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

:'(

@missknissmisskniss added this to theV2 Beta milestoneMay 15, 2022
Copy link
Member

@kylecarbskylecarbs left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me!

@johnstcnjohnstcn merged commitb704903 intomainMay 16, 2022
@johnstcnjohnstcn deleted the cj/gh-1431/cli-sched-output branchMay 16, 2022 16:02
kylecarbs pushed a commit that referenced this pull requestJun 10, 2022
* Adds methods to schedule.Schedule to show the raw cron string and timezone* Uses these methods to clean up output of auto(start|stop) show or ls* Defaults CRON_TZ=UTC if not provided
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@kylecarbskylecarbskylecarbs approved these changes

@dwahlerdwahlerAwaiting requested review from dwahler

@greyscaledgreyscaledAwaiting requested review from greyscaled

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
V2 Beta
Development

Successfully merging this pull request may close these issues.

4 participants
@johnstcn@dwahler@kylecarbs@misskniss

[8]ページ先頭

©2009-2025 Movatter.jp