Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

publiccode.yml parser library and validator in Go

License

NotificationsYou must be signed in to change notification settings

italia/publiccode-parser-go

Repository files navigation

Join the #publiccode channelGet invited

A Go parser and validator forpubliccode.ymlfiles.

publiccode.yml is an international standard for describing public software, whichshould be placed at the root of Free/Libre and Open Source software repositories.

This parser performs syntactic and semantic validation according to theofficial spec.

Features

  • Go library and CLI tool (publiccode-parser)
  • Supports the latest version of thepubliccode.yml Standard
  • publiccode-parser can output validation errors as JSON or inerrorformatfriendly way
  • Verifies the existence of URLs by checking the response for URL fields(can be disabled)

As a library

parser,err:=publiccode.NewDefaultParser()// error handlingpubliccode,err:=parser.Parse("file:///path/to/local/dir/publiccode.yml")// OR// parse.Parse("https://github.com/example/example/publiccode.yml")

Go Reference

From command line

Thepubliccode-parser binary can be used to validate apubliccode.ymlfrom the command line.

To get the latest version use:

go install github.com/italia/publiccode-parser-go/v5/publiccode-parser@latest

Or get a precompiled package from therelease page

Example:

$ publiccode-parser mypubliccode.ymlpubliccode.yml:36:1: error: developmentStatus: developmentStatus must be one of the following:"concept","development","beta","stable" or"obsolete"publiccode.yml:48:3: warning: legal.authorsFile: This key is DEPRECATED and will be removedin the future. It's safe to drop itpubliccode.yml:12:5: warning: description.en.genericName: This key is DEPRECATED and will be removed in the future. It's safe to drop it

Runpubliccode-parser --help for the available command line flags.

The tool returns 0 in case of successful validation, 1 otherwise.

With Docker

You can easily validate your files using Docker on your local machine or in yourCI pipeline:

docker run -i italia/publiccode-parser-go /dev/stdin< publiccode.yml

The image is available onDockerhub.You can also build your own running:

docker build -t italia/publiccode-parser-go.

Examples

Click to expand

The examples assume that yourpubliccode.yml file is on your local machine,at/opt/publiccodes/publiccode.yml

  • Validate and print the canonicalized file

    docker run -i italia/publiccode-parser-go -export /dev/stdout /dev/stdin< publiccode.yml
  • Validate a publiccode file namedpubliccode.yml in/home/user

    docker run -v /home/user:/go/src/files italia/publiccode-parser-go
  • Validate a publiccode file named/opt/publiccodes/my-amazing-code.yaml

    docker run -v /opt/publiccodes:/go/src/files italia/publiccode-parser-go my-amazing-code.yaml
  • Validatepubliccode.yml without using the network (fe. checking URLs are reachable)

    docker run -v /opt/publiccodes/publiccodes:/files italia/publiccode-parser-go -no-network publiccode.yml
  • Debugging, access the container interactive shell, overriding the entrypoint

    docker run -it --entrypoint /bin/sh italia/publiccode-parser-go

Contributing

Contributing is always appreciated.Feel free to open issues, fork or submit a Pull Request.If you want to know more about how to add new fields, check out thepubliccode.yml projectand itsCONTRIBUTING.mdguidelines.

See also

Maintainers

This software is maintained by community contributors.

License

© 2018-present Team per la Trasformazione Digitale - Presidenza del Consigliodei Ministri

Licensed under the EUPL 1.2.The version control system provides attribution for specific lines of code.

About

publiccode.yml parser library and validator in Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors15

Languages


[8]ページ先頭

©2009-2025 Movatter.jp