Giter Club home page Giter Club logo

Comments (8)

SteveL-MSFT avatar SteveL-MSFT commented on September 2, 2024

If I understand what you're trying to do, you want to use a resource that takes a single value and be able to specify an array so that single resource gets used for each element in the array? Basically like a pipeline?

from dsc.

Gijsreyn avatar Gijsreyn commented on September 2, 2024

If I understand what you're trying to do, you want to use a resource that takes a single value and be able to specify an array so that single resource gets used for each element in the array? Basically like a pipeline?

Exactly, the copying part is the key here.

from dsc.

michaeltlombardi avatar michaeltlombardi commented on September 2, 2024

I think this could potentially be solved with a group resource, rather than a configuration document engine feature. Something like...

$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
  - name: Use class PowerShell resources
    type: Microsoft.DSC/PowerShell
    properties:
      resoureces:
      - name: Create several groups 
        type: MyPsDscResources/Multiple:
        properties:
          ResourceType: PSDscResources/Group
          SharedDefaultProperties:
            Ensure: Present
          InstanceProperties:
          - GroupName: Group1
            Members: User1, User2
          - GroupName: Group2
            Members: User1, User3, User4

To use a group like this with adapted resources, you would want an adapted group - otherwise you would end up generating multiple instances of the PowerShell adapter and incur that extra overhead.

But it could work similarly for non-adapted resources:

$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Manage registry keys
  type: Microsoft.Dsc/MultiInstance:
  properties:
    type: Microsoft.Windows/Registry
    sharedDefaultProperties:
      _exist: true
      keyPath: HKCU\DSC\Test
    instanceProperties:
    - valueName: Foo
    - valueName: Bar
    - valueName: Baz
      valueData: { String: 'hello world' }
    - keyPath: HKCU\DSC\Test\OverrideDefault

from dsc.

SteveL-MSFT avatar SteveL-MSFT commented on September 2, 2024

The concept makes sense to me and the example from @michaeltlombardi makes sense to me to use a new Group resource. I don't think MultiInstance really describes the usage, maybe Microsoft.DSC/ForEach? Some naming suggestions:

$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Manage registry keys
  type: Microsoft.Dsc/ForEach
  properties:
    type: Microsoft.Windows/Registry
    propertyDefaults:
      _exist: true
      keyPath: HKCU\DSC\Test
    instanceProperties:
    - valueName: Foo
    - valueName: Bar
    - valueName: Baz
      valueData: { String: 'hello world' }
    - keyPath: HKCU\DSC\Test\OverrideDefault

from dsc.

Gijsreyn avatar Gijsreyn commented on September 2, 2024

I get both the points and I definitely agree on the part that there shouldn't be too much overhead. If it solves the goal that the configuration document in itself can be dynamically filled and if it requires looping through the parameter keys to determine how many resources are required to be executed, I would be happy.

If you want me to explain it in more detail in DSC v2 concepts, I have a practical use case of what we've tried to achieve there.

@SteveL-MSFT , Microsoft.DSC/Foreach sounds good to me if it fits in the picture of ARM functionality, meaning if it cannot be solved from ARM functionality that's being built.

from dsc.

SteveL-MSFT avatar SteveL-MSFT commented on September 2, 2024

@Gijsreyn ForEach would probably fit more with Bicep that would generate ARM and eventually we'd like to explore a Bicep extension to output DSC configuration. However, I don't think it would be much effort to create this resource, so I might give it a shot between other work items.

from dsc.

SteveL-MSFT avatar SteveL-MSFT commented on September 2, 2024

Looking into ARM, I see I missed one important detail which is ARM currently supports the idea of copy which was the original request. So if we want to align with ARM, then we would use their syntax rather than invent something new (although the two aren't mutually exclusive). Looking at the ARM example for copy, it doesn't look very user friendly at all...

from dsc.

Gijsreyn avatar Gijsreyn commented on September 2, 2024

Looking into ARM, I see I missed one important detail which is ARM currently supports the idea of copy which was the original request. So if we want to align with ARM, then we would use their syntax rather than invent something new (although the two aren't mutually exclusive). Looking at the ARM example for copy, it doesn't look very user friendly at all...

I fully agree and it might be confusing on the naming when ForEach is used. Something to look into ...

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.