shield

package
v0.0.0-...-82b3fef Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	UUID          string `json:"uuid"`
	Name          string `json:"name"`
	Address       string `json:"address"`
	Version       string `json:"version"`
	Status        string `json:"status"`
	Hidden        bool   `json:"hidden"`
	LastSeenAt    int64  `json:"last_seen_at"`
	LastCheckedAt int64  `json:"last_checked_at"`
	LastError     string `json:"last_error"`

	Metadata map[string]interface{} `json:"metadata"`

	Problems []string `json:"problems"`
}

type AgentFilter

type AgentFilter struct {
	UUID   string `qs:"uuid"`
	Fuzzy  bool   `qs:"exact:f:t"`
	Hidden *bool  `qs:"hidden:t:f"`
}

type Archive

type Archive struct {
	UUID   string `json:"uuid,omitempty"`
	Key    string `json:"key"`
	Status string `json:"status"`
	Notes  string `json:"notes"`

	Target *Target `json:"target,omitempty"`

	Size int64 `json:"size"`
}

type ArchiveFilter

type ArchiveFilter struct {
	UUID   string `qs:"uuid"`
	Fuzzy  bool   `qs:"exact:f:t"`
	Target string `qs:"target"`
	Status string `qs:"status"`
	//Before string `qs:"before"`
	//After string `qs:"after"`
	Limit *int `qs:"limit"`
}

type AuthID

type AuthID struct {
	Unauthenticated bool `json:"unauthenticated,omitempty"`

	User struct {
		Name    string `json:"name"`
		Account string `json:"account"`
		Backend string `json:"backend"`
		SysRole string `json:"sysrole"`
	} `json:"user"`

	Is struct {
		System struct {
			Admin    bool `json:"admin"`
			Manager  bool `json:"manager"`
			Engineer bool `json:"engineer"`
			Operator bool `json:"operator"`
		} `json:"system"`
	} `json:"is"`
}

type AuthMethod

type AuthMethod interface {
	Authenticate(*Client) (bool, error)
}

type AuthProvider

type AuthProvider struct {
	Name       string `json:"name"`
	Identifier string `json:"identifier"`
	Type       string `json:"type"`

	WebEntry string `json:"web_entry"`
	CLIEntry string `json:"cli_entry"`
	Redirect string `json:"redirect"`

	Properties map[string]interface{} `json:"properties,omitempty"`
}

type AuthToken

type AuthToken struct {
	UUID      string `json:"uuid"`
	Name      string `json:"name"`
	Session   string `json:"session"`
	CreatedAt int64  `json:"created_at"`
	LastSeen  int64  `json:"last_seen"`
}

type BacklogStatus

type BacklogStatus struct {
	Priority int    `json:"priority"`
	Position int    `json:"position"`
	TaskUUID string `json:"task_uuid"`

	Op    string `json:"op"`
	Agent string `json:"agent"`

	System *struct {
		UUID string `json:"uuid"`
		Name string `json:"name"`
	} `json:"system,omitempty"`

	Job *struct {
		UUID     string `json:"uuid"`
		Name     string `json:"name"`
		Schedule string `json:"schedule"`
	} `json:"job,omitempty"`

	Archive *struct {
		UUID string `json:"uuid"`
		Size int64  `json:"size"`
	} `json:"archive,omitempty"`
}

type Bucket

