Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propperly root SetupEnvironment variables with file system paths at run time #6850

Merged
merged 1 commit into from Aug 27, 2019

Conversation

@mwrock
Copy link
Contributor

commented Aug 14, 2019

Fixes #6483 and implements design specified in #6837

This PR introduces a new arg -IsPath to all of the environment functions in Invoke-SetupEnvironment. When setting or pushing values to the environment with IsPath set, it will be understood that the environment variable includes paths. When these values are saved to the metadata files, they will be stripped of the studio root prefix. For example if $pkg_prefix is at c:\hab\studios\work\hab\pkgs\origin\package\version\release, the following:

function Invoke-SetupEnvironment {
    Push-RuntimeEnv -IsPath "PSModulePath" "$pkg_prefix\Modules"
}

will add \hab\pkgs\origin\package\version\release\Modules to PSModulePath stripping away c:\hab\studios\work.

When these values are consumed by the supervisor or the cli, they will have the FS_ROOT of their current environment prefixed. So in a local windows studio, c:\hab\studios\work would be prepended but in a non-studio environment, it would remain \hab\pkgs\origin\package\version\release\Modules.

This allows paths set in Invoke-SetupEnvironment and that point to the hab file system to be portable across environments.

Signed-off-by: mwrock matt@mattwrock.com

@mwrock mwrock self-assigned this Aug 14, 2019
@chef-expeditor

This comment has been minimized.

Copy link

commented Aug 14, 2019

Hello mwrock! Thanks for the pull request!

Here is what will happen next:

  1. Your PR will be reviewed by the maintainers.
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!


# Finally, return the path
$path
}

This comment has been minimized.

Copy link
@mwrock

mwrock Aug 14, 2019

Author Contributor

This function was dead code. Callers were removed in 30248d4#diff-286d17c574b12110264d8a48b995792f

@mwrock mwrock force-pushed the path_env branch 2 times, most recently from 533179e to 5cd187f Aug 20, 2019
@@ -106,7 +106,7 @@ function Invoke-Build([string]$Path, [switch]$Clean, [string]$Command, [switch]$
$nightly = ($toolchain -eq "nightly")
Push-Location $PSScriptRoot
try {
& $PSScriptRoot\test\run_cargo_test.ps1 -Component (Get-Component $path) -Features $Features -TestOptions $TestOptions -Nightly:$nightly
& $PSScriptRoot\.expeditor\scripts\verify\run_cargo_test.ps1 -Component (Get-Component $path) -Features $Features -TestOptions $TestOptions -Nightly:$nightly

This comment has been minimized.

Copy link
@mwrock

mwrock Aug 23, 2019

Author Contributor

fallout from recent script cleanup


function Invoke-Verify {}

function Invoke-Unpack {}

This comment has been minimized.

Copy link
@mwrock

mwrock Aug 23, 2019

Author Contributor

we use to have to provide empty functions and a dummy source file. We don't need to do that anymore.

@mwrock mwrock marked this pull request as ready for review Aug 23, 2019
Copy link
Contributor

left a comment

Very nice

Copy link
Contributor

left a comment

The only part I feel confident in reviewing is the Rust code. That looks great! I just had a few minor potential cleanups.

components/core/src/package/install.rs Outdated Show resolved Hide resolved
components/core/src/package/install.rs Outdated Show resolved Hide resolved
components/core/src/package/install.rs Outdated Show resolved Hide resolved
components/core/src/package/install.rs Outdated Show resolved Hide resolved
@mwrock

This comment has been minimized.

Copy link
Contributor Author

commented Aug 23, 2019

great comments @davidMcneil I have applied them all.

@mwrock mwrock force-pushed the path_env branch from 5f488ea to db4445b Aug 24, 2019
…un time

Signed-off-by: mwrock <matt@mattwrock.com>
@mwrock mwrock force-pushed the path_env branch from db4445b to ceb2240 Aug 27, 2019
@mwrock mwrock merged commit e9feebe into master Aug 27, 2019
5 checks passed
5 checks passed
DCO This commit has a DCO Signed-off-by
Details
buildkite/habitat-sh-habitat-master-verify Build #3249 passed (39 minutes, 19 seconds)
Details
buildkite/habitat-sh-habitat-master-website Build #370 passed (46 seconds)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
expeditor/config-validation Validated your Expeditor config file
Details
@mwrock mwrock deleted the path_env branch Aug 27, 2019
@robbkidd

This comment has been minimized.

Copy link
Collaborator

commented Aug 31, 2019

I can't speak to the implementation, but as an author of plans, I've been using this bugfix/feature all week from an experimental channel and I freaking love it.

all of my love

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.