Skip to content

Change reference() to use the raw output of a resource #634

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

Merged
merged 4 commits into from
Feb 5, 2025

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Feb 4, 2025

PR Summary

As discussed, reference() now refers to the raw output of a prior resource invocation and not the decorated one that comes from DSC engine. This is because the decoration is different for get, set, test, and export such that use of this function means you can't use the same config for both get and test, for example.

Had to update version of tree-sitter to get past the failures in CI but not locally (also updated some other crates)

Also renamed an internal member to references instead of outputs so that the comment is no longer needed.

We'll defer the ability to access the decorated output as it's additive and not breaking until we have a real scenario to need it.

PR Context

Fix #389

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • dsc/tests/dsc_reference.tests.ps1: Language not supported
Comments suppressed due to low confidence (1)

dsc_lib/src/functions/reference.rs:33

  • The error message should be updated to specify that the key was not found in 'references' instead of 'outputs'.
Err(DscError::Parser(t!("functions.reference.keyNotFound", key = key).to_string()))

$out = dsc config get -f $PSScriptRoot/../examples/reference.dsc.yaml | ConvertFrom-Json
It 'Reference works for <operation>' -TestCases @(
@{ operation = 'get' },
@{ operation = 'test' }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any tests for reference with set and export?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at this time, will add later

@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Feb 5, 2025
Merged via the queue into PowerShell:main with commit 894d88d Feb 5, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the reference-raw branch February 5, 2025 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to reuse reference() in set operation from get and test
2 participants