Fix: Decouple plugin --spec dump from core's embedded spec FS - #112
Open
BlueLabelscotch wants to merge 1 commit into
Open
Fix: Decouple plugin --spec dump from core's embedded spec FS#112BlueLabelscotch wants to merge 1 commit into
BlueLabelscotch wants to merge 1 commit into
Conversation
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
rootcmd.SetupAndExecutePluginRootCmdnow takesspecBytes []byteand prints them verbatim on
--spec, instead of callingspecloader.ReadSpecFile(moduleName)(which only reads names bakedinto core's
pkg/specembed.FS at compile time).specloader.LoadSpecnow returns the bytes it read, in addition toregistering the spec — no behavior change for existing callers
beyond the new return value.
specloader.LoadSpecBytes(reg, name, data, isHarnessUser)—same registration logic as
LoadSpec, but the caller supplies thebytes directly instead of going through
spec.Read.har'smain-harness-har.goto the newLoadSpecsignature.Why
go:embedglobs are resolved at compile time of the declaringpackage's own source directory —
pkg/spec's embed can only ever see.spec.yamlfiles physically committed insideharness-unified-cli/pkg/spec/.harworks today only becausehar.spec.yamlhappens to be checked into that directory. A pluginthat lives in a genuinely separate repo (e.g. an upcoming
hcliplugin) has no way to get its spec file into that embed, so the old
dumpSpec/ReadSpecFilepath would fail for it with "file notfound." This change lets each plugin supply its own spec bytes from
wherever it likes (its own
go:embed, typically), whilerootcmd/specloaderstay generic.