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 platforms, lifecycles, and toolchains YAML files #142

Closed
samrocketman opened this issue Dec 5, 2021 · 5 comments
Closed

Support for platforms, lifecycles, and toolchains YAML files #142

samrocketman opened this issue Dec 5, 2021 · 5 comments
Milestone

Comments

@samrocketman
Copy link
Owner

samrocketman commented Dec 5, 2021

JSON has been great... but YAML is more flexible and user-friendly than JSON for admins to add support.

JSON will always be supported for compatibility. However, it would be nice to have YAML as an option.

Example JSON files.

  • platforms.json
  • lifecycles-ubuntu1604-stable.json
  • toolchains-ubuntu1604-stable.json

And the same purpose files but in YAML.

  • platforms.yaml
  • lifecycles-ubuntu1604-stable.yaml
  • toolchains-ubuntu1604-stable.yaml

This is becomes more important as support for documentation generation gets implemented in the future. Refer to issue #139.

@samrocketman samrocketman pinned this issue Jan 23, 2022
@samrocketman
Copy link
Owner Author

With upcoming 2.0 release YAML will be the primary format going forward. JSON support for backwards compatibility.

@samrocketman samrocketman added this to the jervis-2.0 milestone Dec 19, 2022
@samrocketman
Copy link
Owner Author

https://github.com/samrocketman/jervis/blob/main/vars/hasGlobalResource.groovy was added for this purpose. e.g. detect YAML or fall back to JSON.

@samrocketman
Copy link
Owner Author

8da9edc hasGlobalResource enables this.

@samrocketman
Copy link
Owner Author

samrocketman commented Jun 24, 2023

Convert platforms JSON to YAML

import net.gleske.jervis.tools.YamlOperator

String prefix = 'resources'

Map platforms = YamlOperator.loadYamlFrom(new File("${prefix}/platforms.json"))

println "Writing to '${prefix}/platforms.yaml'"
new File("${prefix}/platforms.yaml").withWriter { w ->
    w << YamlOperator.writeObjToYaml(platforms)
}

platforms.supported_platforms.collect { platform, oses ->
    [
        ['lifecycles', 'toolchains'],
        oses.collect { os, v ->
            [
                "${os}-stable",
                "${os}-unstable"
            ]
        }.flatten()
    ].combinations()*.join('-')
}.flatten().sort().unique().each { fileName ->
    if(!(new File("${prefix}/${fileName}.json").exists())) {
        // skip; unstable version doesn't likely exist
        return
    }
    println "Writing to '${prefix}/${fileName}.yaml'"
    new File("${prefix}/${fileName}.yaml").withWriter { w ->
        Map json = YamlOperator.loadYamlFrom(new File("${prefix}/${fileName}.json"))
        json.clone().each { top, v1 ->
            if(top == 'toolchains') {
                return
            }
            v1.clone().each { child, v2 ->
                if(v2 in List) {
                    json[top][child] = v2.join('\n')
                }
            }
        }
         w << YamlOperator.writeObjToYaml(json)
    }
}

null

@samrocketman
Copy link
Owner Author

Closed by 8c93204

@samrocketman samrocketman unpinned this issue Jun 25, 2023
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