Giter Club home page Giter Club logo

Comments (5)

mgreenegit avatar mgreenegit commented on July 28, 2024

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.

mgreenegit avatar mgreenegit commented on July 28, 2024

@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.

michaeltlombardi avatar michaeltlombardi commented on July 28, 2024

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:

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

  1. 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.

JohnMcPMS avatar JohnMcPMS commented on July 28, 2024

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.

SteveL-MSFT avatar SteveL-MSFT commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.