Skip to content

Commit

Permalink
Fix #3 w/ CentOS 7.7+ compatibility for gsiam.py
Browse files Browse the repository at this point in the history
Python functions that Yum expects in plugins changed somewhere between
CentOS 7.4 and 7.7, and on 7.7, Yum is unable to use `gsiam` to parse
`gs://` URLs:

```
[root@f5645f8162d5 /]# yum repolist
Loaded plugins: fastestmirror, gsiam, ovl
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
 Eg. gs://example-bucket/path-to-repo/
```

This patch maintains CentOS 7.4 compatibility and adds CentOS 7.7 and
7.8 compatibility, as well.
  • Loading branch information
shatil committed Apr 15, 2021
1 parent a9fb5cb commit 0442f65
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NAME=yum-plugin-gs-iam
VERSION=1.0.0
VERSION=1.1.0
11 changes: 8 additions & 3 deletions gsiam.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
URL_SCHEME = 'gs://'

__all__ = ['requires_api_version', 'plugin_type', 'CONDUIT',
'config_hook', 'prereposetup_hook']
'config_hook', 'init_hook', 'prereposetup_hook']

requires_api_version = '2.5'
plugin_type = yum.plugins.TYPE_CORE
Expand Down Expand Up @@ -54,7 +54,7 @@ def replace_repo(repos, repo):
repos.add(GCSRepository(repo.id, repo))


def prereposetup_hook(conduit):
def init_hook(conduit):
"""Plugin initialization hook. Setup the GCS repositories."""
repos = conduit.getRepos()
for repo in repos.listEnabled():
Expand All @@ -66,6 +66,11 @@ def prereposetup_hook(conduit):
replace_repo(repos, repo)


def prereposetup_hook(conduit):
"""Maintain compatibility with Yum on older CentOS (< 7.7.1908) releases."""
return init_hook(conduit)


class GCSRepository(YumRepository):

def __init__(self, repoid, repo):
Expand All @@ -82,7 +87,7 @@ def __init__(self, repoid, repo):

if repo.google_application_credentials:
os.environ[environment_vars.CREDENTIALS] = repo.google_application_credentials

self.bucket = bucket
self.base_path = path
self.name = repo.name
Expand Down

0 comments on commit 0442f65

Please sign in to comment.