Skip to content

refactor(fs): replace process-wide os.Chdir with explicit base path - #1273

Open
ManthanNimodiya wants to merge 1 commit into
kitops-ml:mainfrom
ManthanNimodiya:refactor/explicit-base-path
Open

refactor(fs): replace process-wide os.Chdir with explicit base path#1273
ManthanNimodiya wants to merge 1 commit into
kitops-ml:mainfrom
ManthanNimodiya:refactor/explicit-base-path

Conversation

@ManthanNimodiya

Copy link
Copy Markdown

Description

This PR addresses #1269 by eliminating process-wide os.Chdir calls in pack, unpack, and kitimport operations in favor of explicit base paths.

Changing the process working directory via os.Chdir mutated the caller's working directory and prevented safe concurrent execution.

Key Changes

  • Pack pipeline: Added ContextDir to SaveModelOptions in local-storage.go; updated tar and raw layer writers to resolve and walk paths relative
    to contextDir. Removed os.Chdir from pkg/cmd/pack/cmd.go and pkg/cmd/kitimport/util.go.
  • Unpack pipeline: Removed os.Chdir from UnpackModelKit and unpackRemote in core.go. Layers are now explicitly extracted and verified into
    target unpack destinations.
  • Tests: Added TestPackUnpack_PreservesWorkingDir in pack-unpack_test.go verifying that neither kit pack nor kit unpack alters the process
    working directory.

Testing

  • go test ./pkg/... passed
  • go test ./... passed (including all integration tests in testing/)

Fixes #1269

Fixes kitops-ml#1269

Signed-off-by: ManthanNimodiya <manthannimodiya989898@gmail.com>
@ManthanNimodiya

ManthanNimodiya commented Sep 3, 2026

Copy link
Copy Markdown
Author

@amisevsk, @bmicklea have a look when you get time

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.

Replace process-wide os.Chdir in pack/unpack/import with an explicit base path

1 participant