Skip to content

Conversation

@dwilding
Copy link
Contributor

@dwilding dwilding commented Mar 31, 2025

This PR update the kubernetes and machine profiles to include a standalone module for workload-specific logic. Other profiles are not changed in any way.

In addition to the new workload module, the updated profiles have a bit more structure in charm.py to illustrate the basic flow of logic through the charm & workload module, and improved unit tests in test_charm.py.

This PR includes

  • New/updated template files for the kubernetes and machine profiles.
  • Changes to charmcraft/application/commands/init.py, to determine the name of the workload module from the charm name (using workload.py if the charm has a generic name such as charm or k8s-operator).
  • Changes to tests/integration/commands/test_init.py, to test the updated functionality (with tests passing).
  • Updated help and output of charmcraft init, to make users aware of the workload module.
  • New/updated reference docs:

Hopefully it will be easy to follow my commits in sequence. I tried to make the changes in a logical step-by-step order.

@lengau lengau requested a review from mr-cal March 31, 2025 22:21
@lengau
Copy link
Collaborator

lengau commented Mar 31, 2025

Adding @mr-cal on this since he made the upstream version.

Callahan, how hard do you think it'd be to do this in craft-application? Maybe we could make the template filenames format strings that take a small dict?

Copy link
Collaborator

@lengau lengau left a comment

Choose a reason for hiding this comment

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

Thanks for this PR David! Approving the template content themselves - I want to discuss the init changes and the docs with their relevant SMEs though before full approval.

Copy link
Contributor

@mr-cal mr-cal left a comment

Choose a reason for hiding this comment

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

@lengau, it's certainly possible to extend the existing design to allow for this. This is the second scenario where we have template-specific info. The other scenario is providing unique documentation links for each template.

I've been thinking about where this information could live. My current idea is a dict that we pass to the service, which maps template names to template data. That data could include a callables, for scenarios like this where the file renaming is complex.

Approving because the PR looks good and it can go upstream with some integration work.

Copy link
Contributor

@medubelko medubelko left a comment

Choose a reason for hiding this comment

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

Thanks @dwilding! I left some suggestions for a bit of doc refinement, but overall these look fine to me.

@dwilding
Copy link
Contributor Author

Thanks all for the reviews! @medubelko, I'll work on the doc changes first thing next week.

Copy link
Contributor

@medubelko medubelko left a comment

Choose a reason for hiding this comment

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

Latest doc change LGTM.

Copy link
Collaborator

@lengau lengau left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@lengau lengau merged commit 040cce3 into canonical:main Apr 24, 2025
29 of 32 checks passed
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