type Bucket struct {
	Key         string `json:"key"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Compression string `json:"compression"`
	Encryption  string `json:"encryption"`
}

type Client

type Client struct {
	URL   string
	Debug bool
	Trace bool

	InsecureSkipVerify bool
	TrustSystemCAs     bool
	CACertificate      string

	Timeout int
	Session string
	// contains filtered or unexported fields
}

func EnvConfig

func EnvConfig() (*Client, error, bool)

func (*Client) ApplyFixup

func (c *Client) ApplyFixup(id string) (Response, error)

func (*Client) AuthID

func (c *Client) AuthID() (*AuthID, error)

func (*Client) AuthProvider

func (c *Client) AuthProvider(id string) (*AuthProvider, error)

func (*Client) AuthProviderAnonymous

func (c *Client) AuthProviderAnonymous(id string) (*AuthProvider, error)

func (*Client) AuthProviders

func (c *Client) AuthProviders() ([]*AuthProvider, error)

func (*Client) Authenticate

func (c *Client) Authenticate(auth AuthMethod) error

func (*Client) CancelTask

func (c *Client) CancelTask(in *Task) (Response, error)

func (*Client) ChangePassword

func (c *Client) ChangePassword(oldpw, newpw string) (Response, error)

func (*Client) CheckTimespec

func (c *Client) CheckTimespec(spec string) (bool, string, error)

func (*Client) CreateArchive

func (c *Client) CreateArchive(in *Archive) (*Archive, error)

func (*Client) CreateAuthToken

func (c *Client) CreateAuthToken(t *AuthToken) (*AuthToken, error)

func (*Client) CreateJob

func (c *Client) CreateJob(job *Job) (*Job, error)

func (*Client) CreateTarget

func (c *Client) CreateTarget(in *Target) (*Target, error)

func (*Client) CreateTask

func (c *Client) CreateTask(in *Task) (*Task, error)

func (*Client) CreateUser

func (c *Client) CreateUser(in *User) (*User, error)

func (*Client) Curl

func (c *Client) Curl(method, path, body string) (int, string, error)

func (*Client) Debugf

func (c *Client) Debugf(s string, args ...interface{})

func (*Client) DeleteAgent

func (c *Client) DeleteAgent(in *Agent) (Response, error)

func (*Client) DeleteArchive

func (c *Client) DeleteArchive(in *Archive) (Response, error)

func (*Client) DeleteJob

func (c *Client) DeleteJob(in *Job) (Response, error)

func (*Client) DeleteSession

func (c *Client) DeleteSession(in *Session) (Response, error)

func (*Client) DeleteTarget

func (c *Client) DeleteTarget(in *Target, force bool) (Response, error)

func (*Client) DeleteUser

func (c *Client) DeleteUser(in *User) (Response, error)

func (*Client) Export

func (c *Client) Export(task string) (io.Reader, error)

func (*Client) FindAgent

func (c *Client) FindAgent(q string, fuzzy bool) (*Agent, error)

func (*Client) FindArchive

func (c *Client) FindArchive(q string, fuzzy bool) (*Archive, error)

func (*Client) FindBucket

func (c *Client) FindBucket(q string, fuzzy bool) (*Bucket, error)

func (*Client) FindBuckets

func (c *Client) FindBuckets(q string, fuzzy bool) ([]*Bucket, error)

func (*Client) FindJob

func (c *Client) FindJob(q string, fuzzy bool) (*Job, error)

func (*Client) FindTarget

func (c *Client) FindTarget(q string, fuzzy bool) (*Target, error)

func (*Client) FindTask

func (c *Client) FindTask(q string, fuzzy bool) (*Task, error)

func (*Client) FindUser

func (c *Client) FindUser(q string, fuzzy bool) (*User, error)

func (*Client) GetAgent

func (c *Client) GetAgent(uuid string) (*Agent, error)

func (*Client) GetArchive

func (c *Client) GetArchive(uuid string) (*Archive, error)

func (*Client) GetBucket

func (c *Client) GetBucket(key string) (*Bucket, error)

func (*Client) GetFixup

func (c *Client) GetFixup(id string) (*Fixup, error)

func (*Client) GetJob

func (c *Client) GetJob(uuid string) (*Job, error)

func (*Client) GetSession

func (c *Client) GetSession(uuid string) (*Session, error)

func (*Client) GetTarget

func (c *Client) GetTarget(uuid string) (*Target, error)

func (*Client) GetTask

func (c *Client) GetTask(uuid string) (*Task, error)

func (*Client) GetUser

func (c *Client) GetUser(uuid string) (*User, error)

func (*Client) GlobalStatus

func (c *Client) GlobalStatus() (*Status, error)

func (*Client) HideAgent

func (c *Client) HideAgent(in *Agent) (Response, error)

func (*Client) Import

func (c *Client) Import(task, key string, in io.Reader) error

func (*Client) Info

func (c *Client) Info() (*Info, error)

func (*Client) ListAgents

func (c *Client) ListAgents(filter *AgentFilter) ([]*Agent, error)

func (*Client) ListArchives

func (c *Client) ListArchives(filter *ArchiveFilter) ([]*Archive, error)

func (*Client) ListAuthTokens

func (c *Client) ListAuthTokens() ([]*AuthToken, error)

func (*Client) ListBuckets

func (c *Client) ListBuckets() ([]*Bucket, error)

func (*Client) ListFixups

func (c *Client) ListFixups(filter *FixupFilter) ([]*Fixup, error)

func (*Client) ListJobs

func (c *Client) ListJobs(filter *JobFilter) ([]*Job, error)

func (*Client) ListSessions

func (c *Client) ListSessions(filter *SessionFilter) ([]*Session, error)

func (*Client) ListTargets

func (c *Client) ListTargets(filter *TargetFilter) ([]*Target, error)

func (*Client) ListTasks

func (c *Client) ListTasks(filter *TaskFilter) ([]*Task, error)

func (*Client) ListUsers

func (c *Client) ListUsers(filter *UserFilter) ([]*User, error)

func (*Client) Lock

func (c *Client) Lock() error

func (*Client) Logout

func (c *Client) Logout() error

func (*Client) PauseJob

func (c *Client) PauseJob(job *Job) (Response, error)

func (*Client) RestoreArchive

func (c *Client) RestoreArchive(a *Archive, t *Target) (*Task, error)

func (*Client) RevokeAuthToken

func (c *Client) RevokeAuthToken(t *AuthToken) error

func (*Client) RunJob

func (c *Client) RunJob(job *Job) (Response, error)

func (*Client) SchedulerStatus

func (c *Client) SchedulerStatus() (*SchedulerStatus, error)

func (*Client) ShowAgent

func (c *Client) ShowAgent(in *Agent) (Response, error)

func (*Client) StreamEvents

func (c *Client) StreamEvents(fn func(Event)) error

func (*Client) Unlock

func (c *Client) Unlock(master string) error

func (*Client) UnpauseJob

func (c *Client) UnpauseJob(job *Job) (Response, error)

func (*Client) UpdateArchive

func (c *Client) UpdateArchive(in *Archive) (*Archive, error)

func (*Client) UpdateJob

func (c *Client) UpdateJob(job *Job) (*Job, error)

func (*Client) UpdateTarget

func (c *Client) UpdateTarget(in *Target) (*Target, error)

func (*Client) UpdateTask

func (c *Client) UpdateTask(in *Task) (*Task, error)

func (*Client) UpdateUser

func (c *Client) UpdateUser(in *User) (*User, error)

type Config

type Config struct {
	Path    string
	Current *Core
	SHIELDs map[string]*Core
}

func ReadConfig

func ReadConfig(path string) (*Config, error)

func (*Config) Add

func (c *Config) Add(alias string, core Core)

func (*Config) Client

func (c *Config) Client(core string) (*Client, error)

func (*Config) Select

func (c *Config) Select(alias string) error

func (*Config) Write

func (c *Config) Write() error

type Core

type Core struct {
	URL                string `yaml:"url"`
	Session            string `yaml:"session"`
	InsecureSkipVerify bool   `yaml:"skip_verify"`
	CACertificate      string `yaml:"cacert"`
}

type Error

type Error struct {
	Message string   `json:"error"`
	Missing []string `json:"missing"`
	Extra   string   `json:"diagnostic"`
}

func (Error) Error

func (e Error) Error() string

type Event

type Event struct {
	Event string      `json:"event"`
	Queue string      `json:"queue"`
	Type  string      `json:"type,omitempty"`
	Data  interface{} `json:"data"`
}

type Fixup

type Fixup struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	Summary   string `json:"summary"`
	CreatedAt int64  `json:"created_at"`
	AppliedAt int64  `json:"applied_at"`
}

type FixupFilter

type FixupFilter struct {
}

type Info

type Info struct {
	Version string `json:"version,omitempty"`
	Env     string `json:"env,omitempty"`
	Color   string `json:"color,omitempty"`
	MOTD    string `json:"motd,omitempty"`

	API int `json:"api"`
}

type Job

type Job struct {
	UUID       string `json:"uuid,omitempty"`
	Name       string `json:"name"`
	Summary    string `json:"summary"`
	Schedule   string `json:"schedule"`
	KeepDays   int    `json:"keep_days"`
	KeepN      int    `json:"keep_n"`
	Retain     string `json:"-"`
	Paused     bool   `json:"paused"`
	Agent      string `json:"agent"`
	LastStatus string `json:"last_task_status"`
	LastRun    int64  `json:"last_run"`

	TargetUUID string `json:"-"`
	Target     struct {
		UUID   string `json:"uuid"`
		Name   string `json:"name"`
		Agent  string `json:"agent"`
		Plugin string `json:"plugin"`

		Endpoint string                 `json:"endpoint,omitempty"`
		Config   map[string]interface{} `json:"config,omitempty"`
	} `json:"target"`

	Bucket string `json:"bucket"`

	AgentHost string `json:"-"`
	AgentPort int    `json:"-"`
}

func (Job) Status

func (j Job) Status() string

type JobFilter

type JobFilter struct {
	UUID   string `qs:"uuid"`
	Fuzzy  bool   `qs:"exact:f:t"`
	Name   string `qs:"name"`
	Bucket string `qs:"bucket"`
	Target string `qs:"target"`
	Paused *bool  `qs:"paused:t:f"`
}

type LocalAuth

type LocalAuth struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

func (*LocalAuth) Authenticate

func (auth *LocalAuth) Authenticate(c *Client) (bool, error)

type Plugin

type Plugin struct {
	ID   string
	Name string
}

func ParseAgentMetadata

func ParseAgentMetadata(in map[string]interface{}) ([]*Plugin, error)

type Response

type Response struct {
	OK string `json:"ok"`

	TaskUUID string `json:"task_uuid,omitempty"`
}

type SchedulerStatus

type SchedulerStatus struct {
	Backlog []BacklogStatus `json:"backlog"`
	Workers []WorkerStatus  `json:"workers"`
}

type Session

type Session struct {
	UUID           string `json:"uuid"`
	UserUUID       string `json:"user_uuid"`
	CreatedAt      int64  `json:"created_at"`
	LastSeen       int64  `json:"last_seen_at"`
	Token          string `json:"token_uuid"`
	Name           string `json:"name"`
	IP             string `json:"ip_addr"`
	UserAgent      string `json:"user_agent"`
	UserAccount    string `json:"user_account"`
	CurrentSession bool   `json:"current_session"`
}

type SessionFilter

type SessionFilter struct {
	Name       string `qs:"name"`
	ExactMatch bool   `qs:"exact:f:t"`
	UUID       string
	UserUUID   string `qs:"user_uuid"`
	Limit      int    `qs:"limit"`
	IP         string `qs:"ip_addr"`
	IsToken    bool   `qs:"is_token"`
}

type Status

type Status struct {
	Health  StatusHealth  `json:"health"`
	Storage StatusStorage `json:"storage"`
	Jobs    StatusJobs    `json:"jobs"`
	Stats   StatusStats   `json:"stats"`
}

type StatusHealth

type StatusHealth struct {
	Core      string `json:"core"`
	StorageOK bool   `json:"storage_ok"`
	JobsOK    bool   `json:"jobs_ok"`
}

type StatusJobs

type StatusJobs []struct {
	UUID    string `json:"uuid"`
	Target  string `json:"target"`
	Job     string `json:"job"`
	Healthy bool   `json:"healthy"`
}

type StatusStats

type StatusStats struct {
	Jobs        int   `json:"jobs"`
	Systems     int   `json:"systems"`
	Archives    int   `json:"archives"`
	StorageUsed int64 `json:"storage"`
	DailyDelta  int   `json:"daily"`
}

type StatusStorage

type StatusStorage []struct {
	Name   string `json:"name"`
	Health bool   `json:"healthy"`
}

type Target

type Target struct {
	UUID    string `json:"uuid,omitempty"`
	Name    string `json:"name"`
	Summary string `json:"summary"`
	Plugin  string `json:"plugin"`
	Agent   string `json:"agent"`

	Config map[string]interface{} `json:"config"`
}

type TargetFilter

type TargetFilter struct {
	UUID   string `qs:"uuid"`
	Fuzzy  bool   `qs:"exact:f:t"`
	Name   string `qs:"name"`
	Plugin string `qs:"plugin"`
	Used   *bool  `qs:"unused:f:t"`
}

type Task

type Task struct {
	UUID        string `json:"uuid,omitempty"`
	Type        string `json:"type"`
	Status      string `json:"status"`
	Owner       string `json:"owner"`
	StartedAt   int64  `json:"started_at"`
	StoppedAt   int64  `json:"stopped_at"`
	RequestedAt int64  `json:"requested_at"`
	Log         string `json:"log"`
	OK          bool   `json:"ok"`
	Notes       string `json:"notes"`
	Clear       string `json:"clear"`
	JobUUID     string `json:"job_uuid"`
	ArchiveUUID string `json:"archive_uuid"`
}

type TaskFilter

type TaskFilter struct {
	UUID   string `qs:"uuid"`
	Fuzzy  bool   `qs:"exact:f:t"`
	Status string `qs:"status"`
	Active *bool  `qs:"active:t:f"`
	Debug  *bool  `qs:"debug:t:f"`
	Limit  *int   `qs:"limit"`
	Target string `qs:"target"`
	Store  string `qs:"store"`
	Type   string `qs:"type"`
	Before int64  `qs:"before"`
}

type TokenAuth

type TokenAuth struct {
	Token string
}

func (*TokenAuth) Authenticate

func (auth *TokenAuth) Authenticate(c *Client) (bool, error)

type User

type User struct {
	UUID     string `json:"uuid,omitempty"`
	Name     string `json:"name"`
	Account  string `json:"account"`
	SysRole  string `json:"sysrole"`
	Password string `json:"password,omitempty"`
}

type UserFilter

type UserFilter struct {
	UUID    string `qs:"uuid"`
	Fuzzy   bool   `qs:"exact:f:t"`
	Account string `qs:"account"`
	SysRole string `qs:"sysrole"`
}

type WorkerStatus

type WorkerStatus struct {
	ID       int    `json:"id"`
	Idle     bool   `json:"idle"`
	TaskUUID string `json:"task_uuid"`

	Op     string `json:"op"`
	Status string `json:"status"`
	Agent  string `json:"agent"`

	System *struct {
		UUID string `json:"uuid"`
		Name string `json:"name"`
	} `json:"system,omitempty"`

	Job *struct {
		UUID     string `json:"uuid"`
		Name     string `json:"name"`
		Schedule string `json:"schedule"`
	} `json:"job,omitempty"`

	Archive *struct {
		UUID string `json:"uuid"`
		Size int64  `json:"size"`
	} `json:"archive,omitempty"`
}

Jump to

Keyboard shortcuts

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