sheller

package
v0.0.0-...-a78bd83 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_EXPIRY_BUFFER = 10 * time.Minute

Functions

func InitializeLibrary

func InitializeLibrary(config *Config) error

InitializeLibrary initializes the Sheller library with the provided configuration. It loads the configuration from environment variables and validates it.

func LoadConfigFromEnv

func LoadConfigFromEnv(config *Config)

LoadConfigFromEnv loads configuration options from environment variables. It updates the provided config object with values from the environment.

func ValidateAkeylessCliProfileExists

func ValidateAkeylessCliProfileExists(config *Config, name string) error

func ValidateAkeylessHomeDirectoryExists

func ValidateAkeylessHomeDirectoryExists(config *Config) error

func ValidateConfig

func ValidateConfig(config *Config) error

ValidateConfig validates the provided configuration. It checks if the CLIPath, Profile, and AkeylessPath are set correctly and if the files and directories they point to exist and are accessible.

Types

type Config

type Config struct {
	CLIPath      string        // Path to the Akeyless CLI executable
	Profile      string        // Name of the Akeyless CLI profile to use
	AkeylessPath string        // Path to the .akeyless directory
	ExpiryBuffer time.Duration // Buffer time before token expiry to trigger re-authentication
	Debug        bool          // Debug flag to enable or disable debug logging
	AppFs        *afero.Afero  // Filesystem to use to enable mocking of the filesystem
}

Config holds the configuration options for the Sheller library.

func NewConfig

func NewConfig(cliPath, profile, akeylessPath string, expiryBuffer time.Duration, debug bool) *Config

NewConfig creates a new Config instance with the provided parameters. cliPath: Path to the Akeyless CLI executable profile: Name of the Akeyless CLI profile to use akeylessPath: Path to the .akeyless directory expiryBuffer: Buffer time before token expiry to trigger re-authentication debug: Debug flag to enable or disable debug logging

func NewConfigWithDefaults

func NewConfigWithDefaults() *Config

NewConfigWithDefaults creates a new Config instance with default values. It pulls the CLIPath from the system path and uses the "default" CLI profile.

type Profile

type Profile struct {
	Name       string `toml:"name"`
	AccessID   string `toml:"access_id"`
	AccessType string `toml:"access_type"`
}

Profile represents an Akeyless CLI profile.

func GetProfile

func GetProfile(name string, config *Config) (*Profile, error)

GetProfile loads the specified profile from the .akeyless/profiles directory.

func ListProfiles

func ListProfiles(config *Config) ([]Profile, error)

ListProfiles lists all profiles in the .akeyless/profiles directory.

type Token

type Token struct {
	AccessID  string    `json:"access_id"`
	Token     string    `json:"token"`
	Expiry    time.Time `json:"expiry"`
	AuthCreds string    `json:"auth_creds"`
	UamCreds  string    `json:"uam_creds"`
	KfmCreds  string    `json:"kfm_creds"`
}

Token holds the details of an authentication token.

func CheckForExistingToken

func CheckForExistingToken(profile *Profile, config *Config) (*Token, error)

CheckForExistingToken checks for an existing valid token for the specified profile.

func GetToken

func GetToken(profile *Profile, config *Config) (*Token, error)

GetToken retrieves a token for the specified profile, either by reusing an existing valid token or by shelling out to the Akeyless CLI.

func InitializeAndGetToken

func InitializeAndGetToken(config *Config) (*Token, error)

InitializeAndGetToken initializes the library, gets the profile, and retrieves the token. It returns the retrieved token or an error if something went wrong.

func ParseTokenFile

func ParseTokenFile(path string) (*Token, error)

ParseTokenFile parses a token file and returns a Token struct.

func ShellOutForNewToken

func ShellOutForNewToken(profile *Profile, config *Config) (*Token, error)

ShellOutForNewToken shells out to the Akeyless CLI to obtain a new token for the specified profile.

Jump to

Keyboard shortcuts

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