config

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorExtension = errors.New("extension must be either 'hcl' or 'json'")
)

Functions

func Write

func Write(w io.Writer, extension string, root *Root) error

Write info to do

func WriteFile

func WriteFile(filename, format string, root *Root) (string, error)

WriteFile returns outcome file and error just in case

func WriteHCL

func WriteHCL(w io.Writer, root *Root) error

WriteHCL the config in that language

func WriteJSON

func WriteJSON(w io.Writer, root *Root) error

WriteJSON config in json

Types

type AliasService

type AliasService Service

type Association

type Association struct {
	ID   string `hcl:"id" json:"id"`
	Type string `hcl:"type" json:"type"`
}

Association for any item

type AssociationType

type AssociationType int
const (
	Contains AssociationType = iota
	Egress
	Ingress
)

func (AssociationType) String

func (i AssociationType) String() string

type Datacenter

type Datacenter struct {
	Name        string `hcl:"name,label" json:"-"`
	Description string `hcl:"description" json:"description"`
	Default     bool   `hcl:"default,optional" json:"default"`
}

Datacenter entity

func (*Datacenter) FQDN

func (dc *Datacenter) FQDN() string

FQDN - Name

type Meta

type Meta struct {
	Role     string   `hcl:"role,optional" json:"role,omitempty"`
	Version  string   `hcl:"version,optional" json:"version,omitempty"`
	Software string   `hcl:"software,optional" json:"software,omitempty"`
	Extra    hcl.Body `hcl:",remain" json:"extra,omitempty"`
}

Meta information

type Resource

type Resource struct {
	Type         string        `hcl:"type,label" json:"-"`
	Name         string        `hcl:"name,label" json:"-"`
	Associations []Association `hcl:"association,block"`
	Location     string        `hcl:"location,optional" json:"location"`
}

Resource (load balancers)

func (*Resource) FQDN

func (r *Resource) FQDN() string

type ResourceType

type ResourceType int
const (
	Firewall ResourceType = iota
	LoadBalancer
	ServicePool
	ConsulCluster
	ConsulServer
	ConsulClient
)

func (ResourceType) String

func (i ResourceType) String() string

type Root

type Root struct {
	Datacenters []*Datacenter `hcl:"datacenter,block"`
	Resources   []*Resource   `hcl:"resource,block"`
	Services    []*Service    `hcl:"service,block"`
}

Root document and elements

func AddConsul

func AddConsul(root *Root) (*Root, error)

AddConsul to the topology per Region

func Parse

func Parse(r io.Reader, filename, extension string) (*Root, error)

Parse parses the configuration from hcl or json

func ParseFile

func ParseFile(filename string) (*Root, error)

ParseFile gets the io.Reader and the extension of the file

func (*Root) MarshalJSON

func (r *Root) MarshalJSON() ([]byte, error)

MarshalJSON to be compatible with the reader

type RootJSON

type RootJSON struct {
	Datacenter map[string]*Datacenter          `json:"datacenter"`
	Resources  map[string]map[string]*Resource `json:"resource"`
	Services   map[string]map[string]*Service  `json:"service"`
}

RootJSON : This should be the format supported

type Service

type Service struct {
	Type     string `hcl:"type,label" json:"-"`
	Name     string `hcl:"name,label" json:"-"`
	Port     int    `hcl:"port,optional" json:"port,omitempty"`
	Address  string `hcl:"address,optional" json:"address,omitempty"`
	Protocol string `hcl:"protocol,optional" json:"protocol,omitempty"`
	Meta     []Meta `hcl:"meta,block" json:"meta,omitempty"`
}

Service (representation of local stuff)

func (*Service) MarshalJSON

func (s *Service) MarshalJSON() ([]byte, error)

type ServiceJSON

type ServiceJSON struct {
	Meta interface{} `json:"meta,omitempty"`
	*AliasService
}

type X

type X struct{}

Jump to

Keyboard shortcuts

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