Skip to content

Commit

Permalink
Pull resources from the specified channel
Browse files Browse the repository at this point in the history
  • Loading branch information
Cynerva committed Dec 14, 2018
1 parent fdc09f4 commit 41cee5b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions shrinkwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ def main():
subordinates.append(appname)

# Get the charm resources metadata.
resp = requests.get('https://api.jujucharms.com/charmstore/v5/%s/meta/resources' % id)
charm = id.rpartition('-')[0]
resp = requests.get(
'https://api.jujucharms.com/charmstore/v5/%s/meta/resources' % charm,
params={'channel': args.channel}
)
resources = json.loads(resp.text)
bundle['applications'][appname]['resources'] = resources

Expand All @@ -159,8 +163,6 @@ def main():
filename = resource['Name'] + extension
resource['filename'] = filename

print(' Downloading resource %s...' % filename)

path = os.path.join(root, 'resources', appname, filename)

# If it's a snap, download it from the store.
Expand All @@ -185,15 +187,17 @@ def main():
snap = resource['Path'].replace('.snap', '')

# Download the snap and move it into position.
print(' Downloading resource %s from snap store...' % filename)
check_output(('snap download %s --channel=%s' % (snap, channel)).split(), stderr=STDOUT)
check_call('rm *.assert', shell=True)
check_call('mv %s* %s' % (snap, path), shell=True)

# This isn't a snap, do it the easy way.
else:
url = 'https://api.jujucharms.com/charmstore/v5/%s/resource/%s/%d' % (id,
resource['Name'],
resource['Revision'])
name = resource['Name']
revision = resource['Revision']
url = 'https://api.jujucharms.com/charmstore/v5/%s/resource/%s/%d' % (charm, name, revision)
print(' Downloading resource %s from charm store revision %s...' % (filename, revision))
check_call(('wget --quiet %s -O %s' % (url, path)).split())

print('Writing deploy scripts...')
Expand Down

0 comments on commit 41cee5b

Please sign in to comment.