sharedaction

package
v0.0.0-...-e4dbece Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

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

Index

Constants

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

This section is empty.

Types

type Actor

type Actor struct {
	Config Config
}

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) IsLoggedIn

func (actor Actor) IsLoggedIn() bool

IsLoggedIn checks whether a user has authenticated with CF

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 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, may contain examples and flavor text
	Usage 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
	RefreshToken() string
	TargetedOrganizationName() string
	Verbose() (bool, []string)
}

Config a way of getting basic CF configuration

type EnvironmentVariable

type EnvironmentVariable struct {
	Name         string
	Description  string
	DefaultValue string
}

EnvironmentVariable contains env vars specific for this command

type LocalPortForward

type LocalPortForward clissh.LocalPortForward

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