sharedaction

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

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package sharedaction handles all operations that do not require a cloud controller

Index

Constants

View Source
const (
	CommonCommandsIndent string = "  "
	AllCommandsIndent    string = "   "
	CommandIndent        string = "   "
)
View Source
const (
	StagingLog      = "STG"
	RecentLogsLines = 1000
)
View Source
const (
	DefaultFolderPermissions      = 0755
	DefaultArchiveFilePermissions = 0744
	MaxResourceMatchChunkSize     = 1000
)

Variables

View Source
var DefaultIgnoreLines = []string{
	".cfignore",
	".DS_Store",
	".git",
	".gitignore",
	".hg",
	".svn",
	"_darcs",
	"manifest.yaml",
	"manifest.yml",
}

Functions

func GetStreamingLogs

func GetStreamingLogs(appGUID string, client LogCacheClient) (<-chan LogMessage, <-chan error, context.CancelFunc)

Types

type Actor

type Actor struct {
	Config Config
	AuthActor
}

Actor handles all shared actions

func NewActor

func NewActor(config Config) *Actor

NewActor returns an Actor with default settings

func (Actor) CheckTarget

func (actor Actor) CheckTarget(targetedOrganizationRequired bool, targetedSpaceRequired bool) error

CheckTarget confirms that the user is logged in. Optionally it will also check if an organization and space are targeted.

func (Actor) CommandInfoByName

func (Actor) CommandInfoByName(commandList interface{}, commandName string) (CommandInfo, error)

CommandInfoByName returns the help information for a particular commandName in the commandList.

func (Actor) CommandInfos

func (Actor) CommandInfos(commandList interface{}) map[string]CommandInfo

CommandInfos returns a slice of CommandInfo that only fills in the Name and Description for all the commands in commandList

func (Actor) CreateArchive

func (actor Actor) CreateArchive(bitsPath string, resources []Resource) (io.ReadCloser, int64, error)

func (Actor) ExecuteSecureShell

func (actor Actor) ExecuteSecureShell(sshClient SecureShellClient, sshOptions SSHOptions) error

func (Actor) GatherArchiveResources

func (actor Actor) GatherArchiveResources(archivePath string) ([]Resource, error)

GatherArchiveResources returns a list of resources for an archive.

func (Actor) GatherDirectoryResources

func (actor Actor) GatherDirectoryResources(sourceDir string) ([]Resource, error)

GatherDirectoryResources returns a list of resources for a directory.

func (Actor) IsOrgTargeted

func (actor Actor) IsOrgTargeted() bool

IsOrgTargeted determines whether an org is being targeted by the CLI

func (Actor) IsSpaceTargeted

func (actor Actor) IsSpaceTargeted() bool

IsSpaceTargeted determines whether a space is being targeted by the CLI

func (Actor) ReadArchive

func (Actor) ReadArchive(archivePath string) (io.ReadCloser, int64, error)

func (Actor) RequireCurrentUser

func (actor Actor) RequireCurrentUser() (string, error)

func (Actor) RequireTargetedOrg

func (actor Actor) RequireTargetedOrg() (string, error)

func (Actor) ZipArchiveResources

func (actor Actor) ZipArchiveResources(sourceArchivePath string, filesToInclude []Resource) (string, error)

ZipArchiveResources zips an archive and a sorted (based on full path/filename) list of resources and returns the location. On Windows, the filemode for user is forced to be readable and executable.

func (Actor) ZipDirectoryResources

func (actor Actor) ZipDirectoryResources(sourceDir string, filesToInclude []Resource) (string, error)

ZipDirectoryResources zips a directory and a sorted (based on full path/filename) list of resources and returns the location. On Windows, the filemode for user is forced to be readable and executable.

type AuthActor

type AuthActor interface {
	IsLoggedIn() bool
}

type CommandFlag

type CommandFlag struct {
	// Short is the short form of the flag
	Short string

	// Long is the long form of the flag
	Long string

	// Description is the description of the flag
	Description string

	// Default is the flag's default value
	Default string
}

CommandFlag contains the help details of a command's flag

type CommandInfo

type CommandInfo struct {
	// Name is the command name
	Name string

	// Description is the command description
	Description string

	// Alias is the command alias
	Alias string

	// Usage is the command usage string
	Usage string

	// Examples is the command examples string
	Examples string

	// Resources is the types of object that the command applies to
	Resources string

	// RelatedCommands is a list of commands related to the command
	RelatedCommands []string

	// Flags contains the list of flags for this command
	Flags []CommandFlag

	// Environment is a list of environment variables specific for this command
	Environment []EnvironmentVariable
}

