Repository navigation
fix: Initialize IaC providers for dump subcommand - #87
Merged
Merged
Conversation
c7n-left registers its IaC providers in its cli group callback, which is skipped when sinistral invokes the dump subcommand directly. Call initialize_iac() before dumping, default the directory to ".", and raise a usage error when no supported IaC files are found. Also avoid appending duplicate params on repeated make_parser calls. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
tvansteenburgh
approved these changes
Oct 7, 2026
tvansteenburgh
left a comment
Contributor
There was a problem hiding this comment.
LGTM, thanks @ajkerrigan
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant User
participant Sinistral as Sinistral CLI (dump cmd)
participant LeftWrapper as LeftWrapper (click)
participant C7NLeft as c7n-left CLI (left_dump)
participant Provider as IaC Provider Registry
participant FS as Filesystem
Note over Sinistral,Provider: sinistral dump invokes c7n-left dump directly,<br/>bypassing c7n-left top-level CLI setup
User->>Sinistral: invoke dump subcommand
Sinistral->>LeftWrapper: make_parser(ctx)
LeftWrapper->>LeftWrapper: merge left_dump params<br/>(skip duplicates)
LeftWrapper-->>Sinistral: parser ready
Sinistral->>Provider: initialize_iac()
Provider->>Provider: register Terraform provider<br/>and any IaC providers
alt directory param missing
Sinistral->>Sinistral: default directory to "."
end
Sinistral->>FS: get_provider(directory)
FS-->>Sinistral: provider for IaC type (or None)
alt no supported IaC files
Sinistral-->>User: UsageError: No supported IaC files found
else provider available
Sinistral->>C7NLeft: invoke left_dump(ctx)
C7NLeft->>FS: parse .tf/.json files
FS-->>C7NLeft: resource graph
C7NLeft-->>Sinistral: dump output (JSON)
Sinistral-->>User: graph + variables
end
Note over Sinistral,FS: Regression tests invoke CLI in a subprocess<br/>to avoid import side-effect registration</br>from prior in-process c7n-left usage
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.
what
Call
c7n-left'sinitialize_iac()to load the Terraform provider as part of runningsinistral dump.why
For a case where
c7n-left dump -d .succeeds,sinistral dump -d .fails with:AttributeError: 'NoneType' object has no attribute 'initialize'Because sinistral bypasses some top-level CLI logic that c7n-left runs by default, so it handles provider registration for
sinistral runwhile loading policies. It never loads the provider for thedumpcase.testing
Tested locally, added a regression test.
docs
N/A