salt

package module
v0.0.0-...-b7e075d Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 License: MIT Imports: 13 Imported by: 0

README

Introduction

Although there are a few Go libraries for interacting with the Salt API, they are largely abandoned, have little or no test coverage, and do not adhere to modern Go best practices, such as supporting contexts or streaming results.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Client  *http.Client
	Headers map[string]string
	Server  string
	Token   string

	Events  *Events
	Jobs    *Jobs
	Keys    *Keys
	Minions *Minions
}

func New

func New(server string) *Client

New returns a new Client, initialized with the Salt API server.

func (*Client) Login

func (c *Client) Login(ctx context.Context, username, password string) error

func (*Client) Logout

func (c *Client) Logout(ctx context.Context) error

func (*Client) Ping

func (c *Client) Ping(ctx context.Context, target string, fn PingReturnFunc) error

func (*Client) Run

func (c *Client) Run(ctx context.Context, cmd *Command, fn ReturnFunc) error

type Command

type Command struct {
	Arguments  []string `json:"arg,omitempty"`
	Client     string   `json:"client"`
	Function   string   `json:"fun"`
	Keywords   Object   `json:"kwarg,omitempty"`
	Match      string   `json:"match,omitempty"`
	Target     string   `json:"tgt,omitempty"`
	TargetType string   `json:"tgt_type,omitempty"`
	Timeout    int      `json:"timeout,omitempty"`
}

type Error

type Error struct {
	Message string
	Status  int
}

func NewError

func NewError(status int, message string) *Error

func (*Error) Error

func (e *Error) Error() string

type EventStreamFunc

type EventStreamFunc func(Response) error

type Events

type Events struct {
	*Client
}

func (*Events) Fire

func (c *Events) Fire(ctx context.Context, tag string, data any) error

func (*Events) Stream

func (c *Events) Stream(ctx context.Context, fn EventStreamFunc) error

type Format

type Format int
const (
	FormatObject Format = iota
	FormatRunner
)

type Jobs

type Jobs struct {
	*Client
}

func (*Jobs) All

func (c *Jobs) All(ctx context.Context, fn ReturnFunc) error

func (*Jobs) Filter

func (c *Jobs) Filter(ctx context.Context, id string, fn ReturnFunc) error

type Keys

type Keys struct {
	*Client
}

func (*Keys) Accept

func (c *Keys) Accept(ctx context.Context, match string, fn MinionFunc) error

func (*Keys) Delete

func (c *Keys) Delete(ctx context.Context, match string) error

func (*Keys) ListAccepted

func (c *Keys) ListAccepted(ctx context.Context, fn MinionFunc) error

func (*Keys) ListPending

func (c *Keys) ListPending(ctx context.Context, fn MinionFunc) error

func (*Keys) ListRejected

func (c *Keys) ListRejected(ctx context.Context, fn MinionFunc) error

type MinionFunc

type MinionFunc func(string) error

type Minions

type Minions struct {
	*Client
}

func (*Minions) All

func (c *Minions) All(ctx context.Context, fn ReturnFunc) error

func (*Minions) Filter

func (c *Minions) Filter(ctx context.Context, id string, fn ReturnFunc) error

type Object

type Object map[string]any

type PingReturnFunc

type PingReturnFunc func(string, bool) error

type Request

type Request map[string]any

Request is a loosely structured payload to be sent with a request.

type Response

type Response []byte

func (*Response) Decode

func (m *Response) Decode(v any) error

func (*Response) Get

func (m *Response) Get(path string) gjson.Result

func (*Response) Has

func (m *Response) Has(path string) bool

func (*Response) Result

func (m *Response) Result() gjson.Result

func (*Response) String

func (m *Response) String() string

func (*Response) UnmarshalJSON

func (m *Response) UnmarshalJSON(data []byte) error

type ReturnFunc

type ReturnFunc func(string, Response) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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