Skip to content
Snippets Groups Projects
Commit 2c152ffe authored by Fabian.Jakub's avatar Fabian.Jakub
Browse files

add SPACK_ICON_NWP_GITTOKEN to icon-nwp spack package to set an access token...

add SPACK_ICON_NWP_GITTOKEN to icon-nwp spack package to set an access token through environment variable
parent 9ead9c70
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,8 @@
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
from pathlib import Path
import os
from urllib.parse import urlparse
from spack.package import *
......@@ -68,7 +70,17 @@ class IconNwp(Package):
def do_fetch(self, mirror_only=False):
# FIXME: Using the custom_fetchers workaround
source = self.spec.variants['source'].value
self.fetcher[0].url = self.git = self.custom_fetchers[source]
url = self.custom_fetchers[source]
token = os.environ.get('SPACK_ICON_NWP_GITTOKEN')
if token is not None:
if 'https' in url:
parsed = urlparse(url)
user = 'token'
password = token
url = "{}://{}:{}@{}/{}".format(parsed.scheme, user, password, parsed.netloc, parsed.path)
self.fetcher[0].url = self.git = url
super(IconNwp, self).do_fetch(mirror_only)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment