Skip to content

(dsc): Support credentials, acceptLicense and PSGallery registration #2049

Description

@Gijsreyn

Summary of the new feature / enhancement

The DSC resources cannot express three things that the underlying cmdlets support and that are needed in real deployments:

  1. Credentials. Register-PSResourceRepository -CredentialInfo and Install-PSResource -Credential are not modelled, so a private feed (Azure Artifacts, GitHub Packages, an internal NuGet server) cannot be used from a configuration.
  2. acceptLicense. Install-PSResource -AcceptLicense is not passed, so a module that requires license acceptance fails during set with exit code 4.
  3. PSGallery registration. Register-PSResourceRepository -PSGallery is a separate parameter set. Declaring { name: PSGallery } in a Repository instance on a machine where it was unregistered fails, because the script always calls Register-PSResourceRepository -Name -Uri.

Example of what this could look like:

resources:
- name: Internal feed
  type: Microsoft.PowerShell.PSResourceGet/Repository
  properties:
    name: Internal
    uri: https://pkgs.dev.azure.com/contoso/_packaging/internal/nuget/v3/index.json
    trusted: true
    credentialInfo:
      vaultName: ContosoVault
      secretName: InternalFeedPat
- name: Modules
  type: Microsoft.PowerShell.PSResourceGet/PSResourceList
  properties:
    repositoryName: Internal
    acceptLicense: true
    resources:
    - name: Contoso.Tools

Proposed technical implementation details (optional)

  • Repository: add an optional credentialInfo object (vaultName, secretName) mapped to -CredentialInfo on register and set, and handle name: PSGallery without uri by calling Register-PSResourceRepository -PSGallery.
  • PSResourceList: add an optional acceptLicense boolean passed to Install-PSResource -AcceptLicense, and allow credential via SecretManagement rather than plain text in the configuration.
  • Never emit secrets in get, test or export output; return only the vault and secret names.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions