operations

package
v0.0.0-...-1ffed49 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Overview

This package holds majority of actual functionality of rcc, in form of "operations" that can be done.

Index

Constants

View Source
const (
	WorkspaceApi      = `/token-vendor-v1/workspaces/%s/tokenrequest`
	UserApi           = `/token-vendor-v1/user/tokenrequest`
	UserDetails       = `/token-vendor-v1/user/details`
	DeleteCredentials = `/token-vendor-v1/credential`
)
View Source
const (
	X_RCC_RANDOM_IDENTITY = `X-Rcc-Random-Identity`
	AUTHORIZATION         = "Authorization"
)

Variables

This section is empty.

Functions

func AccountByName

func AccountByName(label string) *account

func BackgroundAssistantHeartbeat

func BackgroundAssistantHeartbeat(cancel chan bool, client cloud.Client, account *account, workspaceId, assistantId, runId string)

func BearerToken

func BearerToken(token string) string

func BeatAssistantRun

func BeatAssistantRun(client cloud.Client, account *account, workspaceId, assistantId, runId string, beat int) error

func CacheRobot

func CacheRobot(filename string) error

func CarrierUnzip

func CarrierUnzip(directory, carrier string, force, temporary bool) error

func CleanupOldestRobot

func CleanupOldestRobot()

func CommunityLocation

func CommunityLocation(name, branch string) string

func Decoded

func Decoded(content string) ([]byte, error)

func DefaultAccountName

func DefaultAccountName() string

func DeleteAccount

func DeleteAccount(client cloud.Client, account *account) error

func Digest

func Digest(incoming string) string

func DownloadCommand

func DownloadCommand(client cloud.Client, account *account, workspaceId, robotId, zipfile string, debug bool) error

func DownloadCommunityRobot

func DownloadCommunityRobot(url, filename string) error

func ExecuteSimpleTask

func ExecuteSimpleTask(flags *RunFlags, template []string, config robot.Robot, todo robot.Task, interactive bool, extraEnv map[string]string)

func ExecuteTask

func ExecuteTask(flags *RunFlags, template []string, config robot.Robot, todo robot.Task, label string, interactive bool, extraEnv map[string]string)

func ExecutionEnvironmentListing

func ExecutionEnvironmentListing(wantedfile, label string, searchPath pathlib.PathParts, directory, outputDir string, environment []string) bool

func FindExecutable

func FindExecutable() (string, error)

func FixDirectory

func FixDirectory(dir string) error

func FixRobot

func FixRobot(robotFile string) error

func FreezeEnvironmentListing

func FreezeEnvironmentListing(label string, config robot.Robot)

func HasPayload

func HasPayload(filename string) (bool, error)

func HmacSignature

func HmacSignature(claims *Claims, secret, nonce, bodyHash string) string

func HololibZipShape

func HololibZipShape(file *zip.File) error

func InitializeWorkarea

func InitializeWorkarea(directory, name string, internal, force bool) error

func IoAsString

func IoAsString(source io.Reader) string

func IsCarrier

func IsCarrier() (bool, error)

func ListAccounts

func ListAccounts(json bool)

func ListTemplates

func ListTemplates(internal bool) []string

func LoadAnyTaskEnvironment

func LoadAnyTaskEnvironment(packfile string, force bool) (bool, robot.Robot, robot.Task, string)

func LoadTaskWithEnvironment

func LoadTaskWithEnvironment(packfile, theTask string, force bool) (bool, robot.Robot, robot.Task, string)

func LookupRobot

func LookupRobot(digest string) (string, bool)

func MultipartUpload

func MultipartUpload(url string, fields map[string]string, basename, fullpath string) error

func NiceJsonOutput

func NiceJsonOutput(content interface{}) (string, error)

func OldestRobot

func OldestRobot() (string, time.Time)

func PrintRobotDiagnostics

func PrintRobotDiagnostics(robotfile string, json, production bool) error

func ProduceDiagnostics

func ProduceDiagnostics(filename, robotfile string, json, production, quick bool) (*common.DiagnosticStatus, error)

func ProduceNetDiagnostics

func ProduceNetDiagnostics(body []byte, json bool) (*common.DiagnosticStatus, error)

func ProtectedImport

func ProtectedImport(filename string) (err error)

func PullCatalog

func PullCatalog(origin, catalogName string, useLock bool) (err error)

func RccVersionCheck

func RccVersionCheck() func()

func ReportIssue

func ReportIssue(email, robotFile, reportFile string, attachmentsFiles []string, dryrun bool) error

func RobocorpCloudHmac

func RobocorpCloudHmac(identifier, token string) string

func RunRobotDiagnostics

func RunRobotDiagnostics(robotfile string, production bool) *common.DiagnosticStatus

func SelectExecutionModel

func SelectExecutionModel(runFlags *RunFlags, simple bool, template []string, config robot.Robot, todo robot.Task, label string, interactive bool, extraEnv map[string]string)

func SelfAppend

func SelfAppend(target, payload string) error

func SelfCopy

func SelfCopy(target string) error

func SetDefaultAccount

func SetDefaultAccount(account string)

func StopAssistantRun

func StopAssistantRun(client cloud.Client, account *account, workspaceId, assistantId, runId, status, reason string) error

func SubprocessWarning

func SubprocessWarning(seen ChildMap, use bool) error

func SummonRobotZipfile

func SummonRobotZipfile(client cloud.Client, account *account, workspaceId, robotId, digest string) (string, error)

func TLSExport

func TLSExport(filename string, configfiles []string) (err error)

func TLSProbe

func TLSProbe(serverports []string) (err error)

func TemplatesZip

func TemplatesZip() string

func ToUnix

func ToUnix(content []byte) []byte

func Unzip

func Unzip(directory, zipfile string, force, temporary, flatten bool) error

func UpdateCredentials

func UpdateCredentials(account, endpoint, identifier, secret string)

func UploadCommand

func UploadCommand(client cloud.Client, account *account, workspaceId, robotId, zipfile string, debug bool) error

func VerifyAccounts

func VerifyAccounts(force bool)

func VerifyZip

func VerifyZip(zipfile string, verifier Verifier) []error

func WatchChildren

func WatchChildren(pid int, delay time.Duration) chan ChildMap

func WorkspaceToken

func WorkspaceToken(token string) string

func WorkspaceTreeCommand

func WorkspaceTreeCommand(client cloud.Client, account *account, workspace string) (interface{}, error)

func WorkspaceTreeCommandRequest

func WorkspaceTreeCommandRequest(client cloud.Client, account *account, workspace string) (*cloud.Response, error)

func WorkspacesCommand

func WorkspacesCommand(client cloud.Client, account *account) (interface{}, error)

func Zip

func Zip(directory, zipfile string, ignores []string) error

func ZipAppend

func ZipAppend(writer *zip.Writer, fullpath, relativepath string) error

Types

type ArtifactPublisher

type ArtifactPublisher struct {
	Client          cloud.Client
	ArtifactPostURL string
	ErrorCount      int
}

func (*ArtifactPublisher) NewClient

func (it *ArtifactPublisher) NewClient(targetUrl string) (cloud.Client, *url.URL, error)

func (*ArtifactPublisher) Publish

func (it *ArtifactPublisher) Publish(fullpath, relativepath string, details os.FileInfo)

type AssistantRobot

type AssistantRobot struct {
	WorkspaceId string
	AssistantId string
	RunId       string
	RobotId     string
	TaskName    string
	Zipfile     string
	Environment map[string]string
	Details     map[string]interface{}
	Config      map[string]interface{}
	ArtifactURL string
}

func StartAssistantRun

func StartAssistantRun(client cloud.Client, account *account, workspaceId, assistantId string) (*AssistantRobot, error)

type Cache

type Cache struct {
	Credentials CredentialMap `yaml:"credentials"`
	Stamps      StampMap      `yaml:"stamps"`
	Users       []string      `yaml:"users"`
}

func SummonCache

func SummonCache() (*Cache, error)

func (Cache) Ready

func (it Cache) Ready() *Cache

func (*Cache) Save

func (it *Cache) Save() error

func (Cache) Userset

func (it Cache) Userset() []string

type ChildMap

type ChildMap map[int]string

type Claims

type Claims struct {
	ExpiresIn     int    `json:"expiresIn,omitempty"`
	CapabilitySet string `json:"capabilitySet,omitempty"`
	Method        string `json:"-"`
	Url           string `json:"-"`
	Name          string `json:"-"`
}

func DeleteClaims

func DeleteClaims() *Claims

func EditRobotClaims

func EditRobotClaims(seconds int, workspace string) *Claims

func GetRobotClaims

func GetRobotClaims(seconds int, workspace string) *Claims

func NewClaims

func NewClaims(name, url string, expires int) *Claims

func RunAssistantClaims

func RunAssistantClaims(seconds int, workspace string) *Claims

func RunRobotClaims

func RunRobotClaims(seconds int, workspace string) *Claims

func VerificationClaims

func VerificationClaims() *Claims

func ViewWorkspacesClaims

func ViewWorkspacesClaims(seconds int) *Claims

func (*Claims) AsDelete

func (it *Claims) AsDelete() *Claims

func (*Claims) AsGet

func (it *Claims) AsGet() *Claims

func (*Claims) AsJson

func (it *Claims) AsJson() (string, error)

func (*Claims) IsGet

func (it *Claims) IsGet() bool

type Command

type Command interface {
	Execute() bool
}

type CommandChannel

type CommandChannel chan Command

type CompletedChannel

type CompletedChannel chan bool

type Configuration

type Configuration struct {
	Network *NetConfig `yaml:"network"`
}

type Credential

type Credential struct {
	Account  string `yaml:"account"`
	Context  string `yaml:"context"`
	Token    string `yaml:"token"`
	Deadline int64  `yaml:"deadline"`
}

type CredentialMap

type CredentialMap map[string]*Credential

type EncryptionKeys

type EncryptionKeys struct {
	Iv              string `json:"iv"`
	Atag            string `json:"atag"`
	EncryptedAESKey string `json:"encryptedAESKey"`
}

type EncryptionPayload

type EncryptionPayload struct {
	Encryption *EncryptionKeys `json:"encryption"`
	Payload    string          `json:"payload,omitempty"`
}

type EncryptionV1

type EncryptionV1 struct {
	*rsa.PrivateKey
}

func (*EncryptionV1) Decode

func (it *EncryptionV1) Decode(blob []byte) ([]byte, error)

func (*EncryptionV1) PublicPEM

func (it *EncryptionV1) PublicPEM() string

func (*EncryptionV1) RequestBody

func (it *EncryptionV1) RequestBody(payload interface{}) (io.Reader, error)

func (*EncryptionV1) RequestObject

func (it *EncryptionV1) RequestObject(payload interface{}) ([]byte, error)

type Ephemeral

type Ephemeral interface {
	RequestBody(interface{}) (io.Reader, error)
	Decode([]byte) ([]byte, error)
}

func GenerateEphemeralKey

func GenerateEphemeralKey() (Ephemeral, error)

type MetaTemplates

type MetaTemplates struct {
	Date      string    `yaml:"date"`
	Hash      string    `yaml:"hash"`
	Templates StringMap `yaml:"templates"`
	Url       string    `yaml:"url"`
}

func TemplateInfo

func TemplateInfo(filename string) (ingore *MetaTemplates, err error)

func (*MetaTemplates) MatchingHash

func (it *MetaTemplates) MatchingHash(hash string) bool

type NetConfig

type NetConfig struct {
	DNS  []string     `yaml:"dns-lookup"`
	TLS  []string     `yaml:"tls-verify"`
	Head []*WebConfig `yaml:"head-request"`
	Get  []*WebConfig `yaml:"get-request"`
}

func (*NetConfig) Hostnames

func (it *NetConfig) Hostnames() []string

type ProcessMap

type ProcessMap map[int]*ProcessNode

func ProcessMapNow

func ProcessMapNow() (ProcessMap, error)

func (ProcessMap) Keys

func (it ProcessMap) Keys() []int

func (ProcessMap) Roots

func (it ProcessMap) Roots() []int

type ProcessNode

type ProcessNode struct {
	Pid        int
	Parent     int
	White      bool
	Executable string
	Children   ProcessMap
}

func NewProcessNode

func NewProcessNode(core ps.Process) *ProcessNode

type ProcessNodes

type ProcessNodes []*ProcessNode

type ReaderCloserAt

type ReaderCloserAt interface {
	io.ReaderAt
	io.Closer
	Limit() int64
}

func PayloadReaderAt

func PayloadReaderAt(filename string) (ReaderCloserAt, error)

type RobotData

type RobotData struct {
	Id      string                 `json:"id"`
	Name    string                 `json:"name,omitempty"`
	Package map[string]interface{} `json:"package,omitempty"`
}

type RunFlags

type RunFlags struct {
	*TokenPeriod
	AccountName     string
	WorkspaceId     string
	EnvironmentFile string
	RobotYaml       string
	Assistant       bool
	NoPipFreeze     bool
}

type StampMap

type StampMap map[string]int64

type StringMap

type StringMap map[string]string

type StringPair

type StringPair [2]string

type StringPairList

type StringPairList []StringPair

func ListTemplatesWithDescription

func ListTemplatesWithDescription(internal bool) StringPairList

func (StringPairList) Len

func (it StringPairList) Len() int

func (StringPairList) Less

func (it StringPairList) Less(left, right int) bool

func (StringPairList) Swap

func (it StringPairList) Swap(left, right int)

type Token

type Token map[string]interface{}

func AuthorizeClaims

func AuthorizeClaims(accountName string, claims *Claims, period *TokenPeriod) (Token, error)

func AuthorizeCommand

func AuthorizeCommand(client cloud.Client, account *account, claims *Claims, period *TokenPeriod) (Token, error)

func ListAssistantsCommand

func ListAssistantsCommand(client cloud.Client, account *account, workspaceId string) ([]Token, error)

func NewRobotCommand

func NewRobotCommand(client cloud.Client, account *account, workspace, robotName string) (Token, error)

func (Token) AsJson

func (it Token) AsJson() (string, error)

func (Token) FromJson

func (it Token) FromJson(content []byte) error

type TokenPeriod

type TokenPeriod struct {
	ValidityTime int // minutes
	GracePeriod  int // minutes
}

func DefaultTokenPeriod

func DefaultTokenPeriod() *TokenPeriod

func (*TokenPeriod) AsSeconds

func (it *TokenPeriod) AsSeconds() (int, int, bool)

func (*TokenPeriod) Deadline

func (it *TokenPeriod) Deadline() int64

func (*TokenPeriod) EnforceGracePeriod

func (it *TokenPeriod) EnforceGracePeriod() *TokenPeriod

func (*TokenPeriod) Liveline

func (it *TokenPeriod) Liveline() int64

func (*TokenPeriod) RequestSeconds

func (it *TokenPeriod) RequestSeconds() int

type Unmarshaler

type Unmarshaler func([]byte, interface{}) error

type UrlConfig

type UrlConfig struct {
	TrustedURLs   []string `yaml:"trusted,omitempty"`
	UntrustedURLs []string `yaml:"untrusted,omitempty"`
}

type UserInfo

type UserInfo struct {
	User Token `json:"user"`
	Link Token `json:"request"`
}

func UserinfoCommand

func UserinfoCommand(client cloud.Client, account *account) (*UserInfo, error)

type Verifier

type Verifier func(file *zip.File) error

type WebConfig

type WebConfig struct {
	URL         string `yaml:"url"`
	Codes       []int  `yaml:"codes"`
	Fingerprint string `yaml:"content-sha256,omitempty"`
}

type WorkspaceTreeData

type WorkspaceTreeData struct {
	Id     string       `json:"id"`
	Robots []*RobotData `json:"robots,omitempty"`
}

type WriteTarget

type WriteTarget struct {
	Source *zip.File
	Target string
}

func (*WriteTarget) Execute

func (it *WriteTarget) Execute() bool

Jump to

Keyboard shortcuts

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