Skip to content
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

Add EOL API #2117

Merged
merged 24 commits into from Apr 13, 2024
Merged

Add EOL API #2117

merged 24 commits into from Apr 13, 2024

Conversation

iliajie
Copy link
Collaborator

@iliajie iliajie commented Apr 9, 2024

Hey Jamie,

As discussed here I created an API to return an object of EOL related data for the current system.

Returned EOL object looks like this:

{
  '_eol' => {
    'daymonth' => 'Wednesday, June 10',
    'month' => 'June',
    'short' => '06/10/2026',
    'timestamp' => 1781038800,
    'year' => '2026'
  },
  '_eol_in' => {
    'days' => 791,
    'months' => 25,
    'weeks' => 113,
    'years' => 2
  },
  '_eol_sec' => {
    'daymonth' => 'Saturday, June 10',
    'month' => 'June',
    'short' => '06/10/2028',
    'timestamp' => 1844197200,
    'year' => '2028'
  },
  '_eol_sec_in' => {
    'days' => 1522,
    'months' => 50,
    'weeks' => 217,
    'years' => 4
  },
  '_os' => 'Debian Linux',
  'codename' => 'Bookworm',
  'cycle' => '12',
  'eol' => '2026-06-10',
  'extendedSupport' => '2028-06-10',
  'latest' => '12.5',
  'latestReleaseDate' => '2024-02-10',
  'link' => 'https://www.debian.org/News/2023/20230610',
  'lts' => 1,
  'releaseDate' => '2023-06-10'
}

We can later use it in alert message, and table row to be show on the dashboard depending on configurable options.

The EOL data is cached for 5 days by default.

Have a look please!

webmin/os-eol-lib.pl Outdated Show resolved Hide resolved
webmin/os-eol-lib.pl Outdated Show resolved Hide resolved
webmin/os-eol-lib.pl Outdated Show resolved Hide resolved
webmin/os-eol-lib.pl Outdated Show resolved Hide resolved
year => $eol_date->{'year'},
short => $eol_date->{'short'},
timestamp => $eol_timestamp };
$eol_data->{'_eol_in'} =
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just return a timestamp and have the caller of this API format it as they want?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's better call it once and make object just ready.

Copy link
Collaborator

Choose a reason for hiding this comment

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

An internal API like this shouldn't contain a lot of presentation logic - it should be up to the caller to format the dates for display.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed! I have factored this logic out. Nevertheless, there is still a lot to do to prevent multiple callers from having to reimplement this logic - there has to be a dedicated subroutine for this.

@iliajie
Copy link
Collaborator Author

iliajie commented Apr 10, 2024

Alright, all fixed!

@iliajie
Copy link
Collaborator Author

iliajie commented Apr 10, 2024

Jamie, all done this time! Please have another look!

makedist.pl Show resolved Hide resolved
@@ -0,0 +1,1810 @@
=pod
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this just the file that the API provides?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The API doesn't provide this. I made it as a reference to remember what the data structures are like and what Webmin thinks about OSes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So is this file used by any Webmin code? I'm confused as to why we need to check it in ..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, this is just a .map file. It won't go to the package itself. I checked it in for the reference!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should remove it, as it's kind of confusing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alright, it's done. I just wanted to make it easier for future support.

webmin/os-eol-lib.pl Outdated Show resolved Hide resolved
webmin/os-eol-lib.pl Outdated Show resolved Hide resolved
@iliajie
Copy link
Collaborator Author

iliajie commented Apr 11, 2024

Yeah, I know. But it's much more simple to compare miniserv server version, as it's always getting updated on Webmin upgrade.

makedist.pl Show resolved Hide resolved
}

# eol_update_cache()
# Caches the use of EOL data for next 30 days
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not 30 days anymore is it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not 30 days anymore is it?

It isn't, just an old comment. Fixed now.

@jcameron jcameron merged commit ba9b178 into master Apr 13, 2024
@iliajie iliajie deleted the dev/eol-api branch April 13, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants