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

Fixes #16569: Add an "upgrade-all" command to rudder-pkg #2721

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions relay/sources/rudder-pkg/lib/rudder-pkg/rudderPkg.py
Expand Up @@ -320,3 +320,21 @@ def update():
logging.debug("restoring %s from %s"%(utils.INDEX_PATH, utils.INDEX_PATH + ".bkp"))
os.rename(utils.INDEX_PATH + ".bkp", utils.INDEX_PATH)
utils.fail(e)

"""
Upgrade all plugins install in their latest compatible version
"""
def upgrade_all(mode):
for p in utils.DB["plugins"].keys():
currentVersion = rpkg.PluginVersion(utils.DB["plugins"][p]["version"])
pkgs = plugin.Plugin(p)
pkgs.getAvailablePackages()
if mode == "nightly":
latestVersion = pkgs.getLatestCompatibleNightly().version
else:
latestVersion = pkgs.getLatestCompatibleRelease().version
if currentVersion < latestVersion:
print("The plugin %s is installed in version %s. The version %s %s is available, the plugin will be upgraded."%(p, currentVersion.pluginLongVersion, mode, latestVersion.pluginLongVersion))
package_install_latest([p], mode)
else:
print("No newer %s compatible versions found for the plugin %s"%(mode, p))
10 changes: 10 additions & 0 deletions relay/sources/rudder-pkg/rudder-pkg
Expand Up @@ -6,6 +6,7 @@ Rudder package manager
Usage:
rudder package [--debug] install-file <package.rpkg>...
rudder package [--debug] install <package> [--version=<version>] [--nightly]
rudder package [--debug] upgrade-all [--nightly]
rudder package [--debug] show <package> [--version=<version>] [--nightly]
rudder package [--debug] remove <package>...
rudder package [--debug] search <package>...
Expand Down Expand Up @@ -34,6 +35,9 @@ Commands:
install
download and install the latest released version of the plugin

upgrade-all
download and upgrade the installed plugins to their latest available version

show
show detailed informations on a given plugin

Expand Down Expand Up @@ -103,6 +107,12 @@ if __name__ == "__main__":
rudderPkg.package_list_installed()
elif args['update']:
rudderPkg.update()
elif args['upgrade-all']:
if args['--nightly']:
rudderPkg.upgrade_all("nightly")
else:
rudderPkg.upgrade_all("release")

elif args['licenses']:
rudderPkg.update_licenses()
elif args['search']:
Expand Down