Comments (5)
If git.exe
is available, we can retrieve this information using git rev-parse --show-toplevel
. I like the idea of letting Git own that task. Maybe there is a way to integrate?
from dsc.
@nkalayci is working on a project where the "nxScript" resource has been used. I think she could help us understand how customers reference commands that are not in path.
from dsc.
A normative pattern for this problem in other higher-order tools is to use something like a File
resource to put content in a deterministic location on the managed nodes. Models differ on implementation:
- With Puppet's
file
resource, a user can specify the contents of the file in their config or reference a URI to retrieve the content from. Puppet uses thepuppet://
URI to reference content shipped in a Puppet module (the normative way to ship config groups). - Chef has the
file
resource for defining content directly or from managed-machine-local files, thecookbook_file
resource to copy files from a chef cookbook (similar to using Puppet'sfile
resource with apuppet://
URI), thetemplate
resource for templated content, and theremote_file
resource for copying remote files. - Ansible has the
builtin.template
andwindows.win_template
modules for creating files from templated content, thebuiltin.copy
/windows.win_copy
modules for copying files from local/remote machines, and thebuiltin.get_url
/windows.win_get_url
modules for copying files from URIs.
In the Ansible model, when using copy
or win_copy
, you can specify a local absolute or relative path for the source. When the path is relative, it's relative to the Ansible playbook (which for us is analogous to being relative to the DSC Configuration document).
I'm not against the idea of adding a built-in variable like $DSCConfigRoot
, but I wonder if the semantics of "relative paths handled by DSC itself1 are always relative to the configuration document" is better or worse. Alternatively, relative paths could always be relative to the current working directory, which is in line with how CLI tools generally behave. In that case, the $DSCConfigRoot
(or similar) variable would unambiguously identify a location, but only when DSC is getting the configuration from a file, not from stdin.
Footnotes
-
As opposed to relative paths handled by a DSC Resource. We probably want to standardize on guidance for how DSC Resources should handle relative paths. Most of the time, "relative to the DSC Resource executable" probably doesn't make sense. ↩
from dsc.
I think that the danger of simply using relative paths is that all resources need to be aware of this, as does the caller. Allowing for something like [builtin('DSCConfigRoot')]/file.txt
would make the path absolute, preventing resources from accidentally using a CWD relative path and/or DSC from needing to have path
as a property type.
If a config has a parameter which is itself a path, what is the expectation here (please forgive my lack of knowledge on the exact CLI syntax for dsc
):
C:\User\Foo> dsc config D:\config.yaml --parameter bar=.\parameterIsPath
Even this usage is suspect, but at least has a chance that the CWD will flow properly to wherever the parameter is consumed and result in C:\User\Foo\parameterIsPath
(which would be my expectation as a user) rather than D:\parameterIsPath
(which would surprise me given the invocation circumstance).
from dsc.
WG discussed this and proposes a new env var created by dsc.exe
called DSCConfigRoot
which contains the directory of the currently executing config file. The PowerShell group resource (and any other language group resource) would need to know to expand this before passing to resources:
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json
resources:
- name: Use class PowerShell resources
type: DSC/PowerShellGroup
properties:
resources:
- name: foo
type: PsDesiredStateConfiguration/MSFT_File
properties:
Path: $env:DSCConfigRoot/bar/baz
In the future, for non-group used resources, we can have a function to resolve environment variables getEnvironmentVariable()
.
from dsc.
Related Issues (20)
- Passing params/references to groups/adapters HOT 3
- allow specifying version, signature, hash of resource HOT 3
- Unable to reuse `reference()` in set operation from get and test
- The `int()` function incorrectly handles non-integer numbers HOT 4
- Update `dsc --version` to include build info
- Resources in parallel unless dependson HOT 4
- Create JSON/YAML for configs that only use /*powershell adapter, from PowerShell script HOT 1
- Installing resources HOT 1
- localization support
- Include metadata in result objects HOT 2
- Some static-analysis support HOT 1
- Intent for this implementation - will it only be an Intermediate language? HOT 3
- Extend exitCodes to support Hexidecimal error codes HOT 1
- Add tests for canonical schemas
- `IncludeGroup` to include an external configuration HOT 5
- Enable `dsc config resolve` for included configs HOT 2
- Install PowerShell7 resource HOT 6
- Long running mode for DSC HOT 2
- Resource to manage Windows env vars HOT 1
- Define semantic exit codes for the PowerShell adapters HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dsc.