adi

package module
v0.0.0-...-6ce4394 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(input []string) string

Types

type Data

type Data struct {
	Groups []Group
	Hosts  []HostVars
}

func (Data) GenerateJSON

func (data Data) GenerateJSON() (bytes.Buffer, error)

type Group

type Group struct {
	ID         primitive.ObjectID `bson:"_id,omitempty"`
	Children   []string           `bson:"children"`
	Datacenter string             `bson:"datacenter"`
	Name       string             `bson:"name"`
	Hosts      []string           `bson:"hosts"`
	Vars       map[string]interface{}
}

type HostVars

type HostVars struct {
	ID   primitive.ObjectID `bson:"_id,omitempty"`
	Name string             `bson:"name"`
	Vars map[string]interface{}
}

type MongoDB

type MongoDB struct {
	Client *mongo.Client
	Ctx    context.Context
	DB     *mongo.Database

	// Add fields for collections here
	Collection *mongo.Collection
}

MongoDB connection struct

func MDb

func MDb(ctx context.Context, uri, dbName string, collection string) (*MongoDB, error)

MDb creates a new MongoDB connection

func (*MongoDB) Close

func (db *MongoDB) Close() error

Close closes the MongoDB connection

func (*MongoDB) Getgroups

func (db *MongoDB) Getgroups(group string, host bool) ([]Group, error)

func (*MongoDB) Gethosts

func (db *MongoDB) Gethosts(host string, collection string) ([]HostVars, error)

func (*MongoDB) Hostgroup

func (db *MongoDB) Hostgroup(group string, dc string) ([]string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL