-
Notifications
You must be signed in to change notification settings - Fork 73
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
fix: replace colons with hyphens in charm names #2060
base: main
Are you sure you want to change the base?
Conversation
Multi-base charms may have colons in their platform name. These get converted to hyphens because some environments don't allow colons in filenames. Signed-off-by: Callahan Kovacs <[email protected]>
charmcraft/services/package.py
Outdated
build_plan = models.CharmcraftBuildPlanner.model_validate( | ||
self._project.marshal() | ||
).get_build_plan() | ||
platform = utils.get_os_platform() | ||
build_on_base = bases.BaseName(name=platform.system, version=platform.release) | ||
host_platform = utils.get_os_platform() | ||
build_on_base = bases.BaseName( | ||
name=host_platform.system, version=host_platform.release | ||
) | ||
host_arch = util.get_host_architecture() | ||
for build_info in build_plan: | ||
print(build_info) | ||
if build_info.build_on != host_arch: | ||
continue | ||
if build_info.base == build_on_base: | ||
return dest_dir / f"{self._project.name}_{build_info.platform}.charm" | ||
platform = build_info.platform.replace(":", "-") | ||
return dest_dir / f"{self._project.name}_{platform}.charm" | ||
|
||
raise errors.CraftError( | ||
"Current machine is not a valid build platform for this charm.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I am mistaken, we could delete everything after line 125 in this function.
I don't think there is a scenario where self._platform
doesn't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may well be true now. It wasn't true when I first implemented this service, but at that point we could have self._platform == None
. I'd have to do a deep dive into craft-application to see if that's still valid in the PackageService.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I was suspecting this was needed during the craft-application migration.
I poked around at the service factory and how charmcraft inits the pack service and dropping this appears safe.
The package service will always have a platform, so the code to generate the charm filenames can be simplified. Signed-off-by: Callahan Kovacs <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎸
Multi-base charms may have colons in their platform name. These get converted to hyphens because some environments don't allow colons in filenames.
Fixes #2057