Skip to content

Make Microsoft.Windows/Registry idiomatic #162

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

Closed
michaeltlombardi opened this issue Aug 22, 2023 · 0 comments · Fixed by #206
Closed

Make Microsoft.Windows/Registry idiomatic #162

michaeltlombardi opened this issue Aug 22, 2023 · 0 comments · Fixed by #206
Assignees
Labels
Issue-Enhancement The issue is a feature or idea

Comments

@michaeltlombardi
Copy link
Collaborator

Summary of the new feature / enhancement

As a user, I want the Microsoft.Windows/Registry resource to behave idiomatically, returning a representation of the current state that matches the instance schema.

The resource currently returns the following JSON representations from registry config get:

  • For a key that exists:

    {
      "$id": "https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json",
      "keyPath": "HKCU\\example"
    }
  • For a key that doesn't exist:

    {
      "$id": "https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json",
      "keyPath": ""
    }
  • For a value that exists:

    {
      "$id": "https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json",
      "keyPath": "HKCU\\example\\subkey",
      "valueName": "NewKeyAndValue",
      "valueData": {
        "String": "No errors"
      }
    }
  • For a value that doesn't exist, registry config get errors with exit code 3:

    Error getting config: The registry key or value name does not exist.: Failed to query registry value

Proposed technical implementation details (optional)

The idiomatic representation of the resource instance should always include the keyPath, even when the key doesn't exist. The instance should use the value of the _ensure property to indicate whether the instance is present or absent.

The idiomatic representations for an instance are:

  • For a key that exists:

    {
      "$id": "https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json",
      "_ensure": "Present",
      "keyPath": "HKCU\\example"
    }
  • For a key that doesn't exist:

    {
      "$id": "https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json",
      "_ensure": "Absent",
      "keyPath": "HKCU\\example"
    }
  • For a value that exists:

    {
      "$id": "https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json",
      "_ensure": "Present",
      "keyPath": "HKCU\\example\\subkey",
      "valueName": "NewKeyAndValue",
      "valueData": {
        "String": "No errors"
      }
    }
  • For a value that doesn't exist:

    {
      "$id": "https://developer.microsoft.com/json-schemas/windows/registry/20230303/Microsoft.Windows.Registry.schema.json",
      "_ensure": "Absent",
      "keyPath": "HKCU\\example\\subkey",
      "valueName": "NewKeyAndValue"
    }

This would enable users and integrating tools to reason about the state of the instance without having to know that an empty string for keyPath indicates that the key doesn't exist.

@michaeltlombardi michaeltlombardi added the Issue-Enhancement The issue is a feature or idea label Aug 30, 2023
@SteveL-MSFT SteveL-MSFT self-assigned this Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement The issue is a feature or idea
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants