feat: include rendered spec location in component list output#85
feat: include rendered spec location in component list output#85
Conversation
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
dmcilvaney
left a comment
There was a problem hiding this comment.
Approve pending scenario test results
There was a problem hiding this comment.
Pull request overview
Adds a derived renderedSpecDir field to resolved component configs so azldev component list -O json can include each component’s rendered spec output directory (based on the project’s rendered-specs-dir setting).
Changes:
- Introduce
components.RenderedSpecDir(renderedSpecsDir, componentName)helper to compute{rendered-specs-dir}/{component-name}. - Add
RenderedSpecDirderived field toprojectconfig.ComponentConfigand populate it during component resolution. - Update
component listconfig extraction logic and extend tests for configured/unconfigured rendered-specs-dir behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/projectconfig/component.go | Adds RenderedSpecDir derived field and preserves it through WithAbsolutePaths cloning. |
| internal/app/azldev/core/components/resolver.go | Populates RenderedSpecDir at resolve time for all resolved components. |
| internal/app/azldev/core/components/renderedspecdir.go | New helper that computes the per-component rendered spec output directory. |
| internal/app/azldev/core/components/renderedspecdir_test.go | Unit tests for the helper behavior. |
| internal/app/azldev/cmds/component/list.go | Removes lo.Map usage and returns resolved component configs via a loop. |
| internal/app/azldev/cmds/component/list_test.go | Adds test coverage for rendered-specs-dir propagation into list output. |
Add RenderedSpecDir field to component list results, computed from the project's rendered-specs-dir config and component name. The path calculation is extracted into a reusable RenderedSpecDir helper function in the components package for use by future commands (e.g. component render). Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/10d51939-dcb0-47d4-bbb0-1ebe7341e052 Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/10d51939-dcb0-47d4-bbb0-1ebe7341e052 Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
Move RenderedSpecDir from the ComponentListEntry wrapper into ComponentConfig directly (with toml:"-" to exclude from serialization). The field is now populated by the resolver's createComponentFromConfig, making it available to all consumers of resolved components. Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/e7cc285b-04b7-4227-94f2-79231f4455b0 Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/7f9228f1-708c-4dd3-92dc-01d73387ae97 Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
29edcf5 to
3bd1ac1
Compare
| // Returns an error if componentName is unsafe (absolute, contains path separators | ||
| // or traversal sequences). | ||
| func RenderedSpecDir(renderedSpecsDir, componentName string) (string, error) { | ||
| if err := fileutils.ValidateFilename(componentName); err != nil { | ||
| return "", fmt.Errorf("invalid component name for rendered spec dir:\n%w", err) | ||
| } | ||
|
|
There was a problem hiding this comment.
RenderedSpecDir relies on fileutils.ValidateFilename(componentName), but ValidateFilename does not reject Windows volume-qualified names (e.g. "C:tmp"). On Windows, filepath.Join(renderedSpecsDir, "C:tmp") can discard the base directory and produce a path on another volume, undermining the safety guarantee this helper is meant to provide. Consider rejecting componentName values where filepath.VolumeName(componentName) != "" (ideally inside ValidateFilename so all callers benefit).
| // Returns an error if componentName is unsafe (absolute, contains path separators | |
| // or traversal sequences). | |
| func RenderedSpecDir(renderedSpecsDir, componentName string) (string, error) { | |
| if err := fileutils.ValidateFilename(componentName); err != nil { | |
| return "", fmt.Errorf("invalid component name for rendered spec dir:\n%w", err) | |
| } | |
| // Returns an error if componentName is unsafe (absolute, contains path separators, | |
| // traversal sequences, or a platform-specific volume name). | |
| func RenderedSpecDir(renderedSpecsDir, componentName string) (string, error) { | |
| if err := fileutils.ValidateFilename(componentName); err != nil { | |
| return "", fmt.Errorf("invalid component name for rendered spec dir:\n%w", err) | |
| } | |
| if filepath.VolumeName(componentName) != "" { | |
| return "", fmt.Errorf("invalid component name for rendered spec dir:\ncomponent name %#q must not include a volume name", componentName) | |
| } |
azldev component listnow includes each component's rendered spec output directory (derived fromrendered-specs-dirconfig). Empty when not configured.internal/app/azldev/core/components/renderedspecdir.go— ReusableRenderedSpecDir(renderedSpecsDir, componentName)helper computing{rendered-specs-dir}/{component-name}. Futurecomponent render(PR feat(render): add azldev component render command #81) and subfolder-split work can use this single calculation point.internal/projectconfig/component.go— AddedRenderedSpecDiras a derived field onComponentConfig(toml:"-"excludes it from serialization;table:"-"hides it from human-readable table output; JSON tag exposes it for programmatic use). Follows the same pattern as other derived fields likeNameandSourceConfigFile.internal/app/azldev/core/components/resolver.go— The resolver'screateComponentFromConfigpopulatesRenderedSpecDirat resolve time, making it available to all consumers of resolved components (not just the list command).Example JSON output when
rendered-specs-dir = "SPECS"is configured:[{"name": "vim", "renderedSpecDir": "/project/SPECS/vim", ...}]When
rendered-specs-diris not set,renderedSpecDiris omitted. The field is only included in JSON output (-O json), not in the default table view.