Skip to content

chore: Make deployment admin page show better durations #6856

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

Merged
merged 7 commits into from
Mar 29, 2023

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Mar 28, 2023

Also fix group mappings

fixes: #6834

After

Screenshot from 2023-03-28 14-19-08

Screenshot from 2023-03-28 14-19-12

Screenshot from 2023-03-28 14-20-29

Screenshot from 2023-03-28 14-38-01

@Emyrk Emyrk requested a review from Kira-Pilot March 28, 2023 19:40
// We have to add in the 25 leap days for the frontend to show the
// "100 years" correctly.
Default: ((100 * 365 * time.Hour * 24) + (25 * time.Hour * 24)).String(),
Value: &c.MaxTokenLifetime,
Copy link
Member

Choose a reason for hiding this comment

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

In apikey.go, we check to see if --max-token-lifetime is unset. I think we'll have to adjust this logic now that we aren't using time.Duration(math.MaxInt64).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oof, I hate this maxint buisness. We should have just used 0 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

We can bring back in "unset" if we need later.

@Kira-Pilot
Copy link
Member

I think we need to regenerate cli/testdata/coder_server_--help.golden; it is outdated now that we've adjusted the default value for --max-token-lifetime.

// optionValue is a helper function to format the value of a specific deployment options
function optionValue(option: DeploymentOption): string[] | string | unknown {
switch (option.name) {
case "Max Token Lifetime":
Copy link
Member

Choose a reason for hiding this comment

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

What's up with this empty case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't case blocks fall through to each other? These two cases are handled the same.

Copy link
Member

Choose a reason for hiding this comment

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

:D I had to google that - you're right.

Down the road, I wonder if we should type DeploymentOption.flag as something other than string (like we should return an enum). Then we could have an object lookup on the FE, like:

const deploymentOptionFormats: { [key: FlagEnum]: (option: DeploymentOption) => string[] | string | unknown } = {
    flagName1: (option) => {
        // format and return
    },
    ....
}

// in the JSX
<OptionValue>{deploymentOptionFormats[option.flag](option)}</OptionValue>

This would give us some additional type safety. Not something to worry about in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Totally makes sense. I didn't know the "typescript" way to do this.

Copy link
Member

@Kira-Pilot Kira-Pilot left a comment

Choose a reason for hiding this comment

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

Everything looks great - thanks for tackling this.

@Emyrk Emyrk merged commit 90da09b into main Mar 29, 2023
@Emyrk Emyrk deleted the stevenmasley/better_durations branch March 29, 2023 21:26
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Max Token Lifetime is not human friendly
2 participants