Skip to content
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

Support for deep object merging #30

Open
JakeStanger opened this issue Nov 6, 2023 Discussed in #29 · 0 comments
Open

Support for deep object merging #30

JakeStanger opened this issue Nov 6, 2023 Discussed in #29 · 0 comments

Comments

@JakeStanger
Copy link
Collaborator

Currently object merging only takes the immediate children into account.

There may be utility in changing this, or adding additional syntax, to perform a 'deep merge', running the merge against every child object.

Issue originates from the below discussion, which compares the feature to Nix's 'attrset merge':

Discussed in https://github.com/orgs/corn-config/discussions/29

Originally posted by fbewivpjsbsby November 6, 2023

  1. What version of corn are you using?
    corn-cli 0.9.2
  2. What is your operating system?
    Windows 10

Description

It is like nixos module, config will merge when you imports config, use // operators or use mkMerge.
Corn is override attrsets now.

Steps to reproduce

  1. Write this in corn file:
let {
  $preferences_user_enable = {
    Value = true
    Status = "user"
  }

  // telemetry
  $policies_disable_telemetry = {
    DisableTelemetry = true
    DisableFirefoxStudies = true
  }
  // #TODO 'raw data' need git version corn
  // theme
  $policies_theme = {
    Preferences = {
      'toolkit.legacyUserProfileCustomizations.stylesheets' = $preferences_user_enable
      'layout.css.backdrop-filter.enabled' = $preferences_user_enable
      'widget.non-native-theme.use-theme-accent' = $preferences_user_enable
    }
  }

  $policies_ech = {
    // ech need enable DNS over HTTPS
    DNSOverHTTPS = {
      Enabled =  true
      ProviderURL = "https://1.1.1.1/dns-query"
      Locked = false
      ExcludedDomains = [""]
    }
    Preferences = {
      'network.dns.echconfig.enabled' = $preferences_user_enable
      'network.dns.http3_echconfig.enabled' = $preferences_user_enable
    }
  }
} in
{
  policies = {
    // telemetry
    ..$policies_disable_telemetry
    // ech
    ..$policies_ech
    // theme
    ..$policies_theme
  }
}
  1. run corn [your corn file name].corn -t json It is override by $policies_theme:
{
  "policies": {
    "DisableTelemetry": true,
    "DisableFirefoxStudies": true,
    "DNSOverHTTPS": {
      "Enabled": true,
      "ProviderURL": "https://1.1.1.1/dns-query",
      "Locked": false,
      "ExcludedDomains": [
        ""
      ]
    },
    "Preferences": {
      "toolkit.legacyUserProfileCustomizations.stylesheets": {
        "Value": true,
        "Status": "user"
      },
      "layout.css.backdrop-filter.enabled": {
        "Value": true,
        "Status": "user"
      },
      "widget.non-native-theme.use-theme-accent": {
        "Value": true,
        "Status": "user"
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant