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

feat(extensions): pass app name to get_app_snippet() #4926

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mr-cal
Copy link
Collaborator

@mr-cal mr-cal commented Jul 17, 2024

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run tox run -m lint?
  • Have you successfully run tox run -e test-py310? (supported versions: py39, py310, py311, py312)

To support #4925, where an extension needs to know the name of the app when creating the app's snippet.

source: https://matrix.to/#/!GGqzbFAUQprdPgYYCM:ubuntu.com/$6GuTjHbBgrKzNoUcc6XKCLLqsy_roBsw4OMDFQIUPY4?via=ubuntu.com&via=matrix.org&via=kde.org

Signed-off-by: Callahan Kovacs <callahan.kovacs@canonical.com>
Copy link
Member

@farshidtz farshidtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot.

Tried on #4925 at it works as expected:

diff --git a/snapcraft/extensions/env_injector.py b/snapcraft/extensions/env_injector.py
index c669fa1f4..cf895075f 100644
--- a/snapcraft/extensions/env_injector.py
+++ b/snapcraft/extensions/env_injector.py
@@ -71,10 +71,12 @@ class EnvInjectorExtension(Extension):
 
     
     @overrides
-    def get_app_snippet(self) -> Dict[str, Any]:
-        """Return the app snippet to apply."""
+    def get_app_snippet(self, *, app_name: str) -> Dict[str, Any]:
         return {
             "command-chain": [ "bin/command-chain/env-exporter"],
+            "environment": {
+                "env_alias": app_name,
+            }
         }
 
     @overrides

Copy link

@locnnil locnnil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! This will help a lot! Thank you!

@farshidtz farshidtz mentioned this pull request Jul 19, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants