core

package
v0.0.0-...-ee81150 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2014 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIBaseURL = "http://localhost:8080"
	DefaultAPIVersion = 1
)

Variables

This section is empty.

Functions

func ConfirmKey

func ConfirmKey(entity *openpgp.Entity, config *Config) bool

func Contains

func Contains(s []int, e int) bool

func CopyDir

func CopyDir(source string, dest string) (err error)

func CopyFile

func CopyFile(source string, dest string) (err error)

func CreateDirIfNotExists

func CreateDirIfNotExists(base string, perms int) (string, error)

func FetchKey

func FetchKey(keyid string) error

func GetDefaultKeyRingPath

func GetDefaultKeyRingPath() (string, error)

func GetDefaultSecKeyRingPath

func GetDefaultSecKeyRingPath() (string, error)

func HasKey

func HasKey(keyid string, entities *openpgp.EntityList) (*openpgp.Entity, error)

func MangleCommand

func MangleCommand(command string) string

func ReadKeyRing

func ReadKeyRing(keyRingPath string) (*openpgp.EntityList, error)

func ValidateConfig

func ValidateConfig(c *Config) error

Types

type APIClient

type APIClient interface {
	GetFormattedURL(prefix ...string) string
	NewRequest(method string, url string, params []byte,
		validStatus []int) (*simplejson.Json, error)
	Config() (*ConfigResponse, error)
	Create(description string, private bool, config *Config) (*CaseResponse, error)
	Pull(fileId string) (*UploadFile, error)
	Upload(filename string) error
}

type CaseResponse

type CaseResponse struct {
	Id          int
	Description string
	Created     string `json:",omitempty"`
	IsPrivate   bool
	Signed      string
	Config      string
	Token       string
}

func NewCaseResponse

func NewCaseResponse(json *simplejson.Json) (*CaseResponse, error)

type Client

type Client struct {
	Hostname  string
	APIClient APIClient
	Env       Environment
}

func NewClient

func NewClient(env Environment, server string, uuid string, authToken string) (*Client, error)

func (*Client) Create

func (client *Client) Create(configPath string, description string, private bool, pgp bool, keyid string) (interface{}, error)

func (*Client) Pull

func (client *Client) Pull(id string) (map[string]string, error)

func (*Client) PullAll

func (client *Client) PullAll() (map[string]string, error)

func (*Client) Run

func (client *Client) Run(pgp bool, upload bool, timeout int, dryRun bool) error

func (*Client) RunCommand

func (m *Client) RunCommand(reportPath string, command Command, wg *sync.WaitGroup)

func (*Client) Show

func (client *Client) Show() (interface{}, error)

type Command

type Command struct {
	Executable string
}

func (*Command) GetFileName

func (c *Command) GetFileName(Base string) string

type Config

type Config struct {
	Signed        string
	Raw           string
	Files         []File
	Commands      []Command
	FilesField    []string `yaml:"copy"`
	CommandsField []string `yaml:"run"`
}

func NewConfig

func NewConfig(readed string) (*Config, error)

func (*Config) GetCommands

func (c *Config) GetCommands() ([]Command, error)

func (*Config) GetFiles

func (c *Config) GetFiles() ([]File, error)

func (*Config) Sign

func (c *Config) Sign(keyid string) error

func (*Config) Verify

func (c *Config) Verify(signed string) (*openpgp.Entity, error)

type ConfigResponse

type ConfigResponse struct {
	Signed string
	Config string
	Files  []string
}

func NewConfigResponse

func NewConfigResponse(j *simplejson.Json) (*ConfigResponse, error)

func (*ConfigResponse) GetRawDecoded

func (c *ConfigResponse) GetRawDecoded() string

func (*ConfigResponse) GetSignedDecoded

func (c *ConfigResponse) GetSignedDecoded() string

type DefaultAPIClient

type DefaultAPIClient struct {
	Server    string
	Id        string
	AuthToken string
	Client    *http.Client
}

func (DefaultAPIClient) Config

func (api DefaultAPIClient) Config() (*ConfigResponse, error)

func (DefaultAPIClient) Create

func (api DefaultAPIClient) Create(description string, private bool, config *Config) (*CaseResponse, error)

func (DefaultAPIClient) GetFormattedURL

func (api DefaultAPIClient) GetFormattedURL(prefix ...string) string

func (DefaultAPIClient) NewRequest

func (api DefaultAPIClient) NewRequest(method string, url string,
	params []byte, validStatus []int) (*simplejson.Json, error)

func (DefaultAPIClient) Pull

func (api DefaultAPIClient) Pull(fileId string) (*UploadFile, error)

func (DefaultAPIClient) Upload

func (api DefaultAPIClient) Upload(filename string) error

type DefaultEnvironment

type DefaultEnvironment struct{}

func (DefaultEnvironment) GetCurrentTime

func (env DefaultEnvironment) GetCurrentTime() time.Time

func (DefaultEnvironment) GetDefaultDirectory

func (env DefaultEnvironment) GetDefaultDirectory() (string, error)

func (DefaultEnvironment) GetDefaultReportsDirectory

func (env DefaultEnvironment) GetDefaultReportsDirectory() (string, error)

func (DefaultEnvironment) GetDefaultStoragePath

func (env DefaultEnvironment) GetDefaultStoragePath() (string, error)

func (DefaultEnvironment) GetHomeDir

func (env DefaultEnvironment) GetHomeDir() (string, error)

func (DefaultEnvironment) GetHostName

func (env DefaultEnvironment) GetHostName() (string, error)

func (DefaultEnvironment) GetTempReportDirectory

func (env DefaultEnvironment) GetTempReportDirectory() (string, error)

type Environment

type Environment interface {
	GetDefaultDirectory() (string, error)
	GetDefaultReportsDirectory() (string, error)
	GetTempReportDirectory() (string, error)
	GetHostName() (string, error)
	GetCurrentTime() time.Time
	GetHomeDir() (string, error)
	GetDefaultStoragePath() (string, error)
}

type File

type File struct {
	Path string
}

type PGP

type PGP struct {
	SecKeyRingPath string
	KeyRingPath    string
}

func NewPGP

func NewPGP() (*PGP, error)

func (*PGP) Sign

func (p *PGP) Sign(readed string, keyid string) (string, error)

func (*PGP) Verify

func (p *PGP) Verify(readed string, signed string) (*openpgp.Entity, error)

type PGPSignature

type PGPSignature struct {
	Keys  []openpgp.Key
	KeyId uint64
}

type UploadFile

type UploadFile struct {
	Filename string
	Content  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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