GithubHelp home page GithubHelp logo

relex / aini Goto Github PK

View Code? Open in Web Editor NEW
95.0 9.0 11.0 83 KB

Go library for Parsing Ansible inventory files

License: MIT License

Go 99.18% Makefile 0.82%
ansible ansible-inventory golang go parser parser-library

aini's People

Contributors

bemyak avatar jiping-s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aini's Issues

"ungrouped" always contains all hosts even though they belong to another group.

Hi,

great library!

For my use case I don't need "all" and "ungrouped" - so its not a major thing for me BUT...

I am iterating over the groups and outputting all group names and their respective hosts, I noticed that ungrouped is output with all hosts. According to the docs at ansible, ungrouped should only contain hosts that don't belong to any other group.

Here is a short sample of my quick and dirty method for demonstrating..

	for _, g := range inventory.Groups {
		_, _ = datawriter.WriteString("[" + g.Name + "]\n")
		for _, h := range g.Hosts {
			_, _ = datawriter.WriteString(h.Name + "\n")

.....

So basically I get a list of groups and their respective hosts, works great! But I also get an "ungrouped" group but it contains ALL hosts

Is this correct? I would have suspected that it should be empty as all my hosts belong to another group.

Thanks in advance

How to use your library in go < 1.16?

I'm on a mainstream release that only supports Go 1.15. It seems that your library has a go 1.16 dependency somewhere given the error when trying to get the library installed:

go get github.com/relex/aini
package io/fs: unrecognized import path "io/fs": import path does not begin with hostname

Can you consider making the library compatible to Go versions < 1.16?
(not sure how much you depend on io/fs, but if you could remove the dependency without huge effort would be great?)

Host ranges not working as expected

I stumbled upon your library when working on a little inventory CLI and I think I found an error.

To illustrate I wrote a minimal example:

package main

import (
	"fmt"
	"strings"

	"github.com/relex/aini"
)

func main() {
	// Load from string example
	inventoryReader := strings.NewReader(`foo-[1:2]-[a:c]-bar`)
	inventory, _ := aini.Parse(inventoryReader)

	for host, _ := range inventory.Hosts {
		fmt.Println(host)
	}
}

The output of this when run through go run main.go is as follows:

foo-1-[a:c]-bar
foo-2-[a:c]-bar

I think this is incorrect and should result in this output instead:

foo-1-a-bar
foo-1-b-bar
foo-1-c-bar
foo-2-a-bar
foo-2-b-bar
foo-2-c-bar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.