feat(templates): add Workshop dev-environment scaffold to machine and kubernetes init profiles - #2
Draft
tonyandrewmeyer wants to merge 1 commit into
Draft
feat(templates): add Workshop dev-environment scaffold to machine and kubernetes init profiles#2tonyandrewmeyer wants to merge 1 commit into
tonyandrewmeyer wants to merge 1 commit into
Conversation
… kubernetes init profiles Scaffold a Canonical Workshop dev environment into the `machine` and `kubernetes` init profiles: a root `workshop.yaml` and an in-project, hooks-only project SDK at `.workshop/project-dev/` (sdk.yaml plus setup-base, setup-project and check-health hooks). The charm packs inside the workshop via `charmcraft pack --destructive-mode`, so the base is pinned to ubuntu@24.04 to match the charm's build base and the setup-project hook pre-installs the charm's declared build-packages/build-snaps (which the unprivileged workshop user cannot install at pack time). The juju SDK targets an external controller via a `system:` tunnel slot, since bootstrapping a controller / Canonical Kubernetes inside an unprivileged workshop container is blocked today. The init command marks the three hooks executable, and the init tests assert the scaffold renders with the charm name, ships no leftover template syntax, and emits executable hooks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is a DRAFT / exploratory change that adds a Canonical Workshop dev-environment scaffold to charmcraft's
inittemplates for themachineandkubernetesprofiles. After this change,charmcraft init --profile machineandcharmcraft init --profile kuberneteseach scaffold a charm project that ships a ready-to-use Workshop dev environment.Each generated project gains:
workshop.yamldescribing an ephemeral LXD dev environment (base: ubuntu@24.04) wiring up thesystem,uv,juju(3.6/stable) andcharmcraft(latest/stable) Store SDKs plus the in-projectproject-devSDK, withunit/pack/integrationactions..workshop/project-dev/—sdk.yamlplussetup-base,setup-projectandcheck-healthhooks. The SDK is defined in place and has no build-time fields (nobase/build-base/platforms/parts); it is configured entirely via the hooks.How it works
charmcraft pack --destructive-mode— there is no nested build VM. Because destructive-mode packs in the current environment, the workshopbaseis pinned toubuntu@24.04to match the charm template'sbuild-onbase.--destructive-mode, charmcraft runs as the unprivilegedworkshopuser and cannot apt/snap-install. So:setup-base(runs as root at base-prep time) installs the common charm build tooling andyq.setup-project(runs as root after the project is mounted) parsescharmcraft.yamland pre-installs the charm's declaredparts.charm.build-packages(apt) andbuild-snaps(snap, e.g.astral-uv), then runsuv syncas theworkshopuser.check-healthverifies theworkshopuser can runcharmcraftand import the charm's deps.Deliberate design decisions / caveats
toxSDK. There is intentionally no publishedtoxSDK referenced anywhere — tox was only ever a local experiment. tox-style steps are run viauv runactions instead.juju bootstrap localhost) inside an unprivileged workshop container fails today, and Canonical Kubernetes does not come up inside one either. So integration tests target a Juju controller running outside the workshop, reached via asystem:SDKtunnelslot (juju-api, endpoint17070).system:SDK tunnel slot is not auto-connected, so it cannot go inconnections:. The requiredworkshop connect/workshop remountcommands are documented in a comment inworkshop.yamlinstead.workshop.yamlnotes that an in-workshop Canonical Kubernetes substrate SDK is the intended future shape but is currently blocked (needs a more-privileged container than Workshop provides), and that juju should point at an external k8s-backed controller..workshop/project-dev/path (no templating in paths); the charm name is substituted only inside file contents via the existing{{ name }}init variable.Implementation notes
executableslist incharmcraft/application/commands/init.pyso they are emitted with the executable bit set, matching how the existing template executables are handled.initoverview docstring's file tree now mentionsworkshop.yamland.workshop.Verification done
.workshop/directory) ship as package data, then installed the wheel into a clean venv and confirmedcharmcraft initemits them with the charm name substituted, no leftover template syntax, and executable hooks.ruff check,codespell, andshellcheck(run CI-style over the hook templates, whichfiledetects as shell scripts) all pass.test_workshop_scaffoldtest and updatedBASIC_INIT_FILES; the init test suite passes (pytest tests/integration/commands/test_init.py).Test plan
charmcraft init --profile machineand--profile kubernetesin an empty dir emitworkshop.yamland.workshop/project-dev/...workshop launch+workshop run dev pack+workshop run dev unit/integrationagainst an external controllerhttps://claude.ai/code/session_013ZAmXXPxcfRBUdjK9thAKD
Generated by Claude Code