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

Yaml Fudgefile #59

Open
jayvdb opened this issue Jun 20, 2019 · 8 comments
Open

Yaml Fudgefile #59

jayvdb opened this issue Jun 20, 2019 · 8 comments

Comments

@jayvdb
Copy link
Contributor

jayvdb commented Jun 20, 2019

Cue debate ...

@Badgerati
Copy link
Owner

While I have no objection to using YAML, there's a slight hitch in that PowerShell has no direct YAML support.

We could use the YamlDotNet library if we go ahead.

@jayvdb
Copy link
Contributor Author

jayvdb commented Jun 21, 2019

Linky for topic http://dbadailystuff.com/a-brief-introduction-to-yaml-in-powershell

I guess that means you think Fudge should be dependency free?

As I understand it, vendoring in Powershell is incredibly easy.

There is PSYaml and powershell-yaml , which could be added to nuget.org and choco , so they can be explicit dependencies in the Fudge nuspec .

And there is https://www.nuget.org/packages/PowerYaml/ , which is https://github.com/scottmuc/PowerYaml , and fork https://github.com/cdhunt/PowerYaml , also looking rather moribund, but sounds like what you mean by YamlDotNet.

@jayvdb
Copy link
Contributor Author

jayvdb commented Jun 21, 2019

Interesting discussion , and topical comment at PowerShell/PowerShell#3607 (comment)

@Badgerati
Copy link
Owner

Aye, I've seen the issue, and I hope they add in support for PS7.

I have no issue having dependencies, but for this using the dll directly is likely easier.

Also, since this could be marked for a 2.0 release if we remove json altogether, I'm considering making Fudge a proper module and moving it to PowerShell Gallery (away from choco). This way dependencies would be easier, and I could make this work on nix as well. 🤔

@Badgerati
Copy link
Owner

From #42: Perhaps better has .psd1 and hashtable format?

@jayvdb
Copy link
Contributor Author

jayvdb commented Jun 22, 2019

Excuse my limited experience with powershell syntax; if I recall correctly, hashtables (and PS typically) can not have trailing commas . c.f. PowerShell/PowerShell#8873

This makes it undesirable as a descriptive format (use for state changes; config; etc) in the modern era of DVCS, as minor additions and removals require changes of surrounding lines, breaking 'blame' unnecessarily (or people resort to the ugly comma-first trick).

.psd1 is better than .json in many respects, especially if compared to embedding Powershell code into .json values which contain strings which are supposed to be melded into a CreateProcess lpCommandLine string. Also it makes sense for a PowerShell tool to support .psd1 config, as that is effectively the same as passing a memory object into the relevant functions.

But as alternatives to YAML: XML , TOML, HCL and INI are the common place formats which come to mind. Lots of others are interesting. https://news.ycombinator.com/item?id=18023105 The other one not usually included is Lua - a code as config language that is actually truly sandboxable, with trailing comma support.

@Badgerati
Copy link
Owner

Badgerati commented Jun 22, 2019

Excuse my limited experience with powershell syntax; if I recall correctly, hashtables (and PS typically) can not have trailing commas

Functions and Arrays can't have them, but that's about it off the top of my head. Hashtables are effectively just JSON, but you can more easily embed scripts into them - and there are no commas or semi-colons:

@{
    Scripts = @{
        Pre = @{
            Install = { ./script.ps1 }
        }
    }
    Packages = @(
        @{
            Name = 'curl'
            Version = 'latest'
        }
    )
}

So this would make .psd1 a far more suitable format for Fudge, being a PowerShell tool.

@jayvdb
Copy link
Contributor Author

jayvdb commented Jun 23, 2019

and there are no commas

ok, looks good.

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

2 participants