Skip to content

cli: replace lua-var codegen with //go:embed#1301

Open
bigbes wants to merge 6 commits into
bigbes/tntp-7390-lib-cluster-cleanup-v2from
bigbes/gh-no-embed
Open

cli: replace lua-var codegen with //go:embed#1301
bigbes wants to merge 6 commits into
bigbes/tntp-7390-lib-cluster-cleanup-v2from
bigbes/gh-no-embed

Conversation

@bigbes
Copy link
Copy Markdown
Collaborator

@bigbes bigbes commented May 27, 2026

Lua scripts were serialized into *_gen.go files by a custom jennifer-based generator that ran on every build. Replace it with //go:embed declarations in dedicated lua_embed.go files in each package — cli/running, cli/connector, cli/checkpoint — and drop the generateLuaCodeVar pass from cli/codegen/generate_code.go.

While here, remove cli/connector/lua/call_func_template.lua and its companion callFuncTmpl var — dead since the cartridge-cli removal.

The filemode generator stays (embed.FS strips unix mode bits, so the side-channel map is still necessary for the create-app templates).

jennifer is left in go.mod intentionally - running go mod tidy risks unrelated dep churn that's better handled separately.

bigbes added 6 commits May 27, 2026 13:48
CreateDataCollector is rewritten on top of NewStorageConnection +
NewRemoteStorage so that callers no longer need to know about etcd/TCS
client primitives. Integration tests are updated to drop the removed
YamlCollectorDecorator wrapper and to take a pkgstorage.Storage instead
of a raw etcd client.

Part of TNTP-7390
These files implemented the in-tree ClusterConfig hierarchy, the
Collector/CollectorFactory layer, and the YAML decorator that consumers
have all moved off of.

Closes TNTP-7390
Collapse the twin DataCollectorFactory and DataPublisherFactory into a
single Factory type. RawStorage already implements both DataCollector and
DataPublisher, so the two factories were mechanically duplicating each
other; their only real difference was which integrity options
(verifiers vs signer/verifiers) the caller wired up.

Along the way drop a handful of redundant shims now subsumed by the
unified factory and RawStorage:

  - CSConnection / ConnectCStorage: a duplicate codec wrapper around
    RawStorage. The two failover callers now build a RawStorage
    directly via NewStorage with an empty objectLocation.
  - IRawStorage: declared but never used as a type.
  - CreateDataCollector: a three-line wiring helper with a single
    caller; inlined.
  - NewConfigStorage: a one-line default-argument helper folded into
    Factory.NewRemoteStorage.

Rename FileDataPublisher -> FilePublisher for symmetry with
FileCollector. Helpers in cli/cmd that constructed the two factories
are consolidated into createCollectorFactory /
createPublisherFactory / createCollectorAndPublisherFactories. The
cli/cluster/cmd nil-checking createPublisherAndCollector splits into
openRemoteCollector (show) and openCollectorAndPublisher (publish).

Part of TNTP-7390
Drop redundant indirection across lib/cluster and lib/integrity and
wire the cleaned-up API through cli/cmd:

- Merge datacollector.go, datapublisher.go, errors.go into types.go;
  remove unused CollectEmptyError and errWrongRevision.
- Inline defaultFileReadFunc and the newFileCollector wrapper.
- Collapse RawStorage's collectByKey/publishByKey/collectByRange/
  publishByRange into Get/Put/Collect/Publish; inline
  applyIntegrityBuilderOptions into NewStorage.
- Wire optional cleanup into RawStorage.Close via SetCleanup so
  callers don't need a wrapper; drop failoverStorage.
- Expose NewCollectorFactory/NewPublisherFactory in cli/cluster as a
  single source of truth, inline the cli/cmd/common.go delegation
  wrappers at the 13 call sites in cli/cmd, and wrap pass-through
  errors crossing the cli/cluster boundary.
- Merge dummy_repository.go into lib/integrity/integrity.go; drop
  unused AddHash/Add stubs; shrink redundant flag-registrar tests;
  wrap os.Open's error in dummyRepository.Read with the path.
- Annotate three RawStorage internal pass-throughs with
  //nolint:wrapcheck — the callee already wraps with the storage type.

Part of TNTP-7390
Lua scripts were serialized into *_gen.go files by a custom
jennifer-based generator that ran on every build. Replace it with
//go:embed declarations in dedicated lua_embed.go files in each
package — cli/running, cli/connector, cli/checkpoint — and drop the
generateLuaCodeVar pass from cli/codegen/generate_code.go.

While here, remove cli/connector/lua/call_func_template.lua and its
companion callFuncTmpl var — dead since the cartridge-cli removal.

The filemode generator stays (embed.FS strips unix mode bits, so the
side-channel map is still necessary for the create-app templates).
The filemode codegen pipeline existed to record per-file Unix mode bits
that embed.FS strips. In practice every entry across all four built-in
templates was 0o644, so the generator, the four gitignored *_gen.go
maps, and the side-channel lookup were storing a single constant.

Drop the whole subsystem:

- Delete cli/codegen/generate_code.go and the cli/codegen/ directory.
- Delete cli/create/builtin_templates/static/ (4 gitignored gen files
  plus the .gitkeep — the package only existed to hold the generated
  maps).
- Drop builtin_templates.FileModes; copyEmbedFs no longer takes a
  fileModes map and hard-codes 0o755 for directories, 0o644 for files.
  Drop the getFileMode helper.
- Drop GenerateGoCode and its mg.Deps(...) hooks from magefile.go;
  nothing remains to generate.
- Drop **/*_gen.go from .gitignore — no generated files to ignore.

Update the copy_app_template test to match the new constant-mode
contract (the old test asserted per-file exec bits that production
never produced).

jennifer is left in go.mod intentionally — running `go mod tidy`
risks unrelated dep churn that's better handled separately.
@bigbes bigbes requested review from Mockird31 and sssciel May 27, 2026 21:18
@bigbes bigbes force-pushed the bigbes/tntp-7390-lib-cluster-cleanup-v2 branch from 471754d to d336530 Compare May 29, 2026 15:47
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.

3 participants