CommandInfo contains the help details of a command

type Config

type Config interface {
	AccessToken() string
	BinaryName() string
	CurrentUserName() (string, error)
	HasTargetedOrganization() bool
	HasTargetedSpace() bool
	IsCFOnK8s() bool
	RefreshToken() string
	TargetedOrganizationName() string
	Verbose() (bool, []string)
}

Config a way of getting basic CF configuration

type DefaultAuthActor

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

func NewDefaultAuthActor

func NewDefaultAuthActor(config Config) DefaultAuthActor

func (DefaultAuthActor) IsLoggedIn

func (a DefaultAuthActor) IsLoggedIn() bool

type EnvironmentVariable

type EnvironmentVariable struct {
	Name         string
	Description  string
	DefaultValue string
}

EnvironmentVariable contains env vars specific for this command

type HasExamples

type HasExamples interface {
	Examples() string
}

HasExamples is an interface that commands may implement if they want to define their examples text in a Examples() method, which gives them more flexibility than a struct tag.

type HasResources

type HasResources interface {
	Resources() string
}

HasResources is an interface that commands may implement if they want to define their resources text in a Resources() method, which gives them more flexibility than a struct tag.

type HasUsage

type HasUsage interface {
	Usage() string
}

HasUsage is an interface that commands may implement if they want to define their usage text in a Usage() method, which gives them more flexibility than a struct tag.

type K8sAuthActor

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

func NewK8sAuthActor

func NewK8sAuthActor(config Config) K8sAuthActor

func (K8sAuthActor) IsLoggedIn

func (a K8sAuthActor) IsLoggedIn() bool

type LocalPortForward

type LocalPortForward clissh.LocalPortForward

type LogCacheClient

type LogCacheClient interface {
	Read(
		ctx context.Context,
		sourceID string,
		start time.Time,
		opts ...logcache.ReadOption,
	) ([]*loggregator_v2.Envelope, error)
}

LogCacheClient is a client for getting logs.

type LogMessage

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

func GetRecentLogs

func GetRecentLogs(appGUID string, client LogCacheClient) ([]LogMessage, error)

func NewLogMessage

func NewLogMessage(message string, messageType string, timestamp time.Time, sourceType string, sourceInstance string) *LogMessage

func (LogMessage) Message

func (log LogMessage) Message() string

func (LogMessage) SourceInstance

func (log LogMessage) SourceInstance() string

func (LogMessage) SourceType

func (log LogMessage) SourceType() string

func (LogMessage) Staging

func (log LogMessage) Staging() bool

func (LogMessage) Timestamp

func (log LogMessage) Timestamp() time.Time

func (LogMessage) Type

func (log LogMessage) Type() string

type LogMessages

type LogMessages []*LogMessage

func (LogMessages) Len

func (lm LogMessages) Len() int

func (LogMessages) Less

func (lm LogMessages) Less(i, j int) bool

func (LogMessages) Swap

func (lm LogMessages) Swap(i, j int)

type Resource

type Resource struct {
	Filename string      `json:"fn"`
	Mode     os.FileMode `json:"mode"`
	SHA1     string      `json:"sha1"`
	Size     int64       `json:"size"`
}

func (Resource) ToV3Resource

func (r Resource) ToV3Resource() V3Resource

ToV3Resource converts a sharedaction Resource to V3 Resource format

type SSHOptions

type SSHOptions struct {
	Commands              []string
	Username              string
	Passcode              string
	Endpoint              string
	HostKeyFingerprint    string
	SkipHostValidation    bool
	SkipRemoteExecution   bool
	TTYOption             TTYOption
	LocalPortForwardSpecs []LocalPortForward
}

type SecureShellClient

type SecureShellClient interface {
	Connect(username string, passcode string, sshEndpoint string, sshHostKeyFingerprint string, skipHostValidation bool) error
	Close() error
	InteractiveSession(commands []string, terminalRequest clissh.TTYRequest) error
	LocalPortForward(localPortForwardSpecs []clissh.LocalPortForward) error
	Wait() error
}

type TTYOption

type TTYOption clissh.TTYRequest
const (
	RequestTTYAuto TTYOption = iota
	RequestTTYNo
	RequestTTYYes
	RequestTTYForce
)

type V3Resource

type V3Resource ccv3.Resource

func (V3Resource) ToV2Resource

func (r V3Resource) ToV2Resource() Resource

ToV2Resource converts a V3 Resource to V2 Resource format

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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