Add git-ops project slice command group (create, list, inspect)#60
Merged
Conversation
Add three new commands to manage individual slices of a project from the cli: - `git-ops project slice create`: scaffold a new source slice file containing a placeholder for each required property of the store's schema, recursing into mandatory embedded relations. - `git-ops project slice list`: list the slices of one or all stores, as a table or as json, with the version they would be assigned during an update compile. - `git-ops project slice inspect`: dump the fully-resolved merged view of a single slice as json. Each command triggers a dedicated compile mode during which no slice is emitted in the model, the command logic runs in a finalizer which sends its result back to the cli process through a temporary output file. The compile output is redirected to stderr so the command result on stdout stays clean for piping. Also guard the merge of deleted slices against source slices that never had any active version, which previously raised a KeyError. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The scaffold of a new slice now also contains the non-required properties of the store's schema, pre-filled with their default value, so the created file shows every available property. Model-only attributes (marked with exclude_if) stay out of the scaffold, as they are not part of the slice source files. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Scaffolding a store whose schema has a mandatory embedded relation with a default factory (e.g. container: Container = Field(default_factory=Container)) failed when the embedded object has required properties of its own: the factory call raised a validation error. Embedded relations with a single embedded slice annotation are now always scaffolded recursively, even when the field has a default, the same way the entity schema always treats them as mandatory relations. Other default values are serialized through pydantic, so embedded objects nested in a default value are written like slice files, and a default that can not be constructed falls back to the placeholder. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Pass a logging configuration to the slice command compiles (through the INMANTA_LOGGING_COMPILER_CONTENT environment variable defined by inmanta-core) which sends all the compiler logs to stderr. The compiler no longer logs anything on stdout, which only carries the result of the slice command. The stdout redirection to stderr is kept as a safety net for anything writing to stdout outside of the logging framework. The logging configuration is only applied when the user didn't configure the compiler logging themselves, through one of the environment variables recognized by inmanta-core. A --logging-config argument passed to the compile takes precedence over it in any case. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The logging configuration passed to the slice command compiles now mirrors the default console logging of the compiler: the logs sent to stderr keep their colors when stderr is a tty. The FORCE_TTY environment variable, recognized by inmanta-core, is also set in that case, so the rest of the compile output (error summary, explainers) keeps its styling even though it now goes through a pipe. The compile output is streamed to stderr through that pipe, and the success/failure banner of the compile summary is dropped on the way. The error message of a failed compile is preserved. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Add three new commands to manage individual slices of a project from the cli:
git-ops project slice create: scaffold a new source slice file containing a placeholder for each required property of the store's schema, recursing into mandatory embedded relations.git-ops project slice list: list the slices of one or all stores, as a table or as json, with the version they would be assigned during an update compile.git-ops project slice inspect: dump the fully-resolved merged view of a single slice as json.Each command triggers a dedicated compile mode during which no slice is emitted in the model, the command logic runs in a finalizer which sends its result back to the cli process through a temporary output file. The compile output is redirected to stderr so the command result on stdout stays clean for piping.
Also guard the merge of deleted slices against source slices that never had any active version, which previously raised a KeyError.