helpers

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnonymizeFilepath added in v0.1.4

func AnonymizeFilepath(filePath string) string

AnonymizeFilepath checks if the filepath has a prefixed user ID strips that, and then returns the filepath

func CheckTokenExpiration added in v0.1.0

func CheckTokenExpiration(accessToken string) error

CheckTokenExpiration is used to determine whether the token is expiring in less than a day

func CheckValidChars added in v0.1.1

func CheckValidChars(filename string) error

Check for invalid characters

func CreatePubFile added in v0.1.1

func CreatePubFile(publicKey string, filename string) (string, error)

Create public key file

func FileExists

func FileExists(filename string) bool

FileExists checks if a file exists in the file system. Note that this function will not check if the file is readable, or if the file is a directory, only if it exists.

func FileIsReadable

func FileIsReadable(filename string) bool

FileIsReadable checks that a file exists, and is readable by the program.

func GetPublicKey64 added in v0.1.4

func GetPublicKey64(pubKeyPath *string) (string, error)

Reads the public key and encodes it in base64

func GetPublicKeyFromSession added in v0.1.1

func GetPublicKeyFromSession() (string, error)

reads the .sda-cli-session file, creates the public key file and returns the name of the file

func ListFiles added in v0.1.0

func ListFiles(config Config, prefix string) ([]types.Object, error)

ListFiles returns a list for s3 objects that correspond to files with the specified prefix.

func ParseS3ErrorResponse added in v0.0.4

func ParseS3ErrorResponse(respBody io.Reader) (string, error)

ParseS3ErrorResponse checks if reader stream is xml encoded and if yes unmarshals the xml response and returns it.

func PrintHostBase added in v0.1.6

func PrintHostBase(hostBase string)

func PromptPassword

func PromptPassword(message string) (password string, err error)

PromptPassword creates a user prompt for inputting passwords, where all characters are masked with "*"

Types

type Config added in v0.1.0

type Config struct {
	// #nosec G117
	AccessKey string `ini:"access_key"`
	// #nosec G117
	SecretKey string `ini:"secret_key"`
	// #nosec G117
	AccessToken          string `ini:"access_token"`
	HostBucket           string `ini:"host_bucket"`
	HostBase             string `ini:"host_base"`
	MultipartChunkSizeMb int64  `ini:"multipart_chunk_size_mb"`
	GuessMimeType        bool   `ini:"guess_mime_type"`
	Encoding             string `ini:"encoding"`
	CheckSslCertificate  bool   `ini:"check_ssl_certificate"`
	CheckSslHostname     bool   `ini:"check_ssl_hostname"`
	UseHTTPS             bool   `ini:"use_https"`
	SocketTimeout        int    `ini:"socket_timeout"`
	HumanReadableSizes   bool   `ini:"human_readable_sizes"`
	PublicKey            string `ini:"public_key"`
	MaxS3Keys            int32  // changes MaxKeys of the aws SDK, only used by tests. Default is 1000.
}

Config struct for storing the s3cmd file values

func GetAuth added in v0.1.1

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

GetAuth calls LoadConfig if we have a config file, otherwise try to load .sda-cli-session

func LoadConfigFile added in v0.1.0

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

LoadConfigFile loads ini configuration file to the Config struct

type EncryptionFileSet

type EncryptionFileSet struct {
	Unencrypted string
	Encrypted   string
}

struct type to keep track of infiles and outfiles for encryption and decryption

type XMLerrorResponse added in v0.0.4

type XMLerrorResponse struct {
	Code     string `xml:"Code"`
	Message  string `xml:"Message"`
	Resource string `xml:"Resource"`
}

struct type to unmarshall xml error response from s3 server

Jump to

Keyboard shortcuts

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