confclient

package module
v0.0.0-...-80d2697 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2016 License: GPL-3.0 Imports: 14 Imported by: 0

README

confclient

Build Status

Example client implementation and template parser for confmgr

confadm Usage

conftpl Usage

Get string variable
conftpl -u http://confmgr:8080 -s somestringkey
conftpl -u http://confmgr:8080 -s somehash/field
conftpl -u http://confmgr:8080 -s somelist/index/0
Template processing
conftpl -u http://confmgr:8080 -t my_template.tmpl > my_template.output
With verification

Note: The "FILE" parameter will be replaced with the parsed template output file

conftpl -u http://confmgr:8080 -t some_xml.tmpl -v -- xmllint --format FILE > some_xml.xml

Building

go get github.com/moensch/confmgr/cmd/conftpl
go get github.com/moensch/confmgr/cmd/confadm

Template functions

  • key "keyName" "defaultValue"
    • Gets a given key, optionally fall back to default value
    • Use "keyName/field" to retrieve hash fields
    • Use "keyName/index/n" to retrieve a list item
  • keyd "keyName" "defaultValue"
    • Same as the above, but it will return a hash with "Value" and "Source" to show value origin
  • list "keyName"
    • Retrieve a list
  • listd "keyName"
    • Same as the above, but each list item will be a hash with "Value" and "Source"
  • listj "keyName" "joinChar"
    • Retrieve a list, but return as a string, joined by "joinChar"
  • hash "keyName"
    • Retrieve a hash
    • Always sets "Source" hash key

Examples

key
Hello: {{key "name" "Stranger"}}
keyd
{{with keyd "name" "Stranger"}}
Hello {{.Value}} (key stored at {{.Source}}
{{end}}
list
{{range list "people"}}
  Hello {{.}}
{{end}}
listd
{{range listd "people"}}
  Hello {{.Value}} (From: {{.Source}})
{{end}}
listj
I welcome the following people: {{listj "people" ", "}}
hash
{{range hash "db_settings"}}
  <!-- From: {{.Source}} -->
  <attr key='{{.Key}}' val='{{.Value}}'/>{{end}}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	TemplateDir string
	ConfigDir   string
	// contains filtered or unexported fields
}

func InitiateClient

func InitiateClient(url string) *Client

func (*Client) AdminDeleteKey

func (c *Client) AdminDeleteKey(keyName string) error

func (*Client) AdminDumpKeys

func (c *Client) AdminDumpKeys(output string) error

func (*Client) AdminGetHashField

func (c *Client) AdminGetHashField(keyName string, fieldName string) (string, error)

func (*Client) AdminGetKeyAsJSON

func (c *Client) AdminGetKeyAsJSON(keyName string) ([]byte, error)

func (*Client) AdminGetKeyAsTEXT

func (c *Client) AdminGetKeyAsTEXT(keyName string) (string, error)

func (*Client) AdminGetKeyType

func (c *Client) AdminGetKeyType(keyName string) (string, error)

func (*Client) AdminGetListIndex

func (c *Client) AdminGetListIndex(keyName string, index string) (string, error)

func (*Client) AdminListAppend

func (c *Client) AdminListAppend(keyName string, value string) error

func (*Client) AdminListHashFields

func (c *Client) AdminListHashFields(keyName string) ([]string, error)

func (*Client) AdminListKeys

func (c *Client) AdminListKeys(filter string) ([]string, error)

func (*Client) AdminSetHashField

func (c *Client) AdminSetHashField(keyName string, fieldName string, value string) error

func (*Client) AdminSetKeyFromJSON

func (c *Client) AdminSetKeyFromJSON(keyName string, jsonblob []byte) error

func (*Client) AdminSetStringKey

func (c *Client) AdminSetStringKey(keyName string, value string) error

func (*Client) DELETERequest

func (c *Client) DELETERequest(path string) ([]byte, error)

func (*Client) GETRequest

func (c *Client) GETRequest(path string, accept string) ([]byte, error)

func (*Client) GETRequestJSON

func (c *Client) GETRequestJSON(path string) ([]byte, error)

func (*Client) GETRequestTEXT

func (c *Client) GETRequestTEXT(path string) ([]byte, error)

func (*Client) GetHash

func (c *Client) GetHash(key string) (HashResponse, error)

func (*Client) GetHashValue

func (c *Client) GetHashValue(key string) ([]KeyPair, error)

func (*Client) GetList

func (c *Client) GetList(key string) (ListResponse, error)

func (*Client) GetListValue

func (c *Client) GetListValue(key string) ([]string, error)

func (*Client) GetListValueDebug

func (c *Client) GetListValueDebug(key string) ([]ValueSource, error)

func (*Client) GetListValueJoined

func (c *Client) GetListValueJoined(key string, join_char string) (string, error)

func (*Client) GetString

func (c *Client) GetString(key string) (StringResponse, error)

func (*Client) GetStringValue

func (c *Client) GetStringValue(key string, v ...string) (string, error)

func (*Client) GetStringValueDebug

func (c *Client) GetStringValueDebug(key string, v ...string) (ValueSource, error)

func (*Client) HashExists

func (c *Client) HashExists(key string) (bool, error)

func (*Client) ListExists

func (c *Client) ListExists(key string) (bool, error)

func (*Client) LoadConfigFile

func (c *Client) LoadConfigFile(path string) (*TemplateConfig, error)

func (*Client) LoadConfigFiles

func (c *Client) LoadConfigFiles() (TemplateConfigs, error)

func (*Client) PATCHRequestJSON

func (c *Client) PATCHRequestJSON(path string, data []byte) ([]byte, error)

func (*Client) POSTRequestJSON

func (c *Client) POSTRequestJSON(path string, data []byte) ([]byte, error)

func (*Client) StringExists

func (c *Client) StringExists(key string) (bool, error)

type DataRequest

type DataRequest struct {
	Data string `json:"data"`
}

type HashResponse

type HashResponse struct {
	Type string                 `json:"type"`
	Data map[string]ValueSource `json:"data"`
}

type KeyPair

type KeyPair struct {
	Key    string
	Value  string
	Source string
}

type KeyResponse

type KeyResponse struct {
	Type string      `json:"type"`
	Data interface{} `json:"data"`
}

type ListResponse

type ListResponse struct {
	Type string        `json:"type"`
	Data []ValueSource `json:"data"`
}

type SimpleListResponse

type SimpleListResponse struct {
	Data []string `json:"data"`
}

type StringKeyResponse

type StringKeyResponse struct {
	Type string `json:"type"`
	Data string `json:"data"`
}

type StringResponse

type StringResponse struct {
	Type string      `json:"type"`
	Data ValueSource `json:"data"`
}

type TemplateConfig

type TemplateConfig struct {
	Src      string `toml:"src"`
	Name     string
	Dest     string `toml:"dest"`
	TempDest string
	Uid      int `toml:"uid"`
	Gid      int `toml:"gid"`
	FileMode os.FileMode
	Mode     string `toml:"mode"`
	CheckCmd string `toml:"check_cmd"`
}

func (*TemplateConfig) Process

func (t *TemplateConfig) Process(funcMap map[string]interface{}) error

func (*TemplateConfig) Validate

func (t *TemplateConfig) Validate() error

type TemplateConfigFile

type TemplateConfigFile struct {
	Tpl TemplateConfig `toml:"template"`
}

type TemplateConfigs

type TemplateConfigs []*TemplateConfig

type ValueSource

type ValueSource struct {
	Value  string `json:"value"`
	Source string `json:"source"`
}

Directories

Path Synopsis
cmd
confadm command
conftpl command

Jump to

Keyboard shortcuts

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