Skip to content

feat: dir and file updates to support working dir#591

Merged
jakobmoellerdev merged 26 commits into
open-component-model:mainfrom
matthiasbruns:feat/565_relative_file_pointers_dir_input
Aug 22, 2025
Merged

feat: dir and file updates to support working dir#591
jakobmoellerdev merged 26 commits into
open-component-model:mainfrom
matthiasbruns:feat/565_relative_file_pointers_dir_input

Conversation

@matthiasbruns

Copy link
Copy Markdown
Contributor

What this PR does / why we need it

Resolve file/dir inputs relative to the constructor file by wiring a filesystem working directory through input methods; default-deny path escapes with an explicit opt-out.

Changes (high level):

  • Added WorkingDirectory to FS config and flag plumbing in CLI.
  • Updated file/dir input methods to use the working dir + path utils; tests updated for path handling.

Which issue(s) this PR fixes

Fixes #565

Fix: broken build

On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
Copilot AI review requested due to automatic review settings August 19, 2025 09:28
@matthiasbruns matthiasbruns requested a review from a team as a code owner August 19, 2025 09:28
@github-actions github-actions Bot added the size/m Medium label Aug 19, 2025

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>
@matthiasbruns matthiasbruns force-pushed the feat/565_relative_file_pointers_dir_input branch from 06b15fe to 8d0cd26 Compare August 19, 2025 09:33
@matthiasbruns matthiasbruns marked this pull request as draft August 20, 2025 07:07
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
@matthiasbruns matthiasbruns changed the title Add: dir and file updates to support working dir feat: dir and file updates to support working dir Aug 20, 2025
@github-actions github-actions Bot added the kind/feature new feature, enhancement, improvement, extension label Aug 20, 2025
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/cmd.go Outdated
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
@github-actions github-actions Bot added the size/l Large label Aug 20, 2025
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
@matthiasbruns matthiasbruns marked this pull request as ready for review August 20, 2025 13:30
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/add/component-version/cmd.go Outdated
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
…m:matthiasbruns/open-component-model into feat/565_relative_file_pointers_dir_input
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>

@jakobmoellerdev jakobmoellerdev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approach is generally sound but have quite a few style findings. also missing a test where you actually run the command with this workin dir override

Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/global/flags.go Outdated
Comment thread cli/cmd/setup/hooks/pre_run.go Outdated
Comment thread cli/cmd/setup/hooks/pre_run.go Outdated
Comment thread cli/cmd/setup/hooks/pre_run.go Outdated
Comment thread cli/cmd/setup/setup_filesystem_config.go Outdated
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces working directory support for file and directory input methods, allowing paths to be resolved relative to a configurable working directory while providing path escape protection.

  • Adds WorkingDirectory configuration to filesystem config and wire it through input method registration
  • Updates CLI flag handling to support both temp folder and working directory configuration
  • Refactors setup code into a modular hook system with options pattern for better extensibility

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cli/internal/plugin/builtin/input/file/method.go Adds filesystem config parameter to register working directory with file input method
cli/internal/plugin/builtin/input/dir/method.go Adds filesystem config parameter to register working directory with dir input method
cli/internal/plugin/builtin/builtin.go Updates builtin plugin registration to pass filesystem config
cli/go.mod Updates dependency versions for input methods and moves dag dependency
cli/cmd/setup/setup_test.go Adds comprehensive tests for working directory setup and updates existing tests
cli/cmd/setup/setup_filesystem_config.go Refactors filesystem config setup with options pattern and working directory support
cli/cmd/setup/setup.go Renames functions to be public and updates flag references
cli/cmd/setup/hooks/pre_run.go Introduces new hook system with options pattern for setup configuration
cli/cmd/internal/cmd/flags.go Centralizes flag name constants including new working directory flag
cli/cmd/cmd.go Migrates to new hook system and adds working directory flag
cli/cmd/add/component-version/cmd.go Implements smart working directory defaulting based on constructor file location

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread cli/cmd/setup/setup_test.go
Comment thread cli/cmd/setup/setup_filesystem_config.go
Comment thread cli/cmd/setup/setup.go
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/add/component-version/cmd.go Outdated
Comment thread cli/cmd/internal/cmd/flags.go Outdated
Comment thread cli/cmd/setup/hooks/pre_run.go Outdated
Comment thread cli/cmd/setup/hooks/pre_run.go Outdated
Comment thread cli/cmd/setup/hooks/pre_run.go
Comment thread cli/cmd/setup/hooks/pre_run.go Outdated
Comment thread cli/cmd/add/component-version/cmd.go
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
AOn-behalf-of: SAP <matthias.bruns@sap.com>

Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
@jakobmoellerdev jakobmoellerdev enabled auto-merge (squash) August 21, 2025 16:06
@jakobmoellerdev jakobmoellerdev merged commit d1dd265 into open-component-model:main Aug 22, 2025
17 checks passed
@matthiasbruns matthiasbruns deleted the feat/565_relative_file_pointers_dir_input branch August 22, 2025 07:20
jakobmoellerdev added a commit that referenced this pull request Aug 25, 2025
<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it

- Refactored working directory handling
- Improved CLI flag precedence logic to ensure CLI flag values override
other configurations effectively.
- Removed hooks and builder logic to reduce complexity and redundancy.
- Enhanced unit test to validate new working directory and filesystem
setup logic is actually set in filesystem context

These changes improve reliability and simplify the implementation of
filesystem configuration while ensuring proper value precedence and
behavior. They also fixed a bug in the filesystem config defaulting not
applying to the context.

#### Which issue(s) this PR fixes
<!--
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
-->

follow up to
#591

---------

Signed-off-by: Jakob Möller <jakob.moeller@sap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature new feature, enhancement, improvement, extension size/l Large size/m Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make file and dir inputs support relative paths

3 participants