mackerelclient

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2019 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadApibaseFromConfig

func LoadApibaseFromConfig(conffile string) string

LoadApibaseFromConfig gets mackerel api Base URL (usually https://api.mackerelio.com/) from mackerel-agent.conf if it's installed mackerel-agent on localhost

func LoadApibaseFromConfigWithFallback

func LoadApibaseFromConfigWithFallback(conffile string) string

LoadApibaseFromConfigWithFallback get mackerel api Base URL from mackerel-agent.conf, and fallbacks to default (https://api.mackerelio.com/) if not specified.

func LoadApikeyFromConfig

func LoadApikeyFromConfig(conffile string) string

LoadApikeyFromConfig gets mackerel.io apikey from mackerel-agent.conf if it's installed mackerel-agent on localhost

func LoadApikeyFromEnvOrConfig

func LoadApikeyFromEnvOrConfig(conffile string) string

LoadApikeyFromEnvOrConfig is similar to LoadApikeyFromConfig. return MACKEREL_APIKEY environment value if defined MACKEREL_APIKEY

func LoadHostIDFromConfig

func LoadHostIDFromConfig(conffile string) string

LoadHostIDFromConfig gets localhost's hostID from conf.Root (ex. /var/lib/mackerel/id) if it's installed mackerel-agent on localhost

func NewFromContext

func NewFromContext(c *cli.Context) *mackerel.Client

NewFromContext returns mackerel client from cli.Context

Types

type Client added in v0.36.0

type Client interface {
	FindHosts(param *mackerel.FindHostsParam) ([]*mackerel.Host, error)
	FindServices() ([]*mackerel.Service, error)
	GetOrg() (*mackerel.Org, error)
}

Client represents a client of Mackerel API

func New

func New(conffile, apibase string) (Client, error)

New returns new mackerel client

type MockClient added in v0.36.0

type MockClient struct {
	// contains filtered or unexported fields
}

MockClient represents a mock client of Mackerel API

func NewMockClient added in v0.36.0

func NewMockClient(opts ...MockClientOption) *MockClient

NewMockClient creates a new mock client of Mackerel API

func (*MockClient) ApplyOption added in v0.36.0

func (c *MockClient) ApplyOption(opt MockClientOption)

ApplyOption applies a mock client option

func (*MockClient) FindHosts added in v0.36.0

func (c *MockClient) FindHosts(param *mackerel.FindHostsParam) ([]*mackerel.Host, error)

FindHosts ...

func (*MockClient) FindServices added in v0.36.0

func (c *MockClient) FindServices() ([]*mackerel.Service, error)

FindServices ...

func (*MockClient) GetOrg added in v0.36.0

func (c *MockClient) GetOrg() (*mackerel.Org, error)

GetOrg ...

type MockClientOption added in v0.36.0

type MockClientOption func(*MockClient)

MockClientOption represents an option of mock client of Mackerel API

func MockFindHosts added in v0.36.0

func MockFindHosts(callback func(param *mackerel.FindHostsParam) ([]*mackerel.Host, error)) MockClientOption

MockFindHosts returns an option to set the callback of FindHosts

func MockFindServices added in v0.36.0

func MockFindServices(callback func() ([]*mackerel.Service, error)) MockClientOption

MockFindServices returns an option to set the callback of FindServices

func MockGetOrg added in v0.36.0

func MockGetOrg(callback func() (*mackerel.Org, error)) MockClientOption

MockGetOrg returns an option to set the callback of GetOrg

Jump to

Keyboard shortcuts

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